diff --git a/README.md b/README.md index cd30044d..4e3a1c17 100644 --- a/README.md +++ b/README.md @@ -45,23 +45,29 @@ public function registerBundles() ## Configuration in Symfony 3 +The configuration is the same as the following section, but the path should be +`app/config.yml` instead. + +## Configuration in Symfony 4 and up + If you do not explicitly configure this bundle, an HTMLPurifier service will be defined as `exercise_html_purifier.default`. This behavior is the same as if you had specified the following configuration: ```yaml -# app/config.yml +# config/packages/exercise_html_purifier.yaml exercise_html_purifier: default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier' ``` -The `default` profile is special in that it is used as the configuration for the -`exercise_html_purifier.default` service as well as the base configuration for -other profiles you might define. +The `default` profile is special, it is *always* defined and its configuration +is inherited by all custom profiles. +`exercise_html_purifier.default` is the default service using the base +configuration. ```yaml -# app/config.yml +# config/packages/exercise_html_purifier.yaml exercise_html_purifier: default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier' @@ -81,45 +87,12 @@ option to suppress the default path. [configuration documentation]: http://htmlpurifier.org/live/configdoc/plain.html -## Configuration in Symfony 4 and up - -If you do not explicitly configure this bundle, an HTMLPurifier service will be -defined as `exercise_html_purifier.default`. This behavior is the same as if you -had specified the following configuration: - -```yaml -# config/packages/exercise_html_purifier.yaml - -exercise_html_purifier: - default_cache_serializer_path: '%kernel.cache_dir%/htmlpurifier' -``` - -The `default` profile is special, it is *always* defined and its configuration -is inherited by all custom profiles. -`exercise_html_purifier.default` is the default service using the base -configuration. - -```yaml -# config/packages/exercise_html_purifier.yaml - -exercise_html_purifier: - default_cache_serializer_path: 'tmp/htmlpurifier' - html_profiles: - default: - config: - Cache.SerializerPermissions: 777 - custom: - config: - Core.Encoding: 'ISO-8859-1' -``` - ## Autowiring By default type hinting `\HtmlPurifier` in your services will autowire the `exercise_html_purifier.default` service. To override it and use your own config as default autowired services just add -this in you `app/config/services.yml` in you use symfony 3 or `config/services.yaml` -if you use symfony 4: +this configuration: ```yaml # config/services.yaml @@ -131,7 +104,8 @@ services: ### Using a custom purifier class as default -If you want to use your own class as default purifier, define a new alias: +If you want to use your own class as default purifier, define the new alias as +below: ```yaml # config/services.yaml @@ -141,10 +115,7 @@ services: exercise_html_purifier.default: '@App\Html\CustomHtmlPurifier' ``` -In such case, the custom purifier will use its own defined configuration, -ignoring the bundle configuration. - -### Argument binding +### Argument binding (Symfony >= 4.4) The bundle also leverages the alias argument binding for each profile. So the following config: @@ -170,11 +141,10 @@ public function __construct(\HTMLPurifier $galleryPurifier) {} // gallery config ## Form Type Extension This bundles provides a form type extension for filtering form fields with -HTMLPurifier. Purification is done during the PRE_SUBMIT event, which -means that client data will be filtered before binding to the form. +HTMLPurifier. Purification is done early during the PRE_SUBMIT event, which +means that client data will be filtered before being bound to the form. -The following example demonstrates one possible way to integrate an HTMLPurifier -transformer into a form by way of a custom field type: +Two options are automatically available in all `TextType` based types: ```php