From c87632c4ec6e1500d9d423c767f03622fa604d63 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Fri, 4 Oct 2019 15:17:20 +0200 Subject: [PATCH 0001/7107] [EventDispatcher] Document event name aliases. --- components/event_dispatcher.rst | 50 ++++++++++++++++++++++-- event_dispatcher.rst | 67 +++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 3 deletions(-) diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index 89853d22941..bf055411efa 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -220,11 +220,55 @@ determine which instance is passed. $containerBuilder->register('subscriber_service_id', \AcmeSubscriber::class) ->addTag('kernel.event_subscriber'); + ``RegisterListenersPass`` is able to resolve aliased class names which for + instance allows to refer to an event via the fully qualified class name + (FQCN) of the event class. The pass will read the alias mapping from a + dedicated container parameter. This parameter can be extended by registering + another compiler pass, ``AddEventAliasesPass``:: + + use Symfony\Component\DependencyInjection\Compiler\PassConfig; + use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; + use Symfony\Component\DependencyInjection\Reference; + use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass; + use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; + use Symfony\Component\EventDispatcher\EventDispatcher; + + $containerBuilder = new ContainerBuilder(new ParameterBag()); + $containerBuilder->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING); + $containerBuilder->addCompilerPass(new AddEventAliasesPass([ + \AcmeFooActionEvent::class => 'acme.foo.action', + ])); + + $containerBuilder->register('event_dispatcher', EventDispatcher::class); + + // registers an event listener + $containerBuilder->register('listener_service_id', \AcmeListener::class) + ->addTag('kernel.event_listener', [ + // will be translated to 'acme.foo.action' by RegisterListenersPass. + 'event' => \AcmeFooActionEvent::class, + 'method' => 'onFooAction', + ]); + + .. note:: + + Note that ``AddEventAliasesPass`` has to be processed before ``RegisterListenersPass``. + By default, the listeners pass assumes that the event dispatcher's service id is ``event_dispatcher``, that event listeners are tagged with the - ``kernel.event_listener`` tag and that event subscribers are tagged - with the ``kernel.event_subscriber`` tag. You can change these default - values by passing custom values to the constructor of ``RegisterListenersPass``. + ``kernel.event_listener`` tag, that event subscribers are tagged + with the ``kernel.event_subscriber`` tag and that the alias mapping is + stored as parameter ``event_dispatcher.event_aliases``. You can change these + default values by passing custom values to the constructors of + ``RegisterListenersPass`` and ``AddEventAliasesPass``. + +.. versionadded:: 4.3 + + Aliasing event names is possible since Symfony 4.3. + +.. versionadded:: 4.4 + + The ``AddEventAliasesPass`` class was introduced in Symfony 4.4. .. _event_dispatcher-closures-as-listeners: diff --git a/event_dispatcher.rst b/event_dispatcher.rst index c1c7d1c6f95..58239019bb7 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -246,6 +246,73 @@ there are some minor advantages for each of them: * **Listeners are more flexible** because bundles can enable or disable each of them conditionally depending on some configuration value. +.. _event-aliases: + +Event Aliases +------------- + +When configuring event listeners and subscribers via dependency injection, +Symfony's core events can also be referred to by the fully qualified class +name (FQCN) of the corresponding event class:: + + // src/EventSubscriber/RequestSubscriber.php + namespace App\EventSubscriber; + + use Symfony\Component\EventDispatcher\EventSubscriberInterface; + use Symfony\Component\HttpKernel\Event\RequestEvent; + + class RequestSubscriber implements EventSubscriberInterface + { + public static function getSubscribedEvents(): array + { + return [ + RequestEvent::class => 'onKernelRequest', + ]; + } + + public function onKernelRequest(RequestEvent $event) + { + // ... + } + } + +.. versionadded:: 4.3 + + Referring Symfony's core events via the FQCN of the event class is possible + since Symfony 4.3. + +Internally, the event FQCN are treated as aliases for the original event names. +Since the mapping already happens when compiling the service container, event +listeners and subscribers using FQCN instead of event names will appear under +the original event name when inspecting the event dispatcher. + +This alias mapping can be extended for custom events by registering the +compiler pass ``AddEventAliasesPass``:: + + // src/Kernel.php + use App\Event\MyCustomEvent; + use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\EventDispatcher\DependencyInjection\AddEventAliasesPass; + use Symfony\Component\HttpKernel\Kernel as BaseKernel; + + class Kernel extends BaseKernel + { + protected function build(ContainerBuilder $container) + { + $container->addCompilerPass(new AddEventAliasesPass([ + MyCustomEvent::class => 'my_custom_event', + ])); + } + } + +The compiler pass will always extend the existing list of aliases. Because of +that, it is safe to register multiple instances of the pass with different +configurations. + +.. versionadded:: 4.4 + + The ``AddEventAliasesPass`` class was introduced in Symfony 4.4. + Debugging Event Listeners ------------------------- From b600aa07523f2214d259175d7c1a2e39d584f239 Mon Sep 17 00:00:00 2001 From: Maciej Malarz Date: Thu, 10 Oct 2019 21:32:03 +0200 Subject: [PATCH 0002/7107] List CSV encoder's context options --- components/serializer.rst | 54 ++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 7 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 94c1ca0d5b1..fd44a459530 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -810,13 +810,6 @@ The ``CsvEncoder`` The ``CsvEncoder`` encodes to and decodes from CSV. -You can pass the context key ``as_collection`` in order to have the results -always as a collection. - -.. deprecated:: 4.2 - - Relying on the default value ``false`` is deprecated since Symfony 4.2. - The ``XmlEncoder`` ~~~~~~~~~~~~~~~~~~ @@ -1254,6 +1247,52 @@ These are the options available: ``remove_empty_tags`` If set to true, removes all empty tags in the generated XML. +The ``CsvEncoder`` +------------------ + +This encoder transforms arrays into CSV and vice versa. + +Context +~~~~~~~ + +The ``encode()`` method defines a third optional parameter called ``context`` +which defines the configuration options for the CsvEncoder an associative array:: + + $csvEncoder->encode($array, 'csv', $context); + +These are the options available: + +``csv_delimiter`` + Sets the field delimiter separating values (one character only, default: ``,``). + +``csv_enclosure`` + Sets the field enclosure (one character only, default: ``"``). + +``csv_escape_char`` + Sets the escape character (at most one character, default: empty string). + +``csv_key_separator`` + Sets the separator for array's keys during its flattening (default: ``.``). + +``csv_headers`` + Sets the headers for the data (default: ``[]``, inferred from input data's keys). + +``csv_escape_formulas`` + Escapes fields containg formulas by prepending them with a ``\t`` character (default: ``false``). + +``as_collection`` + Always returns results as a collection, even if only one line is decoded (default: ``false``). + +.. deprecated:: 4.2 + + Relying on the default value ``false`` is deprecated since Symfony 4.2. + +``no_headers`` + Disables header in the encoded CSV (default: ``false``). + +``output_utf8_bom`` + Outputs special `UTF-8 BOM`_ along with encoded data (default: ``false``). + Handling Constructor Arguments ------------------------------ @@ -1506,6 +1545,7 @@ Learn more .. _YAML: http://yaml.org/ .. _CSV: https://tools.ietf.org/html/rfc4180 .. _`RFC 7807`: https://tools.ietf.org/html/rfc7807 +.. _`UTF-8 BOM`: https://en.wikipedia.org/wiki/Byte_order_mark .. _`Value Objects`: https://en.wikipedia.org/wiki/Value_object .. _`API Platform`: https://api-platform.com .. _`list of PHP timezones`: https://www.php.net/manual/en/timezones.php From 3a5c137954134fc59a9f37c82d76ca8d65e597a2 Mon Sep 17 00:00:00 2001 From: Clement Herreman Date: Tue, 19 Nov 2019 17:37:15 +0100 Subject: [PATCH 0003/7107] Add note about .env.local being ignored in test environment --- configuration.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configuration.rst b/configuration.rst index 1254e074038..d6e6f8abb1f 100644 --- a/configuration.rst +++ b/configuration.rst @@ -627,6 +627,11 @@ the only mandatory file and each file content overrides the previous one: env vars overrides only for some environment. It's similar to ``.env.local``, but the overrides only apply to some particular environment. +.. note:: + + ``.env.local`` is always ignored in test environment. The logic is that + tests should always produce the same results for everyone. + .. note:: The real environment variables defined in the server always win over the From 3d50d7861817affa3fe28e91a3930735083b7b1e Mon Sep 17 00:00:00 2001 From: Harald Leithner Date: Mon, 25 Nov 2019 14:09:15 +0100 Subject: [PATCH 0004/7107] Set PHP Version requirement to 7.2.5 --- setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.rst b/setup.rst index fe01d60201e..70ef50c1fdf 100644 --- a/setup.rst +++ b/setup.rst @@ -17,7 +17,7 @@ Technical Requirements Before creating your first Symfony application you must: -* Install PHP 7.2.9 or higher and these PHP extensions (which are installed and +* Install PHP 7.2.5 or higher and these PHP extensions (which are installed and enabled by default in most PHP 7 installations): `Ctype`_, `iconv`_, `JSON`_, `PCRE`_, `Session`_, `SimpleXML`_, and `Tokenizer`_; * `Install Composer`_, which is used to install PHP packages; From 9457979ba708f2ef3304a30c3639959f57ded3c1 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 26 Nov 2019 08:46:27 -0500 Subject: [PATCH 0005/7107] Remove ErrorRenderer reference everywhere --- components/error_handler.rst | 10 -- components/error_renderer.rst | 159 ------------------ components/http_kernel.rst | 2 +- controller/error_pages.rst | 2 +- .../http_kernel_httpkernel_class.rst | 4 +- 5 files changed, 4 insertions(+), 173 deletions(-) delete mode 100644 components/error_renderer.rst diff --git a/components/error_handler.rst b/components/error_handler.rst index f5b1e7b9c11..7452ebce3e5 100644 --- a/components/error_handler.rst +++ b/components/error_handler.rst @@ -67,11 +67,6 @@ to enable this error handler:: ErrorHandler::register(); -.. tip:: - - If you want to get even better exception pages, install the - :doc:`ErrorRenderer component ` too. - Catching PHP Function Errors and Turning Them into Exceptions ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -145,11 +140,6 @@ to enable this exception handler:: ExceptionHandler::register(); -.. tip:: - - If you want to get even better exception pages, install the - :doc:`ErrorRenderer component ` too. - .. _component-debug-class-loader: Class Loading Debugger diff --git a/components/error_renderer.rst b/components/error_renderer.rst deleted file mode 100644 index 607935aa6bb..00000000000 --- a/components/error_renderer.rst +++ /dev/null @@ -1,159 +0,0 @@ -.. index:: - single: Error - single: Exception - single: Components; ErrorRenderer - -The ErrorRenderer Component -=========================== - - The ErrorRenderer component converts PHP errors and exceptions into other - formats such as JSON and HTML and renders them. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/error-renderer - -.. include:: /components/require_autoload.rst.inc - -Usage ------ - -The ErrorRenderer component provides several renderers to convert PHP errors and -exceptions into other formats such as JSON and HTML easier to debug when working -with HTTP applications:: - - use Symfony\Component\ErrorRenderer\ErrorRenderer; - use Symfony\Component\ErrorRenderer\ErrorRenderer\HtmlErrorRenderer; - use Symfony\Component\ErrorRenderer\ErrorRenderer\JsonErrorRenderer; - use Symfony\Component\ErrorRenderer\Exception\FlattenException; - use Symfony\Component\HttpFoundation\Response; - - $renderers = [ - new HtmlErrorRenderer(), - new JsonErrorRenderer(), - // ... - ]; - $errorRenderer = new ErrorRenderer($renderers); - - try { - // ... - } catch (\Throwable $e) { - $e = FlattenException::createFromThrowable($e); - - return new Response($errorRenderer->render($e, 'json'), 500, ['Content-Type' => 'application/json']); - } - -Built-in Error Renderers ------------------------- - -This component provides error renderers for the most common needs: - - * :class:`Symfony\\Component\\ErrorRenderer\\ErrorRenderer\\HtmlErrorRenderer` - renders errors in HTML format; - * :class:`Symfony\\Component\\ErrorRenderer\\ErrorRenderer\\JsonErrorRenderer` - renders errors in JSON format and it's compliant with the `RFC 7807`_ standard; - * :class:`Symfony\\Component\\ErrorRenderer\\ErrorRenderer\\XmlErrorRenderer` - renders errors in XML and Atom formats. It's compliant with the `RFC 7807`_ - standard; - * :class:`Symfony\\Component\\ErrorRenderer\\ErrorRenderer\\TxtErrorRenderer` - renders errors in plain text format. - -Adding a Custom Error Renderer ------------------------------- - -Error renderers are PHP classes that implement the -:class:`Symfony\\Component\\ErrorRenderer\\ErrorRenderer\\ErrorRendererInterface`. -For example, if you need to render errors in `JSON-LD format`_, create this -class anywhere in your project:: - - namespace App\ErrorRenderer; - - use Symfony\Component\ErrorRenderer\ErrorRenderer\ErrorRendererInterface; - use Symfony\Component\ErrorRenderer\Exception\FlattenException; - - class JsonLdErrorRenderer implements ErrorRendererInterface - { - private $debug; - - public function __construct(bool $debug = true) - { - $this->debug = $debug; - } - - public static function getFormat(): string - { - return 'jsonld'; - } - - public function render(FlattenException $exception): string - { - $content = [ - '@id' => 'https://example.com', - '@type' => 'error', - '@context' => [ - 'title' => $exception->getTitle(), - 'code' => $exception->getStatusCode(), - 'message' => $exception->getMessage(), - ], - ]; - - if ($this->debug) { - $content['@context']['exceptions'] = $exception->toArray(); - } - - return (string) json_encode($content); - } - } - -.. tip:: - - If the ``getFormat()`` method of your error renderer matches one of formats - supported by the built-in renderers, the built-in renderer is replaced by - your custom renderer. - -To enable the new error renderer in the application, -:ref:`register it as a service ` and -:doc:`tag it ` with the ``error_renderer.renderer`` -tag. - -.. configuration-block:: - - .. code-block:: yaml - - # config/services.yaml - services: - App\ErrorRenderer\JsonLdErrorRenderer: - arguments: ['%kernel.debug%'] - tags: ['error_renderer.renderer'] - - .. code-block:: xml - - - - - - - - %kernel.debug% - - - - - - .. code-block:: php - - // config/services.php - use App\ErrorRenderer\JsonLdErrorRenderer; - - $container->register(JsonLdErrorRenderer::class) - ->setArguments([$container->getParameter('kernel.debug')]); - ->addTag('error_renderer.renderer'); - -.. _`RFC 7807`: https://tools.ietf.org/html/rfc7807 -.. _`JSON-LD format`: https://en.wikipedia.org/wiki/JSON-LD diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 046ca09a6f6..9ba9226abeb 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -554,7 +554,7 @@ below for more details). The listener has several goals: 1) The thrown exception is converted into a - :class:`Symfony\\Component\\ErrorRenderer\\Exception\\FlattenException` + :class:`Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` object, which contains all the information about the request, but which can be printed and serialized. diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 482ba6edd95..b1a6e2d3992 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -247,7 +247,7 @@ the request that will be dispatched to your controller. In addition, your contro will be passed two parameters: ``exception`` - A :class:`\\Symfony\\Component\\ErrorRenderer\\Exception\\FlattenException` + A :class:`\\Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` instance created from the exception being handled. ``logger`` diff --git a/create_framework/http_kernel_httpkernel_class.rst b/create_framework/http_kernel_httpkernel_class.rst index 5845f4219dc..96bda4df692 100644 --- a/create_framework/http_kernel_httpkernel_class.rst +++ b/create_framework/http_kernel_httpkernel_class.rst @@ -69,7 +69,7 @@ Our code is now much more concise and surprisingly more robust and more powerful than ever. For instance, use the built-in ``ExceptionListener`` to make your error management configurable:: - $errorHandler = function (Symfony\Component\ErrorRenderer\Exception\FlattenException $exception) { + $errorHandler = function (Symfony\Component\ErrorHandler\Exception\FlattenException $exception) { $msg = 'Something went wrong! ('.$exception->getMessage().')'; return new Response($msg, $exception->getStatusCode()); @@ -91,7 +91,7 @@ The error controller reads as follows:: // example.com/src/Calendar/Controller/ErrorController.php namespace Calendar\Controller; - use Symfony\Component\ErrorRenderer\Exception\FlattenException; + use Symfony\Component\ErrorHandler\Exception\FlattenException; use Symfony\Component\HttpFoundation\Response; class ErrorController From 71469628c7fae4bc107f83e82012379df83f68b5 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Wed, 27 Nov 2019 14:57:52 +0100 Subject: [PATCH 0006/7107] Add documentation for exponential format number --- components/expression_language/syntax.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index 147782b4c9f..045451491f5 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -19,6 +19,7 @@ The component supports: * **hashes** - using JSON-like notation (e.g. ``{ foo: 'bar' }``) * **booleans** - ``true`` and ``false`` * **null** - ``null`` +* **exponential** - also known as scientific (e.g. ``1.99E+3`` or ``1e-2``) .. caution:: From 6ba282e22b352ae44e02c829c9129b4a2c8b864b Mon Sep 17 00:00:00 2001 From: Bagus Erlang Date: Wed, 27 Nov 2019 13:21:13 +0800 Subject: [PATCH 0007/7107] uppercase --- setup.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.rst b/setup.rst index b6ccd34210b..f9585b1eb6a 100644 --- a/setup.rst +++ b/setup.rst @@ -237,7 +237,7 @@ stable version. If you want to use an LTS version, add the ``--version`` option: .. code-block:: terminal - # use the most recent 'lts' version + # use the most recent LTS version $ symfony new my_project_name --version=lts # use the 'next' Symfony version to be released (still in development) From 79160c8f118dfff54741a931c20187917bc94dc6 Mon Sep 17 00:00:00 2001 From: MrYamous Date: Wed, 27 Nov 2019 16:42:58 +0100 Subject: [PATCH 0008/7107] Add versionadded in file Co-Authored-By: Oskar Stark --- components/expression_language/syntax.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index 045451491f5..5b7ee72ec7a 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -21,6 +21,10 @@ The component supports: * **null** - ``null`` * **exponential** - also known as scientific (e.g. ``1.99E+3`` or ``1e-2``) + .. versionadded:: 4.4 + + The ``exponential`` literal was introduced in Symfony 4.4. + .. caution:: A backslash (``\``) must be escaped by 4 backslashes (``\\\\``) in a string From 7719243997ee6b5d53993f863dd7570b84d24206 Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Wed, 27 Nov 2019 22:37:23 +0100 Subject: [PATCH 0009/7107] fix TraceableEventDispatcherInterface removed in 5.0 --- components/event_dispatcher/traceable_dispatcher.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/event_dispatcher/traceable_dispatcher.rst b/components/event_dispatcher/traceable_dispatcher.rst index 87d58023445..33a98a2336b 100644 --- a/components/event_dispatcher/traceable_dispatcher.rst +++ b/components/event_dispatcher/traceable_dispatcher.rst @@ -41,10 +41,10 @@ to register event listeners and dispatch events:: $traceableEventDispatcher->dispatch($event, 'event.the_name'); After your application has been processed, you can use the -:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface::getCalledListeners` +:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getCalledListeners` method to retrieve an array of event listeners that have been called in your application. Similarly, the -:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcherInterface::getNotCalledListeners` +:method:`Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher::getNotCalledListeners` method returns an array of event listeners that have not been called:: // ... From 015d91a6199de25e38f7cd559343e014251ee886 Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Thu, 28 Nov 2019 00:01:04 +0100 Subject: [PATCH 0010/7107] Removed simple_form and simple_pre_auth --- security/auth_providers.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/security/auth_providers.rst b/security/auth_providers.rst index f5ec3723c7b..69fd0abaaa2 100644 --- a/security/auth_providers.rst +++ b/security/auth_providers.rst @@ -21,8 +21,6 @@ use-case matches one of these exactly, they're a great option: * :doc:`json_login ` * :ref:`X.509 Client Certificate Authentication (x509) ` * :ref:`REMOTE_USER Based Authentication (remote_user) ` -* ``simple_form`` -* ``simple_pre_auth`` .. _security-http_basic: From f5f64e1b3ea06304a96639f9de74bb5ac9608b6c Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Wed, 27 Nov 2019 23:27:50 +0100 Subject: [PATCH 0011/7107] Changed names of Intl classes in form types docs --- reference/forms/types/country.rst | 2 +- reference/forms/types/currency.rst | 2 +- reference/forms/types/language.rst | 2 +- reference/forms/types/locale.rst | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index dbf2a87cc5b..da066decbb9 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -70,7 +70,7 @@ Overridden Options choices ~~~~~~~ -**default**: ``Symfony\Component\Intl\Intl::getRegionBundle()->getCountryNames()`` +**default**: ``Symfony\Component\Intl\Countries::getNames()`` The country type defaults the ``choices`` option to the whole list of countries. The locale is used to translate the countries names. diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 83fdafa4e17..9921baa75d9 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -62,7 +62,7 @@ Overridden Options choices ~~~~~~~ -**default**: ``Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencyNames()`` +**default**: ``Symfony\Component\Intl\Currencies::getNames()`` The choices option defaults to all currencies. diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 7aee017fcce..9a751ecc4af 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -72,7 +72,7 @@ Overridden Options choices ~~~~~~~ -**default**: ``Symfony\Component\Intl\Intl::getLanguageBundle()->getLanguageNames()``. +**default**: ``Symfony\Component\Intl\Languages::getNames()``. The choices option defaults to all languages. The default locale is used to translate the languages names. diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 6afaddd6250..2ff8e24ce51 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -73,7 +73,7 @@ Overridden Options choices ~~~~~~~ -**default**: ``Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleNames()`` +**default**: ``Symfony\Component\Intl\Locales::getNames()`` The choices option defaults to all locales. It uses the default locale to specify the language. From d76b6d09434bce56e06a6d1f6c118d30551485ef Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Sat, 30 Nov 2019 01:07:36 +0100 Subject: [PATCH 0012/7107] Fix documentation for PhpUnitBridge regex configuration --- components/phpunit_bridge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 59217470965..7272bcc02a0 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -209,7 +209,7 @@ message, enclosed with ``/``. For example, with: - + From fcfe1ca796b67000dc8463c32ccd975d022abed4 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Sat, 30 Nov 2019 16:48:28 +0100 Subject: [PATCH 0013/7107] Remove references to the Twig extensions repo --- reference/dic_tags.rst | 37 ------------------------------------ reference/twig_reference.rst | 8 -------- 2 files changed, 45 deletions(-) diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index ceeaf202643..35a44883808 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -1288,42 +1288,6 @@ For information on how to create the actual Twig Extension class, see `Twig's documentation`_ on the topic or read the :doc:`/templating/twig_extension` article. -Before writing your own extensions, have a look at the -`Twig official extension repository`_ which already includes several -useful extensions. For example ``Intl`` and its ``localizeddate`` filter -that formats a date according to user's locale. These official Twig extensions -also have to be added as regular services: - -.. configuration-block:: - - .. code-block:: yaml - - services: - Twig\Extensions\IntlExtension: - tags: [twig.extension] - - .. code-block:: xml - - - - - - - - - - - - .. code-block:: php - - $container - ->register('Twig\Extensions\IntlExtension') - ->addTag('twig.extension') - ; - twig.loader ----------- @@ -1404,6 +1368,5 @@ For an example, see the ``DoctrineInitializer`` class inside the Doctrine Bridge. .. _`Twig's documentation`: https://twig.symfony.com/doc/2.x/advanced.html#creating-an-extension -.. _`Twig official extension repository`: https://github.com/fabpot/Twig-extensions .. _`SwiftMailer's Plugin Documentation`: http://swiftmailer.org/docs/plugins.html .. _`Twig Loader`: https://twig.symfony.com/doc/2.x/api.html#loaders diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 6c455c8b306..45af378af9d 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -28,12 +28,6 @@ describe these extra features. framework. You are probably using some other bundles as well, and those might come with their own extensions not covered here. -.. tip:: - - The `Twig Extensions repository`_ contains some additional Twig extensions - that do not belong to the Twig core, so you might want to have a look at - the `Twig Extensions documentation`_. - .. _reference-twig-functions: Functions @@ -771,6 +765,4 @@ The available attributes are: * ``app.flashes``, returns flash messages from the session .. _`Twig Reference`: https://twig.symfony.com/doc/2.x/#reference -.. _`Twig Extensions repository`: https://github.com/twigphp/Twig-extensions -.. _`Twig Extensions documentation`: http://twig-extensions.readthedocs.io/en/latest/ .. _`Twig Bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/Twig/Extension From 7ec6d9d140b41e03853e06bc4c7d85b729115815 Mon Sep 17 00:00:00 2001 From: "tien.xuan.vo" Date: Sat, 30 Nov 2019 23:09:30 +0700 Subject: [PATCH 0014/7107] [DependencyInjection] Bind tagged services --- service_container.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/service_container.rst b/service_container.rst index 44b2d1ee4db..1febe0cf8cc 100644 --- a/service_container.rst +++ b/service_container.rst @@ -665,6 +665,7 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type # optionally you can define both the name and type of the argument to match string $adminEmail: 'manager@example.com' Psr\Log\LoggerInterface $requestLogger: '@monolog.logger.request' + iterable $rules: !tagged_iterator app.foo.rule # ... @@ -695,6 +696,10 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type type="service" id="monolog.logger.request" /> + @@ -728,6 +733,7 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type // optionally you can define both the name and type of the argument to match ->bind('string $adminEmail', 'manager@example.com') ->bind(LoggerInterface::class.' $requestLogger', ref('monolog.logger.request')) + ->bind('iterable $rules', tagged_iterator('app.foo.rule')) ; // ... From c47d8ae727d592d071f941927e8b44532b2258b9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 27 Nov 2019 16:13:49 +0100 Subject: [PATCH 0015/7107] Tweak the IsTrue validation docs --- reference/constraints/IsTrue.rst | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index f4237a6c483..6ffeda1686e 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -1,9 +1,8 @@ IsTrue ====== -Validates that a value is ``true``. Specifically, this checks to see if -the value is exactly ``true``, exactly the integer ``1``, or exactly the -string "``1``". +Validates that a value is ``true``. Specifically, this checks if the value is +exactly ``true``, exactly the integer ``1``, or exactly the string ``"1"``. Also see :doc:`IsFalse `. @@ -23,9 +22,9 @@ Basic Usage ----------- This constraint can be applied to properties (e.g. a ``termsAccepted`` property -on a registration model) or to a "getter" method. It's most powerful in -the latter case, where you can assert that a method returns a true value. -For example, suppose you have the following method:: +on a registration model) and methods. It's most powerful in the latter case, +where you can assert that a method returns a true value. For example, suppose +you have the following method:: // src/AppBundle/Entity/Author.php namespace AppBundle\Entity; @@ -40,7 +39,7 @@ For example, suppose you have the following method:: } } -Then you can constrain this method with ``IsTrue``. +Then you can validate this method with ``IsTrue`` as follows: .. configuration-block:: From 9da96e1c8f5977c22ad04b3e2ab76877a2a68375 Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Wed, 27 Nov 2019 23:18:45 +0100 Subject: [PATCH 0016/7107] [minor] remove usage of Kernel::$rootDir from docs --- reference/configuration/kernel.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 4ef889f6fb5..5852927e7ad 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -105,7 +105,7 @@ method to return the right project directory:: Cache Directory ~~~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``$this->rootDir/cache/$this->environment`` +**type**: ``string`` **default**: ``$this->getProjectDir()/var/cache/$this->environment`` This returns the absolute path of the cache directory of your Symfony project. It's calculated automatically based on the current @@ -119,7 +119,7 @@ cache directory. Log Directory ~~~~~~~~~~~~~ -**type**: ``string`` **default**: ``$this->rootDir/log`` +**type**: ``string`` **default**: ``$this->getProjectDir()/var/log`` .. deprecated:: 4.2 From f046117ccf61991d4dc367ef858b5da74e26f585 Mon Sep 17 00:00:00 2001 From: Jerzy Zawadzki Date: Wed, 27 Nov 2019 23:44:47 +0100 Subject: [PATCH 0017/7107] Removed constructor parameters from AuthenticationTrustResolver --- components/security/authorization.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/components/security/authorization.rst b/components/security/authorization.rst index 647a204f0b5..7bfe29d6cfa 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -104,10 +104,8 @@ level of authentication, i.e. is the user fully authenticated, or only based on a "remember-me" cookie, or even authenticated anonymously?:: use Symfony\Component\Security\Core\Authentication\AuthenticationTrustResolver; - use Symfony\Component\Security\Core\Authentication\Token\AnonymousToken; - use Symfony\Component\Security\Core\Authentication\Token\RememberMeToken; - $trustResolver = new AuthenticationTrustResolver(AnonymousToken::class, RememberMeToken::class); + $trustResolver = new AuthenticationTrustResolver(); $authenticatedVoter = new AuthenticatedVoter($trustResolver); From 9007f8d566323cf37bce9283c7264771bc011881 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 30 Nov 2019 18:11:38 +0100 Subject: [PATCH 0018/7107] Fixed a merge conflict --- reference/twig_reference.rst | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index ad2eb85c139..6725f9a7f46 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -624,28 +624,8 @@ Global Variables app ~~~ -<<<<<<< HEAD The ``app`` variable is injected automatically by Symfony in all templates and provides access to lots of useful application information. Read more about the :ref:`Twig global app variable `. .. _`default filters and functions defined by Twig`: https://twig.symfony.com/doc/2.x/#reference -======= -The ``app`` variable is available everywhere and gives access to many commonly -needed objects and values. It is an instance of -:class:`Symfony\\Bundle\\FrameworkBundle\\Templating\\GlobalVariables`. - -The available attributes are: - -* ``app.user``, a PHP object representing the current user; -* ``app.request``, a :class:`Symfony\\Component\\HttpFoundation\\Request` object; -* ``app.session``, a :class:`Symfony\\Component\\HttpFoundation\\Session\\Session` object; -* ``app.environment``, a string with the name of the execution environment; -* ``app.debug``, a boolean telling whether the debug mode is enabled in the app; -* ``app.token``, a :class:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface` - object representing the security token -* ``app.flashes``, returns flash messages from the session - -.. _`Twig Reference`: https://twig.symfony.com/doc/2.x/#reference -.. _`Twig Bridge`: https://github.com/symfony/symfony/tree/master/src/Symfony/Bridge/Twig/Extension ->>>>>>> 3.4 From 0de1588a46ff2c0a30113948d5b456bc163deba6 Mon Sep 17 00:00:00 2001 From: Wouter J Date: Sun, 13 Oct 2019 01:38:54 +0200 Subject: [PATCH 0019/7107] Added article on password migrations --- security.rst | 1 + security/password_migration.rst | 210 ++++++++++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 security/password_migration.rst diff --git a/security.rst b/security.rst index c91f7babc2f..3bfb384121d 100644 --- a/security.rst +++ b/security.rst @@ -1000,6 +1000,7 @@ Authentication (Identifying/Logging in the User) security/form_login_setup security/json_login_setup security/guard_authentication + security/password_migration security/auth_providers security/user_provider security/ldap diff --git a/security/password_migration.rst b/security/password_migration.rst new file mode 100644 index 00000000000..7ce2d08d153 --- /dev/null +++ b/security/password_migration.rst @@ -0,0 +1,210 @@ +.. index:: + single: Security; How to Migrate a Password Hash + +How to Migrate a Password Hash +============================== + +.. versionadded:: 4.4 + + Password migration was introduced in Symfony 4.4. + +In order to protect passwords, it is recommended to store them using the latest +hash algorithms. This means that if a better hash algorithm is supported on the +system, the user's password should be rehashed and stored. Symfony provides this +functionality when a user is successfully authenticated. + +To enable this, make sure you apply the following steps to your application: + +#. `Configure a new Encoder Using "migrate_from"`_ +#. `Upgrade the Password`_ +#. Optionally, `Trigger Password Migration From a Custom Encoder`_ + +Configure a new Encoder Using "migrate_from" +-------------------------------------------- + +When configuring a new encoder, you can specify a list of legacy encoders by +using the ``migrate_from`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + # ... + + encoders: + legacy: + algorithm: sha256 + encode_as_base64: false + iterations: 1 + + App\Entity\User: + # the new encoder, along with its options + algorithm: sodium + migrate_from: + - bcrypt # uses the "bcrypt" encoder with the default options + - legacy # uses the "legacy" encoder configured above + + .. code-block:: xml + + + + + + + + + + + + + + bcrypt + + + legacy + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + // ... + + 'encoders' => [ + 'legacy' => [ + 'algorithm' => 'sha256', + 'encode_as_base64' => false, + 'iterations' => 1, + ], + + 'App\Entity\User' => [ + // the new encoder, along with its options + 'algorithm' => 'sodium', + 'migrate_from' => [ + 'bcrypt', // uses the "bcrypt" encoder with the default options + 'legacy', // uses the "legacy" encoder configured above + ], + ], + ], + ]); + +.. tip:: + + The *auto*, *native*, *bcrypt* and *argon* encoders automatically enable + password migration using the following list of ``migrate_from`` algorithms: + + #. :ref:`PBKDF2 ` (which uses :phpfunction:`hash_pbkdf2`); + #. Message digest (which uses :phpfunction:`hash`) + + Both use the ``hash_algorithm`` setting as algorithm. It is recommended to + use ``migrate_from`` instead of ``hash_algorithm``, unless the *auto* + encoder is used. + +Upgrade the Password +-------------------- + +Upon successful login, the Security system checks whether a better algorithm +is available to hash the user's password. If it is, it'll hash the correct +password using the new hash. You can enable this behavior by implementing how +this newly hashed password should be stored: + +* `When using Doctrine's entity user provider `_ +* `When using a custom user provider `_ + +After this, you're done and passwords are always hashed as secure as possible! + +Upgrade the Password when using Doctrine +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When using the :ref:`entity user provider `, implement +:class:`Symfony\\Component\\Security\\Core\\User\\PasswordUpgraderInterface` in +the ``UserRepository`` (see `the Doctrine docs for information`_ on how to +create this class if it's not already created). This interface implements +storing the newly created password hash:: + + // src/Repository/UserRepository.php + namespace App\Repository; + + // ... + use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; + + class UserRepository extends EntityRepository implements PasswordUpgraderInterface + { + // ... + + public function upgradePassword(UserInterface $user, string $newEncodedPassword): void + { + // set the new encoded password on the User object + $user->setPassword($newEncodedPassword); + + // execute the queries on the database + $this->getEntityManager()->flush($user); + } + } + +Upgrade the Password when using a Custom User Provider +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If you're using a :ref:`custom user provider `, implement the +:class:`Symfony\\Component\\Security\\Core\\User\\PasswordUpgraderInterface` in +the user provider:: + + // src/Security/UserProvider.php + namespace App\Security; + + // ... + use Symfony\Component\Security\Core\User\PasswordUpgraderInterface; + + class UserProvider implements UserProviderInterface, PasswordUpgraderInterface + { + // ... + + public function upgradePassword(UserInterface $user, string $newEncodedPassword): void + { + // set the new encoded password on the User object + $user->setPassword($newEncodedPassword); + + // ... store the new password + } + } + +Trigger Password Migration From a Custom Encoder +------------------------------------------------ + +If you're using a custom password encoder, you can trigger the password +migration by returning ``true`` in the ``needsRehash()`` method:: + + // src/Security/UserProvider.php + namespace App\Security; + + // ... + use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; + + class CustomPasswordEncoder implements PasswordEncoderInterface + { + // ... + + public function needsRehash(string $encoded): bool + { + // check whether the current password is hash using an outdated encoder + $hashIsOutdated = ...; + + return $hashIsOutdated; + } + } + +.. _`the Doctrine docs for information`: https://www.doctrine-project.org/projects/doctrine-orm/en/current/reference/working-with-objects.html#custom-repositories From d1edbfdbf8d6551bdd485aec5376a6da2649e660 Mon Sep 17 00:00:00 2001 From: Alsciende Date: Sun, 1 Dec 2019 19:31:52 +0100 Subject: [PATCH 0020/7107] Small typo in workflow.rst Replaced `worflowRegistry` with `workflowRegistry`. --- workflow.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/workflow.rst b/workflow.rst index 3c9bb5e916a..fd55f189609 100644 --- a/workflow.rst +++ b/workflow.rst @@ -227,16 +227,16 @@ registry in the constructor:: class MyClass { - private $worflowRegistry; + private $workflowRegistry; public function __construct(Registry $workflowRegistry) { - $this->worflowRegistry = $worflowRegistry; + $this->workflowRegistry = $workflowRegistry; } public function toReview(BlogPost $blogPost) { - $workflow = $this->worflowRegistry->get($blogPost); + $workflow = $this->workflowRegistry->get($blogPost); // Update the currentState on the post try { From 1218275fb91a99f4517e72974c8fa909f8dfc133 Mon Sep 17 00:00:00 2001 From: dawidpierzchalski Date: Fri, 29 Nov 2019 13:37:12 +0100 Subject: [PATCH 0021/7107] Update impersonating_user.rst --- security/impersonating_user.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 310db3350d2..9c6d44332ce 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -102,7 +102,7 @@ over the user's roles until you find one that is a ``SwitchUserRole`` object:: use Symfony\Component\Security\Core\Security; // ... - public class SomeService + class SomeService { private $security; From 81321a47b6695ad8f86962bfe0152bc017b27b27 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 2 Dec 2019 11:33:21 +0100 Subject: [PATCH 0022/7107] add versionadded directive. refs #12741 --- service_container.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/service_container.rst b/service_container.rst index 1febe0cf8cc..28f49130585 100644 --- a/service_container.rst +++ b/service_container.rst @@ -739,6 +739,10 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type // ... }; +.. versionadded:: 4.4 + + The feature to bind tagged services was introduced in Symfony 4.4. + By putting the ``bind`` key under ``_defaults``, you can specify the value of *any* argument for *any* service defined in this file! You can bind arguments by name (e.g. ``$adminEmail``), by type (e.g. ``Psr\Log\LoggerInterface``) or both From 01e2f3586a70290ef673f10c4cbacb536c5ec53c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 2 Dec 2019 11:33:28 +0100 Subject: [PATCH 0023/7107] minor --- service_container.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service_container.rst b/service_container.rst index 28f49130585..dded8bad51d 100644 --- a/service_container.rst +++ b/service_container.rst @@ -190,8 +190,8 @@ each time you ask for it. ->defaults() ->autowire() // Automatically injects dependencies in your services. ->autoconfigure() // Automatically registers your services as commands, event subscribers, etc. - ; - + ; + // makes classes in src/ available to be used as services // this creates a service per class whose id is the fully-qualified class name $services->load('App\\', '../src/*') From 833ed5e9f2f01bbbdd20a94012c89983d79553a9 Mon Sep 17 00:00:00 2001 From: BETARI Date: Sun, 1 Dec 2019 00:06:00 +0100 Subject: [PATCH 0024/7107] Update parent_services.rst --- service_container/parent_services.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service_container/parent_services.rst b/service_container/parent_services.rst index e4bafac16b4..31fd839a807 100644 --- a/service_container/parent_services.rst +++ b/service_container/parent_services.rst @@ -39,7 +39,7 @@ Your child service classes may look like this:: // src/AppBundle/Repository/DoctrineUserRepository.php namespace AppBundle\Repository; - use AppBundle\Repository\BaseDoctrineRepository + use AppBundle\Repository\BaseDoctrineRepository; // ... class DoctrineUserRepository extends BaseDoctrineRepository @@ -50,7 +50,7 @@ Your child service classes may look like this:: // src/AppBundle/Repository/DoctrinePostRepository.php namespace AppBundle\Repository; - use AppBundle\Repository\BaseDoctrineRepository + use AppBundle\Repository\BaseDoctrineRepository; // ... class DoctrinePostRepository extends BaseDoctrineRepository From e930ea912e3b87effa489414adc78a7aa3e24fc2 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 3 Dec 2019 11:02:44 +0100 Subject: [PATCH 0025/7107] *Response::create() method is deprecated --- migration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migration.rst b/migration.rst index 89bfd5c21c1..144fe93d08d 100644 --- a/migration.rst +++ b/migration.rst @@ -433,7 +433,7 @@ which script to call and wrap the output in a response class:: { public function loadLegacyScript(string $requestPath, string $legacyScript) { - return StreamedResponse::create( + return new StreamedResponse( function () use ($requestPath, $legacyScript) { $_SERVER['PHP_SELF'] = $requestPath; $_SERVER['SCRIPT_NAME'] = $requestPath; From 627ec43dc66a6a4fc2b0b52c2fedba31e4d96d55 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Thu, 28 Nov 2019 10:50:04 +0100 Subject: [PATCH 0026/7107] Update mailer.rst --- components/mailer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/mailer.rst b/components/mailer.rst index 0ffc22d537d..f4290bed825 100644 --- a/components/mailer.rst +++ b/components/mailer.rst @@ -64,10 +64,10 @@ it: Then, use the SMTP Gmail transport:: - use Symfony\Component\Mailer\Bridge\Google\Smtp\GmailTransport; + use Symfony\Component\Mailer\Bridge\Google\Transport\GmailSmtpTransport; use Symfony\Component\Mailer\Mailer; - $transport = new GmailTransport('user', 'pass'); + $transport = new GmailSmtpTransport('user', 'pass'); $mailer = new Mailer($transport); $mailer->send($email); From 37a5f1eba6c993ecedd495ef8c1e2c69ca28c37f Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 3 Dec 2019 11:22:30 +0100 Subject: [PATCH 0027/7107] get/setThrowable --- components/http_kernel.rst | 14 +++++++++++++- event_dispatcher.rst | 2 +- reference/events.rst | 4 ++-- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/components/http_kernel.rst b/components/http_kernel.rst index 046ca09a6f6..b1c98d7cae2 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -526,10 +526,22 @@ to the exception. Each listener to this event is passed a :class:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent` object, which you can use to access the original exception via the -:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` +:method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` method. A typical listener on this event will check for a certain type of exception and create an appropriate error ``Response``. +.. versionadded:: 4.4 + + The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` and + :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setThrowable` methods + were introduced in Symfony 4.4. + +.. deprecated:: 4.4 + + The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` and + :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setException` methods + are deprecated since Symfony 4.4. + For example, to generate a 404 page, you might throw a special type of exception and then add a listener on this event that looks for this exception and creates and returns a 404 ``Response``. In fact, the HttpKernel component diff --git a/event_dispatcher.rst b/event_dispatcher.rst index c1c7d1c6f95..8df171497a5 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -35,7 +35,7 @@ The most common way to listen to an event is to register an **event listener**:: public function onKernelException(ExceptionEvent $event) { // You get the exception object from the received event - $exception = $event->getException(); + $exception = $event->getThrowable(); $message = sprintf( 'My Error says: %s with code: %s', $exception->getMessage(), diff --git a/reference/events.rst b/reference/events.rst index d6d7b669573..b7eec4d8dbd 100644 --- a/reference/events.rst +++ b/reference/events.rst @@ -239,14 +239,14 @@ sent as response:: public function onKernelException(ExceptionEvent $event) { - $exception = $event->getException(); + $exception = $event->getThrowable(); $response = new Response(); // setup the Response object based on the caught exception $event->setResponse($response); // you can alternatively set a new Exception // $exception = new \Exception('Some special exception'); - // $event->setException($exception); + // $event->setThrowable($exception); } .. note:: From f03df932f81a985fe0b675319dbc79bafbe96591 Mon Sep 17 00:00:00 2001 From: Florent Destremau Date: Sat, 30 Nov 2019 16:54:29 +0100 Subject: [PATCH 0028/7107] Added note regarding workflow "entered" event being dispatched on creation --- workflow.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/workflow.rst b/workflow.rst index fd55f189609..f3b960ba6c5 100644 --- a/workflow.rst +++ b/workflow.rst @@ -215,7 +215,7 @@ what actions are allowed on a blog post:: // See all the available transitions for the post in the current state $transitions = $workflow->getEnabledTransitions($post); - + Accessing the Workflow in a Class --------------------------------- @@ -223,21 +223,21 @@ To access workflow inside a class, use dependency injection and inject the registry in the constructor:: use Symfony\Component\Workflow\Registry; - + class MyClass { - + private $workflowRegistry; - + public function __construct(Registry $workflowRegistry) { $this->workflowRegistry = $workflowRegistry; } - + public function toReview(BlogPost $blogPost) { $workflow = $this->workflowRegistry->get($blogPost); - + // Update the currentState on the post try { $workflow->apply($post, 'to_review'); @@ -339,6 +339,11 @@ order: The leaving and entering events are triggered even for transitions that stay in same place. +.. versionadded:: 4.3 + + Following events are also dispatched when the subject enters the workflow + for the first time: ``workflow.entered`` and ``workflow.[worflow name].entered``. + Here is an example of how to enable logging for every time a "blog_publishing" workflow leaves a place:: From 9774ef214cc7d189a6bb24d66b9ed70418846b72 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 3 Dec 2019 13:27:44 +0100 Subject: [PATCH 0029/7107] Remove old versionadded directives --- components/expression_language/syntax.rst | 4 ---- components/http_kernel.rst | 12 ------------ security/password_migration.rst | 8 ++------ service_container.rst | 4 ---- workflow.rst | 5 ----- 5 files changed, 2 insertions(+), 31 deletions(-) diff --git a/components/expression_language/syntax.rst b/components/expression_language/syntax.rst index 5b7ee72ec7a..045451491f5 100644 --- a/components/expression_language/syntax.rst +++ b/components/expression_language/syntax.rst @@ -21,10 +21,6 @@ The component supports: * **null** - ``null`` * **exponential** - also known as scientific (e.g. ``1.99E+3`` or ``1e-2``) - .. versionadded:: 4.4 - - The ``exponential`` literal was introduced in Symfony 4.4. - .. caution:: A backslash (``\``) must be escaped by 4 backslashes (``\\\\``) in a string diff --git a/components/http_kernel.rst b/components/http_kernel.rst index f4b1618c62f..19f52b757ce 100644 --- a/components/http_kernel.rst +++ b/components/http_kernel.rst @@ -530,18 +530,6 @@ object, which you can use to access the original exception via the method. A typical listener on this event will check for a certain type of exception and create an appropriate error ``Response``. -.. versionadded:: 4.4 - - The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getThrowable` and - :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setThrowable` methods - were introduced in Symfony 4.4. - -.. deprecated:: 4.4 - - The :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::getException` and - :method:`Symfony\\Component\\HttpKernel\\Event\\ExceptionEvent::setException` methods - are deprecated since Symfony 4.4. - For example, to generate a 404 page, you might throw a special type of exception and then add a listener on this event that looks for this exception and creates and returns a 404 ``Response``. In fact, the HttpKernel component diff --git a/security/password_migration.rst b/security/password_migration.rst index 7ce2d08d153..d11146f6b16 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -4,10 +4,6 @@ How to Migrate a Password Hash ============================== -.. versionadded:: 4.4 - - Password migration was introduced in Symfony 4.4. - In order to protect passwords, it is recommended to store them using the latest hash algorithms. This means that if a better hash algorithm is supported on the system, the user's password should be rehashed and stored. Symfony provides this @@ -122,8 +118,8 @@ is available to hash the user's password. If it is, it'll hash the correct password using the new hash. You can enable this behavior by implementing how this newly hashed password should be stored: -* `When using Doctrine's entity user provider `_ -* `When using a custom user provider `_ +* `When using Doctrine's entity user provider `_ +* `When using a custom user provider `_ After this, you're done and passwords are always hashed as secure as possible! diff --git a/service_container.rst b/service_container.rst index dded8bad51d..6fc33e94fa7 100644 --- a/service_container.rst +++ b/service_container.rst @@ -739,10 +739,6 @@ You can also use the ``bind`` keyword to bind specific arguments by name or type // ... }; -.. versionadded:: 4.4 - - The feature to bind tagged services was introduced in Symfony 4.4. - By putting the ``bind`` key under ``_defaults``, you can specify the value of *any* argument for *any* service defined in this file! You can bind arguments by name (e.g. ``$adminEmail``), by type (e.g. ``Psr\Log\LoggerInterface``) or both diff --git a/workflow.rst b/workflow.rst index e29a4f7d14c..d1c78568879 100644 --- a/workflow.rst +++ b/workflow.rst @@ -339,11 +339,6 @@ order: The leaving and entering events are triggered even for transitions that stay in same place. -.. versionadded:: 4.3 - - Following events are also dispatched when the subject enters the workflow - for the first time: ``workflow.entered`` and ``workflow.[worflow name].entered``. - Here is an example of how to enable logging for every time a "blog_publishing" workflow leaves a place:: From 74ad03422289426833f7de9807fe07608178128e Mon Sep 17 00:00:00 2001 From: Johan Date: Tue, 3 Dec 2019 17:00:47 +0100 Subject: [PATCH 0030/7107] Update lock.rst --- components/lock.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index eb67082ba4a..7869c2e019d 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -215,7 +215,7 @@ Available Stores ---------------- Locks are created and managed in ``Stores``, which are classes that implement -:class:`Symfony\\Component\\Lock\\PersistStoreInterface` and, optionally, +:class:`Symfony\\Component\\Lock\\PersistingStoreInterface` and, optionally, :class:`Symfony\\Component\\Lock\\BlockingStoreInterface`. The component includes the following built-in store types: @@ -233,7 +233,7 @@ Store Scope Blocking Expiring .. versionadded:: 4.4 - The ``PersistStoreInterface`` and ``BlockingStoreInterface`` interfaces were + The ``PersistingStoreInterface`` and ``BlockingStoreInterface`` interfaces were introduced in Symfony 4.4. In previous versions there was only one interface called ``Symfony\Component\Lock\StoreInterface``. From b2816282b10ea6ace170f0ca80894d71c39eacfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Schl=C3=A4pfer?= Date: Tue, 3 Dec 2019 23:50:31 +0100 Subject: [PATCH 0031/7107] fix a typo in mailer docs (Mutliple -> Multiple) --- mailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index cff2d439ce8..acf196c0ebc 100644 --- a/mailer.rst +++ b/mailer.rst @@ -703,7 +703,7 @@ you have a transport called ``async``, you can route the message there: Thanks to this, instead of being delivered immediately, messages will be sent to the transport to be handled later (see :ref:`messenger-worker`). -Mutliple Email Transports +Multiple Email Transports ------------------------- .. versionadded:: 4.4 From 7361fdbf9743ffd523290389b0fe4f2744546c15 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 3 Dec 2019 12:38:51 +0100 Subject: [PATCH 0032/7107] [Form] Documented the choice_self_translation option of LanguageType --- reference/forms/types/language.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 7824120d605..d292fde172c 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -24,6 +24,7 @@ manually, but then you should just use the ``ChoiceType`` directly. | Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | +-------------+------------------------------------------------------------------------+ | Options | - `alpha3`_ | +| | - `choice_self_translation`_ | | | - `choice_translation_locale`_ | +-------------+------------------------------------------------------------------------+ | Overridden | - `choices`_ | @@ -74,6 +75,23 @@ If this option is ``true``, the choice values use the `ISO 639-2 alpha-3`_ three-letter codes (e.g. French = ``fra``) instead of the default `ISO 639-1 alpha-2`_ two-letter codes (e.g. French = ``fr``). +choice_self_translation +~~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +.. versionadded:: 5.1 + + The ``choice_self_translation`` option was introduced in Symfony 5.1. + +By default, the choice values are translated into the locale of the application. +For example, when using ``en`` as the locale, you'll get an array like +``[..., 'cs' => 'Czech', ..., 'es' => 'Spanish', ..., 'zh' => 'Chinese']``. + +If this option is ``true``, each choice value is translated into its own +language. The resulting array is the same regardless of the application locale: +``[..., 'cs' => 'čeština', ..., 'es' => 'español', ..., 'zh' => '中文']``. + .. include:: /reference/forms/types/options/choice_translation_locale.rst.inc Overridden Options From 8438276e6f4103dcd2ea64419af067a82bb71589 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 5 Dec 2019 11:14:58 +0100 Subject: [PATCH 0033/7107] Minor tweak in a security expression explanation --- security/expressions.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/expressions.rst b/security/expressions.rst index 82a2aebee31..87aa4388ab6 100644 --- a/security/expressions.rst +++ b/security/expressions.rst @@ -39,9 +39,9 @@ Inside the expression, you have access to a number of variables: ``user`` The user object (or the string ``anon`` if you're not authenticated). ``roles`` - The array of roles the user has, including from the - :ref:`role hierarchy ` but not including the - ``IS_AUTHENTICATED_*`` attributes (see the functions below). + The array of roles the user has. This array includes any roles granted + indirectly via the :ref:`role hierarchy ` but it + does not include the ``IS_AUTHENTICATED_*`` attributes (see the functions below). ``object`` The object (if any) that's passed as the second argument to ``isGranted()``. ``token`` From 6ed4809da985ffeb647a7f007a25b543a983ef7a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 5 Dec 2019 12:00:10 +0100 Subject: [PATCH 0034/7107] Explain the prefix used for expressions in YAML files --- service_container/expression_language.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/service_container/expression_language.rst b/service_container/expression_language.rst index daba69e6f26..fcf2e5e8c57 100644 --- a/service_container/expression_language.rst +++ b/service_container/expression_language.rst @@ -28,6 +28,7 @@ to another service: ``AppBundle\Mailer``. One way to do this is with an expressi AppBundle\Mail\MailerConfiguration: ~ AppBundle\Mailer: + # the '@=' prefix is required when using expressions for arguments in YAML files arguments: ["@=service('AppBundle\\\\Mail\\\\MailerConfiguration').getMailerMethod()"] .. code-block:: xml @@ -80,6 +81,7 @@ via a ``container`` variable. Here's another example: services: AppBundle\Mailer: + # the '@=' prefix is required when using expressions for arguments in YAML files arguments: ["@=container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"] .. code-block:: xml From 234c9f92de6d27c77033af2e1f48c8b348343593 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 5 Dec 2019 13:27:17 +0100 Subject: [PATCH 0035/7107] Fixed the minimum Twig version needed for lazy extensions --- templating/twig_extension.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index dc0e29f8ccb..8508091000d 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -95,9 +95,9 @@ You can now start using your filter in any Twig template. Creating Lazy-Loaded Twig Extensions ------------------------------------ -.. versionadded:: 1.26 +.. versionadded:: 1.35 - Support for lazy-loaded extensions was introduced in Twig 1.26. + Support for lazy-loaded extensions was introduced in Twig 1.35.0 and 2.4.4. Including the code of the custom filters/functions in the Twig extension class is the simplest way to create extensions. However, Twig must initialize all From 1227f8b36056bdd448ba6d46cfb0392260194160 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 6 Dec 2019 10:39:09 +0100 Subject: [PATCH 0036/7107] [Cache] Expand the docs about the cache chain --- cache.rst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/cache.rst b/cache.rst index 5de81659a5b..9912b879e93 100644 --- a/cache.rst +++ b/cache.rst @@ -397,11 +397,21 @@ and use that when configuring the pool. Creating a Cache Chain ---------------------- -Different cache adapters have different strengths and weaknesses. Some might be really -quick but small and some may be able to contain a lot of data but are quite slow. -To get the best of both worlds you may use a chain of adapters. The idea is to -first look at the quick adapter and then move on to slower adapters. In the worst -case the value needs to be recalculated. +Different cache adapters have different strengths and weaknesses. Some might be +really quick but optimized to store small items and some may be able to contain +a lot of data but are quite slow. To get the best of both worlds you may use a +chain of adapters. + +A cache chain combines several cache pools into a single one. When storing an +item in a cache chain, Symfony stores it in all pools sequentially. When +retrieving an item, Symfony tries to get it from the first pool. If it's not +found, it tries the next pools until the item is found or an exception is thrown. +Because of this behavior, it's recommended to define the adapters in the chain +in order from the fastest to the slowest. + +If an error happens when storing an item in a pool, Symfony stores it in the +other pools and no exception is thrown. Later, when the item is retrieved, +Symfony stores the item automatically in all the missing pools. .. configuration-block:: From c54caecf1feeb6636423a5d3574152aa5b389a0f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 6 Dec 2019 10:58:28 +0100 Subject: [PATCH 0037/7107] [Cache] Fixed a minor RST syntax issue --- cache.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.rst b/cache.rst index c08694cc51b..bf5454d09ae 100644 --- a/cache.rst +++ b/cache.rst @@ -518,7 +518,7 @@ the same key could be invalidate with one function call:: } } -The cache adapter needs to implement :class:`Symfony\\Contracts\\Cache\\TagAwareCacheInterface`` +The cache adapter needs to implement :class:`Symfony\\Contracts\\Cache\\TagAwareCacheInterface` to enable this feature. This could be added by using the following configuration. .. configuration-block:: From 35556da26a337428ecf9786d43de593c1b560e2a Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Fri, 6 Dec 2019 11:36:19 +0100 Subject: [PATCH 0038/7107] Update paragraph about portable command lines --- components/process.rst | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/components/process.rst b/components/process.rst index 4819c023813..9a53f06080b 100644 --- a/components/process.rst +++ b/components/process.rst @@ -112,7 +112,7 @@ Using Features From the OS Shell Using array of arguments is the recommended way to define commands. This saves you from any escaping and allows sending signals seamlessly -(e.g. to stop processes before completion):: +(e.g. to stop processes while they run):: $process = new Process(['/path/command', '--option', 'argument', 'etc.']); $process = new Process(['/path/to/php', '--define', 'memory_limit=1024M', '/path/to/script.php']); @@ -139,6 +139,21 @@ environment variables using the second argument of the ``run()``, // On both Unix-like and Windows $process->run(null, ['MESSAGE' => 'Something to output']); +To help write command lines that are independent from the operating system, +you can also write the above code as such:: + + // On both Unix-like and Windows + $process = Process::fromShellCommandline('echo "${:MESSAGE}"'); + +This requires using a syntax that is specific to the component: when enclosing +a variable name into ``"{$:`` and ``}"`` exactly, the process object will +replace it with its escaped value, or will fail if the variable is not found in +the list of environment variables attached to the command. + +.. versionadded:: 4.4 + + Portable command lines were introduced in Symfony 4.4. + Setting Environment Variables for Processes ------------------------------------------- @@ -368,27 +383,6 @@ instead:: ); $process->run(); -Using a Prepared Command Line ------------------------------ - -You can run the process by using a a prepared command line using the -double bracket notation. You can use a placeholder in order to have a -process that can only be changed with the values and without changing -the PHP code:: - - use Symfony\Component\Process\Process; - - $process = Process::fromShellCommandline('echo "$name"'); - $process->run(null, ['name' => 'Elsa']); - -.. caution:: - - A prepared command line will not be escaped automatically! - -.. versionadded:: 4.4 - - Prepared command lines were introduced in Symfony 4.4. - Process Timeout --------------- From 00d045cd452adab659825d7a6b469eb578f04d83 Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Thu, 5 Dec 2019 19:25:28 +0300 Subject: [PATCH 0039/7107] Update messenger.rst --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 30abf07b135..5cc5bbdd4e1 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1310,7 +1310,7 @@ middleware and *only* include your own: buses: messenger.bus.default: middleware: - # service ids that implement Symfony\Component\Messenger\Middleware + # service ids that implement Symfony\Component\Messenger\Middleware\MiddlewareInterface - 'App\Middleware\MyMiddleware' - 'App\Middleware\AnotherMiddleware' From 72e8bb9723260a2355588cf11136854b024857f4 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 8 Dec 2019 13:54:31 +0100 Subject: [PATCH 0040/7107] Fixed DOCtor whitelist --- .doctor-rst.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index caebab386db..efc63dba577 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -60,8 +60,8 @@ whitelist: - '.. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection' - '.. versionadded:: 0.21.0' # Encore - '.. versionadded:: 2.4.0' # SwiftMailer - - '.. versionadded:: 1.26' # Twig - '.. versionadded:: 1.30' # Twig + - '.. versionadded:: 1.35' # Twig - '.. versionadded:: 1.2' # MakerBundle - '.. versionadded:: 1.11' # MakerBundle - '.. versionadded:: 1.3' # MakerBundle From 58928695d45f3da52346a7ba201a70e9b044ffb8 Mon Sep 17 00:00:00 2001 From: Abdouni Abdelkarim Date: Thu, 5 Dec 2019 11:00:48 +0100 Subject: [PATCH 0041/7107] Update setup.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello, I just updated the files to link to Symfony releases instead of Symfony Roadmap. Cheers 😉 --- setup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.rst b/setup.rst index f9585b1eb6a..32be370c945 100644 --- a/setup.rst +++ b/setup.rst @@ -230,7 +230,7 @@ Symfony LTS Versions According to the :doc:`Symfony release process `, "long-term support" (or LTS for short) versions are published every two years. -Check out the `Symfony roadmap`_ to know which is the latest LTS version. +Check out the `Symfony releases`_ to know which is the latest LTS version. By default, the command that creates new Symfony applications uses the latest stable version. If you want to use an LTS version, add the ``--version`` option: @@ -284,7 +284,7 @@ Learn More .. _`The Symfony Demo Application`: https://github.com/symfony/demo .. _`Symfony Flex`: https://github.com/symfony/flex .. _`PHP security advisories database`: https://github.com/FriendsOfPHP/security-advisories -.. _`Symfony roadmap`: https://symfony.com/roadmap +.. _`Symfony releases`: https://symfony.com/releases .. _`Main recipe repository`: https://github.com/symfony/recipes .. _`Contrib recipe repository`: https://github.com/symfony/recipes-contrib .. _`Symfony Recipes documentation`: https://github.com/symfony/recipes/blob/master/README.rst From 2ad6aaa543c9f9f2f329ca51f216dfc9bc1ea2f0 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 8 Dec 2019 13:59:22 +0100 Subject: [PATCH 0042/7107] Removed 4.4 versionadded from the 4.3 docs --- components/cache/adapters/redis_adapter.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index 53b28c58466..608fd8e44d2 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -106,10 +106,6 @@ name of your service group:: The option to define multiple servers in a single DSN was introduced in Symfony 4.2. -.. versionadded:: 4.4 - - Redis Sentinel support was introduced in Symfony 4.4. - .. note:: See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options From 3c6c7a3648c11720726c3b439c25c20370f58c4f Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 8 Dec 2019 13:59:39 +0100 Subject: [PATCH 0043/7107] Revert "Removed 4.4 versionadded from the 4.3 docs" This reverts commit 2ad6aaa543c9f9f2f329ca51f216dfc9bc1ea2f0. --- components/cache/adapters/redis_adapter.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index 608fd8e44d2..53b28c58466 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -106,6 +106,10 @@ name of your service group:: The option to define multiple servers in a single DSN was introduced in Symfony 4.2. +.. versionadded:: 4.4 + + Redis Sentinel support was introduced in Symfony 4.4. + .. note:: See the :class:`Symfony\\Component\\Cache\\Traits\\RedisTrait` for more options From 6784ec42d6711d15598d52064fa4b06b540e287c Mon Sep 17 00:00:00 2001 From: Johny Date: Sun, 8 Dec 2019 21:28:36 +0100 Subject: [PATCH 0044/7107] ListenerInterface deprecated since Symfony 4.3 Symfony\Component\Security\Http\Firewall deprecation comment: @deprecated since Symfony 4.3, turn listeners into callables instead Targeting 4.3 branch as per @OskarStark comment in original PR https://github.com/symfony/symfony-docs/pull/12780#issuecomment-562987989 --- security/custom_authentication_provider.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 1a0a78bf226..1edc00c5228 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -97,8 +97,7 @@ The Listener Next, you need a listener to listen on the firewall. The listener is responsible for fielding requests to the firewall and calling the authentication -provider. A listener must be an instance of -:class:`Symfony\\Component\\Security\\Http\\Firewall\\ListenerInterface`. +provider. Listener is a callable, so you have to implement __invoke() method. A security listener should handle the :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent` event, and set an authenticated token in the token storage if successful:: @@ -112,9 +111,8 @@ set an authenticated token in the token storage if successful:: use Symfony\Component\Security\Core\Authentication\AuthenticationManagerInterface; use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; - use Symfony\Component\Security\Http\Firewall\ListenerInterface; - class WsseListener implements ListenerInterface + class WsseListener { protected $tokenStorage; protected $authenticationManager; @@ -125,7 +123,7 @@ set an authenticated token in the token storage if successful:: $this->authenticationManager = $authenticationManager; } - public function handle(RequestEvent $event) + public function __invoke(RequestEvent $event) { $request = $event->getRequest(); From 1ca59e0741f60da36d0aae6f2f700c2fefefc510 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 12:26:35 +0100 Subject: [PATCH 0045/7107] Updated a link to Debug component --- components/phpunit_bridge.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 01b2583e17e..b2b6a1fac47 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -311,8 +311,9 @@ Deprecation Notices at Autoloading Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, the PHPUnit Bridge uses ``DebugClassLoader`` from the -`Debug component`_ to throw deprecation notices at class autoloading time. -This can be disabled with the ``debug-class-loader`` option. +:doc:`ErrorHandler component `_ to throw deprecation +notices at class autoloading time. This can be disabled with the +``debug-class-loader`` option. .. code-block:: xml @@ -978,4 +979,3 @@ not find the SUT: .. _`test listener`: https://phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.test-listeners .. _`@covers`: https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.covers .. _`PHP namespace resolutions rules`: https://php.net/manual/en/language.namespaces.rules.php -.. _Debug component: https://github.com/symfony/debug From 6d661f0a7d4b50d116cdc298a926cd413716bf7f Mon Sep 17 00:00:00 2001 From: Michael Schouman Date: Mon, 25 Nov 2019 13:52:55 +0100 Subject: [PATCH 0046/7107] Updated the location of the errors.xml file --- controller/error_pages.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index b1a6e2d3992..706765f56be 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -157,30 +157,30 @@ automatically when installing Twig support): .. code-block:: yaml - # config/routes/dev/twig.yaml + # config/routes/dev/framework.yaml _errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' prefix: /_error .. code-block:: xml - + - + .. code-block:: php - // config/routes/dev/twig.php + // config/routes/dev/framework.php use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { - $routes->import('@TwigBundle/Resources/config/routing/errors.xml') + $routes->import('@FrameworkBundle/Resources/config/routing/errors.xml') ->prefix('/_error') ; }; From 4c867f9b5556631aa618006fe51c7fc1113439f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20Brekelmans?= Date: Sun, 24 Nov 2019 15:33:36 +0100 Subject: [PATCH 0047/7107] Fix 12273 Added new ErrorController --- controller/error_pages.rst | 151 ++++++++++++++------------ reference/configuration/framework.rst | 18 +++ reference/configuration/twig.rst | 6 + 3 files changed, 108 insertions(+), 67 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 482ba6edd95..3d8b3a33ef6 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -9,14 +9,6 @@ In Symfony applications, all errors are treated as exceptions, no matter if they are just a 404 Not Found error or a fatal error triggered by throwing some exception in your code. -If your app has the `TwigBundle`_ installed, a special controller handles these -exceptions. This controller displays debug information for errors and allows to -customize error pages, so run this command to make sure the bundle is installed: - -.. code-block:: terminal - - $ composer require twig - In the :ref:`development environment `, Symfony catches all the exceptions and displays a special **exception page** with lots of debug information to help you discover the root problem: @@ -39,37 +31,42 @@ Error pages for the production environment can be customized in different ways depending on your needs: #. If you just want to change the contents and styles of the error pages to match - the rest of your application, :ref:`override the default error templates `; + the rest of your application, :ref:`override the default error templates `; + +#. If you want to change the contents of non-HTML error output, :ref:`create a new normalizer `; #. If you also want to tweak the logic used by Symfony to generate error pages, - :ref:`override the default exception controller `; + :ref:`override the default error controller `; #. If you need total control of exception handling to execute your own logic :ref:`use the kernel.exception event `. -.. _use-default-exception-controller: -.. _using-the-default-exceptioncontroller: +.. _use-default-error-controller: +.. _using-the-default-errorcontroller: Overriding the Default Error Templates -------------------------------------- -When the error page loads, an internal :class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController` +You can use the built-in Twig error renderer to easily override the default error templates. +Both the TwigBundle and TwigBridge need to be installed for this. +Run this command to ensure both are installed: + +.. code-block:: terminal + + $ composer require twig + +When the error page loads, :class:`Symfony\\Bridge\\Twig\\ErrorRenderer\\TwigErrorRenderer` is used to render a Twig template to show the user. .. _controller-error-pages-by-status-code: -This controller uses the HTTP status code, the request format and the following +This renderer uses the HTTP status code and the following logic to determine the template filename: -#. Look for a template for the given format and status code (like ``error404.json.twig`` - or ``error500.html.twig``); +#. Look for a template for the given status code (like ``error500.html.twig``); #. If the previous template doesn't exist, discard the status code and look for - a generic template for the given format (like ``error.json.twig`` or - ``error.xml.twig``); - -#. If none of the previous templates exist, fall back to the generic HTML template - (``error.html.twig``). + a generic error template (``error.html.twig``). .. _overriding-or-adding-templates: @@ -77,7 +74,7 @@ To override these templates, rely on the standard Symfony method for :ref:`overriding templates that live inside a bundle ` and put them in the ``templates/bundles/TwigBundle/Exception/`` directory. -A typical project that returns HTML and JSON pages might look like this: +A typical project that returns HTML pages might look like this: .. code-block:: text @@ -87,10 +84,7 @@ A typical project that returns HTML and JSON pages might look like this: └─ Exception/ ├─ error404.html.twig ├─ error403.html.twig - ├─ error.html.twig # All other HTML errors (including 500) - ├─ error404.json.twig - ├─ error403.json.twig - └─ error.json.twig # All other JSON errors (including 500) + └─ error.html.twig # All other HTML errors (including 500) Example 404 Error Template -------------------------- @@ -112,24 +106,17 @@ To override the 404 error template for HTML pages, create a new

{% endblock %} -In case you need them, the ``ExceptionController`` passes some information to +In case you need them, the ``TwigErrorRenderer`` passes some information to the error template via the ``status_code`` and ``status_text`` variables that store the HTTP status code and message respectively. .. tip:: - You can customize the status code by implementing + You can customize the status code of an exception by implementing :class:`Symfony\\Component\\HttpKernel\\Exception\\HttpExceptionInterface` and its required ``getStatusCode()`` method. Otherwise, the ``status_code`` will default to ``500``. -.. note:: - - The exception pages shown in the development environment can be customized - in the same way as error pages. Create a new ``exception.html.twig`` template - for the standard HTML exception page or ``exception.json.twig`` for the JSON - exception page. - Security & 404 Pages -------------------- @@ -146,41 +133,41 @@ While you're in the development environment, Symfony shows the big *exception* page instead of your shiny new customized error page. So, how can you see what it looks like and debug it? -Fortunately, the default ``ExceptionController`` allows you to preview your +Fortunately, the default ``ErrorController`` allows you to preview your *error* pages during development. -To use this feature, you need to load some special routes provided by TwigBundle +To use this feature, you need to load some special routes provided by FrameworkBundle (if the application uses :ref:`Symfony Flex ` they are loaded -automatically when installing Twig support): +automatically when installing ``symfony/framework-bundle``): .. configuration-block:: .. code-block:: yaml - # config/routes/dev/twig.yaml + # config/routes/dev/framework.yaml _errors: - resource: '@TwigBundle/Resources/config/routing/errors.xml' + resource: '@FrameworkBundle/Resources/config/routing/errors.xml' prefix: /_error .. code-block:: xml - + - + .. code-block:: php - // config/routes/dev/twig.php + // config/routes/dev/framework.php use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { - $routes->import('@TwigBundle/Resources/config/routing/errors.xml') + $routes->import('@FrameworkBundle/Resources/config/routing/errors.xml') ->prefix('/_error') ; }; @@ -193,61 +180,93 @@ for a given status code as HTML or for a given status code and format. http://localhost/index.php/_error/{statusCode} http://localhost/index.php/_error/{statusCode}.{format} -.. _custom-exception-controller: -.. _replacing-the-default-exceptioncontroller: +.. _overriding-non-html-error-output: + +Overriding Error output for non-HTML formats +-------------------------------------------- -Overriding the Default ExceptionController ------------------------------------------- +To override non-HTML error output, the Serializer component needs to be installed. + +.. code-block:: terminal + + $ composer require serializer + +The Serializer component has a built-in ``FlattenException`` normalizer (``ProblemNormalizer``) and JSON/XML/CSV/YAML +encoders by default. That means that if an exception were to be thrown in your application, Symfony can output it in +a format supported by one of the encoders. If you want to change how the output is structured, all you have to do +is create a new Normalizer that supports the ``FlattenException`` input:: + + class MyCustomProblemNormalizer implements NormalizerInterface + { + public function normalize($exception, $format = null, array $context = []) + { + return [ + 'content': 'This is my custom problem normalizer.', + 'exception': [ + 'message': $exception->getMessage(), + 'code': $exception->getStatusCode(), + ], + ]; + } + + public function supportsNormalization($data, $format = null) + { + return $data instanceof FlattenException; + } + } + +.. _custom-error-controller: +.. _replacing-the-default-errorcontroller: + +Overriding the Default ErrorController +-------------------------------------- If you need a little more flexibility beyond just overriding the template, then you can change the controller that renders the error page. For example, you might need to pass some additional variables into your template. To do this, create a new controller anywhere in your application and set -the :ref:`twig.exception_controller ` +the :ref:`framework.error_controller ` configuration option to point to it: .. configuration-block:: .. code-block:: yaml - # config/packages/twig.yaml - twig: - exception_controller: App\Controller\ExceptionController::showAction + # config/packages/framework.yaml + framework: + error_controller: App\Controller\ErrorController::showAction .. code-block:: xml - + + https://symfony.com/schema/dic/services/services-1.0.xsd"> - - App\Controller\ExceptionController::showAction - + + App\Controller\ErrorController::showAction + .. code-block:: php // config/packages/twig.php - $container->loadFromExtension('twig', [ - 'exception_controller' => 'App\Controller\ExceptionController::showAction', + $container->loadFromExtension('framework', [ + 'error_controller' => 'App\Controller\ErrorController::showAction', // ... ]); -The :class:`Symfony\\Component\\HttpKernel\\EventListener\\ExceptionListener` -class used by the TwigBundle as a listener of the ``kernel.exception`` event creates +The :class:`Symfony\\Component\\HttpKernel\\EventListener\\ErrorListener` +class used by the FrameworkBundle as a listener of the ``kernel.exception`` event creates the request that will be dispatched to your controller. In addition, your controller will be passed two parameters: ``exception`` - A :class:`\\Symfony\\Component\\ErrorRenderer\\Exception\\FlattenException` + A :class:`\\Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` instance created from the exception being handled. ``logger`` @@ -355,5 +374,3 @@ time and again, you can have just one (or several) listeners deal with them. your application (like :class:`Symfony\\Component\\Security\\Core\\Exception\\AccessDeniedException`) and takes measures like redirecting the user to the login page, logging them out and other things. - -.. _`TwigBundle`: https://github.com/symfony/twig-bundle diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index d0cfd613590..d100d1b7b62 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -74,6 +74,7 @@ Configuration * `default_locale`_ * `disallow_search_engine_index`_ +* `error_controller`_ * `esi`_ * :ref:`enabled ` @@ -596,6 +597,23 @@ If you're using forms, but want to avoid starting your session (e.g. using forms in an API-only website), ``csrf_protection`` will need to be set to ``false``. +.. _config-framework-error_controller: + +error_controller +~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``error_controller`` + +.. versionadded:: 4.4 + + The ``error_controller`` option was introduced in Symfony 4.4. + +This is the controller that is activated after an exception is thrown anywhere +in your application. The default controller +(:class:`Symfony\\Component\\HttpKernel\\Controller\\ErrorController`) +is what's responsible for rendering specific templates under different error +conditions (see :doc:`/controller/error_pages`). + esi ~~~ diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 147a8a9b145..7c6add6ca60 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -203,6 +203,12 @@ exception_controller **type**: ``string`` **default**: ``twig.controller.exception:showAction`` +.. deprecated:: 4.4 + + The ``exception_controller`` configuration option was deprecated in Symfony 4.4. + Set it to ``null`` and use the new ``error_controller`` option under ``framework`` + configuration instead. + This is the controller that is activated after an exception is thrown anywhere in your application. The default controller (:class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`) From b243534a8d2f71fa6787da5c433b0d3fc443ec8b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 12:59:50 +0100 Subject: [PATCH 0048/7107] Minor tweaks --- controller/error_pages.rst | 21 +++++++++++++-------- reference/configuration/framework.rst | 8 ++++---- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 3d8b3a33ef6..471bb55d4f6 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -33,7 +33,8 @@ depending on your needs: #. If you just want to change the contents and styles of the error pages to match the rest of your application, :ref:`override the default error templates `; -#. If you want to change the contents of non-HTML error output, :ref:`create a new normalizer `; +#. If you want to change the contents of non-HTML error output, + :ref:`create a new normalizer `; #. If you also want to tweak the logic used by Symfony to generate error pages, :ref:`override the default error controller `; @@ -47,9 +48,9 @@ depending on your needs: Overriding the Default Error Templates -------------------------------------- -You can use the built-in Twig error renderer to easily override the default error templates. -Both the TwigBundle and TwigBridge need to be installed for this. -Run this command to ensure both are installed: +You can use the built-in Twig error renderer to override the default error +templates. Both the TwigBundle and TwigBridge need to be installed for this. Run +this command to ensure both are installed: .. code-block:: terminal @@ -191,10 +192,14 @@ To override non-HTML error output, the Serializer component needs to be installe $ composer require serializer -The Serializer component has a built-in ``FlattenException`` normalizer (``ProblemNormalizer``) and JSON/XML/CSV/YAML -encoders by default. That means that if an exception were to be thrown in your application, Symfony can output it in -a format supported by one of the encoders. If you want to change how the output is structured, all you have to do -is create a new Normalizer that supports the ``FlattenException`` input:: +The Serializer component has a built-in ``FlattenException`` normalizer +(``ProblemNormalizer``) and JSON/XML/CSV/YAML encoders. When your application +throws an exception, Symfony can output it in one of those formats. If you want +to change the output contents, create a new Normalizer that supports the +``FlattenException`` input:: + + # src/App/Serializer/MyCustomProblemNormalizer.php + namespace App\Serializer; class MyCustomProblemNormalizer implements NormalizerInterface { diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index d100d1b7b62..2fd84702e30 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -608,11 +608,11 @@ error_controller The ``error_controller`` option was introduced in Symfony 4.4. -This is the controller that is activated after an exception is thrown anywhere -in your application. The default controller +This is the controller that is called when an exception is thrown anywhere in +your application. The default controller (:class:`Symfony\\Component\\HttpKernel\\Controller\\ErrorController`) -is what's responsible for rendering specific templates under different error -conditions (see :doc:`/controller/error_pages`). +renders specific templates under different error conditions (see +:doc:`/controller/error_pages`). esi ~~~ From e7094c10db721ba6aa7529ac64373be9d4195d9a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 13:01:31 +0100 Subject: [PATCH 0049/7107] Removed 4.4 versionadded and deprecations --- reference/configuration/framework.rst | 4 ---- reference/configuration/twig.rst | 24 ------------------------ 2 files changed, 28 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 6a446439556..a17a02a8c81 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -589,10 +589,6 @@ error_controller **type**: ``string`` **default**: ``error_controller`` -.. versionadded:: 4.4 - - The ``error_controller`` option was introduced in Symfony 4.4. - This is the controller that is called when an exception is thrown anywhere in your application. The default controller (:class:`Symfony\\Component\\HttpKernel\\Controller\\ErrorController`) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 7c6add6ca60..7f83f0929a8 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -42,7 +42,6 @@ Configuration * `debug`_ * `default_path`_ -* `exception_controller`_ * `form_themes`_ * `globals`_ * `number_format`_ @@ -196,29 +195,6 @@ The path to the directory where Symfony will look for the application Twig templates by default. If you store the templates in more than one directory, use the :ref:`paths ` option too. -.. _config-twig-exception-controller: - -exception_controller -~~~~~~~~~~~~~~~~~~~~ - -**type**: ``string`` **default**: ``twig.controller.exception:showAction`` - -.. deprecated:: 4.4 - - The ``exception_controller`` configuration option was deprecated in Symfony 4.4. - Set it to ``null`` and use the new ``error_controller`` option under ``framework`` - configuration instead. - -This is the controller that is activated after an exception is thrown anywhere -in your application. The default controller -(:class:`Symfony\\Bundle\\TwigBundle\\Controller\\ExceptionController`) -is what's responsible for rendering specific templates under different error -conditions (see :doc:`/controller/error_pages`). Modifying this -option is advanced. If you need to customize an error page you should use -the previous link. If you need to perform some behavior on an exception, -you should add an :doc:`event listener ` to the -:ref:`kernel.exception event `. - .. _config-twig-form-themes: form_themes From de045d7d56b4c84d4646f09611c7644906da385b Mon Sep 17 00:00:00 2001 From: Yann Klis Date: Fri, 6 Dec 2019 13:57:43 +0100 Subject: [PATCH 0050/7107] Scalingo is another PaaS which supports Symfony --- deployment.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/deployment.rst b/deployment.rst index b0ab569c87f..fcac0960cb4 100644 --- a/deployment.rst +++ b/deployment.rst @@ -72,6 +72,7 @@ app quickly. There are many PaaS - below are a few that work well with Symfony: * `Azure`_ * `fortrabbit`_ * `Clever Cloud`_ +* `Scalingo`_ Using Build Scripts and other Tools ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -254,3 +255,4 @@ Learn More .. _`EasyDeployBundle`: https://github.com/EasyCorp/easy-deploy-bundle .. _`Clever Cloud`: https://www.clever-cloud.com/doc/php/tutorial-symfony/ .. _`Symfony Cloud`: https://symfony.com/doc/master/cloud/intro.html +.. _`Scalingo`: https://doc.scalingo.com/languages/php/symfony From c1f4174a552875810dbc4704ca2e3f5fea28eb6c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 5 Dec 2019 09:31:49 +0100 Subject: [PATCH 0051/7107] Mentioned the PHP 7.4 class preloading --- performance.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/performance.rst b/performance.rst index fdf181839c9..893ba7877ba 100644 --- a/performance.rst +++ b/performance.rst @@ -17,6 +17,7 @@ Production Server Checklist --------------------------- #. :ref:`Use the OPcache byte code cache ` +#. :ref:`Use the OPcache class preloading ` #. :ref:`Configure OPcache for maximum performance ` #. :ref:`Don't check PHP files timestamps ` #. :ref:`Configure the PHP realpath Cache ` @@ -42,6 +43,28 @@ every request. There are some `byte code caches`_ available, but as of PHP 5.5, PHP comes with `OPcache`_ built-in. For older versions, the most widely used byte code cache is `APC`_. +.. _performance-use-preloading: + +Use the OPcache class preloading +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 4.4 + + The feature that generates the preloading file was introduced in Symfony 4.4. + +Starting from PHP 7.4, OPcache can compile and load classes at start-up and +make them available to all requests until the server is restarted, improving +performance significantly. + +Symfony generates the file automatically with the list of classes to preload. +The file path is the same as the file generated for the service container but +with the ``preload`` suffix: + +.. code-block:: ini + + ; php.ini + opcache.preload=/path/to/project/var/cache/prod/App_KernelProdContainer.preload.php + .. _performance-configure-opcache: Configure OPcache for Maximum Performance From 3777c9264e5a702edb703b8d21effd9c64bcdfcc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 13:25:44 +0100 Subject: [PATCH 0052/7107] Removed the versionadded directive --- performance.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/performance.rst b/performance.rst index 893ba7877ba..eb15d40579b 100644 --- a/performance.rst +++ b/performance.rst @@ -48,10 +48,6 @@ used byte code cache is `APC`_. Use the OPcache class preloading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The feature that generates the preloading file was introduced in Symfony 4.4. - Starting from PHP 7.4, OPcache can compile and load classes at start-up and make them available to all requests until the server is restarted, improving performance significantly. From 286a980bcd8037189d8bf1e951d22fc8f6bf8e75 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 9 Dec 2019 13:49:46 +0100 Subject: [PATCH 0053/7107] Fix highlighting. Refs #12781 --- security/custom_authentication_provider.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 1edc00c5228..24856c151ee 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -97,7 +97,7 @@ The Listener Next, you need a listener to listen on the firewall. The listener is responsible for fielding requests to the firewall and calling the authentication -provider. Listener is a callable, so you have to implement __invoke() method. +provider. Listener is a callable, so you have to implement an ``__invoke()`` method. A security listener should handle the :class:`Symfony\\Component\\HttpKernel\\Event\\RequestEvent` event, and set an authenticated token in the token storage if successful:: From e0f0908d6367f4619841c777e277de8e8f5d7cfc Mon Sep 17 00:00:00 2001 From: Robert Saylor Date: Wed, 4 Dec 2019 14:17:21 -0500 Subject: [PATCH 0054/7107] Update setup.rst --- setup.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/setup.rst b/setup.rst index 32be370c945..4dbe8215608 100644 --- a/setup.rst +++ b/setup.rst @@ -61,6 +61,10 @@ commands to create the new Symfony application using Composer: # run this if you are building a microservice, console application or API $ composer create-project symfony/skeleton my_project_name + + # to specify the version of Symfony to install + $ composer create-project symfony/website-skeleton:^4.x my_project_name + Replace 4.x with the version. IE: 4.4 No matter which command you run to create the Symfony application. All of them will create a new ``my_project_name/`` directory, download some dependencies From 2c94fdc44cc4609dd6cc287cfa1240dd27cf0aa1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 15:14:20 +0100 Subject: [PATCH 0055/7107] Tweaked the previous merge --- setup.rst | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index 4dbe8215608..f3a1203f1a8 100644 --- a/setup.rst +++ b/setup.rst @@ -61,10 +61,6 @@ commands to create the new Symfony application using Composer: # run this if you are building a microservice, console application or API $ composer create-project symfony/skeleton my_project_name - - # to specify the version of Symfony to install - $ composer create-project symfony/website-skeleton:^4.x my_project_name - Replace 4.x with the version. IE: 4.4 No matter which command you run to create the Symfony application. All of them will create a new ``my_project_name/`` directory, download some dependencies @@ -247,6 +243,16 @@ stable version. If you want to use an LTS version, add the ``--version`` option: # use the 'next' Symfony version to be released (still in development) $ symfony new my_project_name --version=next + # you can also select an exact specific Symfony version + $ symfony new my_project_name --version=4.4 + +The ``lts`` and ``next`` shortcuts are only available when using Symfony to +create new projects. If you use Composer, you need to tell the exact version: + +.. code-block:: terminal + + $ composer create-project symfony/website-skeleton:^4.4 my_project_name + The Symfony Demo application ---------------------------- From 0942165484dc54cb7a1f4a67899af6c8bb15c02e Mon Sep 17 00:00:00 2001 From: gary houbre Date: Wed, 4 Dec 2019 19:36:03 +0100 Subject: [PATCH 0056/7107] added minor review of example code --- service_container.rst | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/service_container.rst b/service_container.rst index 44b2d1ee4db..63c8e7b0bc9 100644 --- a/service_container.rst +++ b/service_container.rst @@ -29,20 +29,24 @@ you can "ask" for a service from the container by type-hinting an argument with service's class or interface name. Want to :doc:`log ` something? No problem:: // src/Controller/ProductController.php - // ... + namespace App\Controller; use Psr\Log\LoggerInterface; - /** - * @Route("/products") - */ - public function list(LoggerInterface $logger) + class ProductController { - $logger->info('Look! I just used a service'); + /** + * @Route("/products") + */ + public function list(LoggerInterface $logger) + { + $logger->info('Look! I just used a service'); - // ... + // ... + } } + What other services are available? Find out by running: .. code-block:: terminal @@ -222,7 +226,7 @@ the ``LoggerInterface`` type-hint. Set this on a new ``$logger`` property and use it later:: // src/Service/MessageGenerator.php - // ... + namespace App\Service; use Psr\Log\LoggerInterface; @@ -550,7 +554,7 @@ Choose a Specific Service The ``MessageGenerator`` service created earlier requires a ``LoggerInterface`` argument:: // src/Service/MessageGenerator.php - // ... + namespace App\Service; use Psr\Log\LoggerInterface; From e2d1c06672b45ba42b9861100bfb63d4db72a3af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Samson?= Date: Tue, 26 Nov 2019 16:45:08 +0100 Subject: [PATCH 0057/7107] Update console.rst Since Symfony 5.0, we have an error if we don't return an int on the `execute` function, I added it in the doc so there will not be an `TypeError` when trying this. --- console.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/console.rst b/console.rst index 2a201b84e03..a92553de3c5 100644 --- a/console.rst +++ b/console.rst @@ -146,6 +146,8 @@ the console:: // outputs a message without adding a "\n" at the end of the line $output->write('You are about to '); $output->write('create a user.'); + + return 0; } Now, try executing the command: @@ -195,6 +197,8 @@ which returns an instance of // (this example deletes the last two lines of the section) $section1->clear(2); // Output is now completely empty! + + return 0; } } @@ -235,6 +239,8 @@ Use input options or arguments to pass information to the command:: // retrieve the argument value using getArgument() $output->writeln('Username: '.$input->getArgument('username')); + + return 0; } Now, you can pass the username to the command: @@ -284,6 +290,8 @@ as a service, you can use normal dependency injection. Imagine you have a $this->userManager->create($input->getArgument('username')); $output->writeln('User successfully generated!'); + + return 0; } } From 49f341f265359a86edc65b7b3154d1b86c114385 Mon Sep 17 00:00:00 2001 From: Robert Slootjes Date: Fri, 29 Nov 2019 15:49:25 +0100 Subject: [PATCH 0058/7107] Add mandatory exit status Modified all execute() functions and added a note with the new requirement which links to an explanation of exit statuses. --- console.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/console.rst b/console.rst index a92553de3c5..2110e179625 100644 --- a/console.rst +++ b/console.rst @@ -46,6 +46,8 @@ want a command to create a user:: protected function execute(InputInterface $input, OutputInterface $output) { // ... + + return 0; } } @@ -316,6 +318,7 @@ command: :method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)* This method is executed after ``interact()`` and ``initialize()``. It contains the logic you want the command to execute. + Must return an integer which will be used as the command `exit status`_. .. _console-testing-commands: @@ -395,3 +398,5 @@ tools capable of helping you with different tasks: * :doc:`/components/console/helpers/formatterhelper`: customize the output colorization * :doc:`/components/console/helpers/progressbar`: shows a progress bar * :doc:`/components/console/helpers/table`: displays tabular data as a table + +.. _`exit status`: https://en.wikipedia.org/wiki/Exit_status From f65a4edfb6586971124e2873e01c783773cf579a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 15:35:23 +0100 Subject: [PATCH 0059/7107] Tweaks --- console.rst | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/console.rst b/console.rst index 2110e179625..3b38de76cff 100644 --- a/console.rst +++ b/console.rst @@ -46,7 +46,7 @@ want a command to create a user:: protected function execute(InputInterface $input, OutputInterface $output) { // ... - + return 0; } } @@ -148,7 +148,7 @@ the console:: // outputs a message without adding a "\n" at the end of the line $output->write('You are about to '); $output->write('create a user.'); - + return 0; } @@ -199,7 +199,7 @@ which returns an instance of // (this example deletes the last two lines of the section) $section1->clear(2); // Output is now completely empty! - + return 0; } } @@ -241,7 +241,7 @@ Use input options or arguments to pass information to the command:: // retrieve the argument value using getArgument() $output->writeln('Username: '.$input->getArgument('username')); - + return 0; } @@ -292,7 +292,7 @@ as a service, you can use normal dependency injection. Imagine you have a $this->userManager->create($input->getArgument('username')); $output->writeln('User successfully generated!'); - + return 0; } } @@ -317,8 +317,13 @@ command: :method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)* This method is executed after ``interact()`` and ``initialize()``. - It contains the logic you want the command to execute. - Must return an integer which will be used as the command `exit status`_. + It contains the logic you want the command to execute and it should + return an integer which will be used as the command `exit status`_. + + .. deprecated:: 4.4 + + Not returning an integer with the exit status as the result of + ``execute()`` is deprecated since Symfony 4.4. .. _console-testing-commands: From ad75aa9ec07c5b362cb9a6660c23175c0619af3b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 15:36:09 +0100 Subject: [PATCH 0060/7107] Removed the deprecated note --- console.rst | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/console.rst b/console.rst index 3b38de76cff..a83b6139206 100644 --- a/console.rst +++ b/console.rst @@ -317,14 +317,9 @@ command: :method:`Symfony\\Component\\Console\\Command\\Command::execute` *(required)* This method is executed after ``interact()`` and ``initialize()``. - It contains the logic you want the command to execute and it should + It contains the logic you want the command to execute and it must return an integer which will be used as the command `exit status`_. - .. deprecated:: 4.4 - - Not returning an integer with the exit status as the result of - ``execute()`` is deprecated since Symfony 4.4. - .. _console-testing-commands: Testing Commands From 3938b0a30c082173ca96045d4a813ebcf191e3dd Mon Sep 17 00:00:00 2001 From: Kyle Date: Sat, 30 Nov 2019 13:00:09 +0100 Subject: [PATCH 0061/7107] Mention twig/extensions is not for Twig 3 As twig/extensions is obsolete according to: https://github.com/twigphp/Twig-extensions/pull/258 And not compatible with Twig 3, let prevent developers for running a dead end command. --- templating/twig_extension.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index 068acee63b5..74e80fd8497 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -11,7 +11,8 @@ Before writing your own Twig extension, check if the filter/function that you need is already implemented in the `default Twig filters and functions`_ or the :doc:`Twig filters and functions added by Symfony `. Check also the `official Twig extensions`_, which add commonly needed filters -and functions and can be installed in your application as follows: +and functions and can be installed in your application as follows (only needed +if you're using Twig 1 or 2): .. code-block:: terminal From 700db0a2c87a3eddcba417cbc1d012d906b7a438 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 16:00:36 +0100 Subject: [PATCH 0062/7107] Tweak --- templating/twig_extension.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templating/twig_extension.rst b/templating/twig_extension.rst index 74e80fd8497..c92f0c35707 100644 --- a/templating/twig_extension.rst +++ b/templating/twig_extension.rst @@ -10,9 +10,9 @@ use them in your templates. Before writing your own Twig extension, check if the filter/function that you need is already implemented in the `default Twig filters and functions`_ or the :doc:`Twig filters and functions added by Symfony `. -Check also the `official Twig extensions`_, which add commonly needed filters -and functions and can be installed in your application as follows (only needed -if you're using Twig 1 or 2): +Check also the `official Twig GitHub organization`_, which contains some extra +repositories that provide extensions for common needs (such as ``string-extra``, +``html-extra``, ``intl-extra``, etc.) .. code-block:: terminal @@ -178,5 +178,5 @@ for this class and :doc:`tag your service ` with ``twig .. _`Twig Extensions`: https://twig.symfony.com/doc/2.x/advanced.html#creating-an-extension .. _`default Twig filters and functions`: https://twig.symfony.com/doc/2.x/#reference -.. _`official Twig extensions`: https://github.com/twigphp/Twig-extensions +.. _`official Twig GitHub organization`: https://github.com/twigphp .. _`global variables`: https://twig.symfony.com/doc/2.x/advanced.html#id1 From 93c8f33ed37cfc72358d778922c032bf2204b619 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 16:29:20 +0100 Subject: [PATCH 0063/7107] Tweaks --- configuration.rst | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/configuration.rst b/configuration.rst index d6e6f8abb1f..89961f0e5ef 100644 --- a/configuration.rst +++ b/configuration.rst @@ -617,21 +617,16 @@ following list shows the files loaded in all environments. The ``.env`` file is the only mandatory file and each file content overrides the previous one: * ``.env``: defines the default values of the env vars needed by the application; -* ``.env.local``: defines machine-specific overrides for env vars on all - environments. This file is not committed to the repository, so these overrides - only apply to the machine which contains the file (your local computer, - production server, etc.); +* ``.env.local``: overrides the default values of env vars for all environments + but only in the machine which contains the file (e.g. your development computer). + This file should not be committed to the repository and it's ignored in the + ``test`` environment (because tests should produce the same results for everyone); * ``.env.`` (e.g. ``.env.test``): overrides env vars only for some environment but for all machines; * ``.env..local`` (e.g. ``.env.test.local``): defines machine-specific env vars overrides only for some environment. It's similar to ``.env.local``, but the overrides only apply to some particular environment. -.. note:: - - ``.env.local`` is always ignored in test environment. The logic is that - tests should always produce the same results for everyone. - .. note:: The real environment variables defined in the server always win over the @@ -802,7 +797,7 @@ parameters at once by type-hinting any of its constructor arguments with the // src/Service/MessageGenerator.php namespace App\Service; - + // ... use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface; From c009c1b5eca434e6b803f0a71d1425c60592303a Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Fri, 22 Nov 2019 12:05:30 +0100 Subject: [PATCH 0064/7107] Update readme --- README.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index c1c1000be1a..af34e1032b0 100644 --- a/README.markdown +++ b/README.markdown @@ -18,7 +18,7 @@ Symfony documentation, please read SymfonyCloud ------------ -Pull requests are automatically built by [SymfonyCloud](https://symfony.com/cloud). +Pull requests are automatically built on [SymfonyCloud](https://symfony.com/cloud). Docker ------ From 077ab139c8009562fb4332cc6d4fc6262acdabc4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 16:37:20 +0100 Subject: [PATCH 0065/7107] Tweaks --- README.markdown | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.markdown b/README.markdown index af34e1032b0..9ffba759439 100644 --- a/README.markdown +++ b/README.markdown @@ -18,7 +18,8 @@ Symfony documentation, please read SymfonyCloud ------------ -Pull requests are automatically built on [SymfonyCloud](https://symfony.com/cloud). +Thanks to [SymfonyCloud](https://symfony.com/cloud) for providing an integration +server where Pull Requests are built and can be reviewed by contributors. Docker ------ From e23ebe00b6c67bdeaadd30a52904429598701c48 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 17:10:05 +0100 Subject: [PATCH 0066/7107] [DI] Documented the lint:container command --- service_container.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/service_container.rst b/service_container.rst index ccdc30c253c..a277cd24b0f 100644 --- a/service_container.rst +++ b/service_container.rst @@ -788,6 +788,28 @@ you don't need to do *anything*: the service will be automatically loaded. Then, implements ``Twig\Extension\ExtensionInterface``. And thanks to ``autowire``, you can even add constructor arguments without any configuration. +Linting Service Definitions +--------------------------- + +.. versionadded:: 4.4 + + The ``lint:conainer`` command was introduced in Symfony 4.4. + +The ``lint:conainer`` command checks that the arguments injected into services +match their type declarations. It's useful to run it before deploying your +application to production (e.g. in your continuous integration server): + +.. code-block:: terminal + + $ php bin/console lint:container + +Checking the types of all service arguments whenever the container is compiled +can hurt performance. That's why this type checking is implemented in a +:doc:`compiler pass ` called +``CheckTypeDeclarationsPass`` which is disabled by default and enabled only when +executing the ``lint:container`` command. If you don't mind the performance +loss, enable the compiler pass in your application. + .. _container-public: Public Versus Private Services From 9370179c15492a785cfd0ada3ebb0b9f4b1fdb04 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 17:21:53 +0100 Subject: [PATCH 0067/7107] [Mailer] Mentioned the getMessageId() method --- mailer.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mailer.rst b/mailer.rst index acf196c0ebc..fc19a02e914 100644 --- a/mailer.rst +++ b/mailer.rst @@ -271,6 +271,17 @@ provides access to the original message (``getOriginalMessage()``) and to some debug information (``getDebug()``) such as the HTTP calls done by the HTTP transports, which is useful to debug errors. +.. note:: + + Some mailer providers change the ``Message-Id`` when sending the email. The + ``getMessageId()`` method from ``SentMessage`` always returns the definitive + ID of the message (being the original random ID generated by Symfony or the + new ID generated by the mailer provider). + + .. versionadded:: 4.4 + + The ``getMessageId()`` method was introduced in Symfony 4.4. + The exceptions related to mailer transports (those which implement :class:`Symfony\\Component\\Mailer\\Exception\\TransportException`) also provide this debug information via the ``getDebug()`` method. From 0dfdb641a924041aad8aaf25ee17f63127e34982 Mon Sep 17 00:00:00 2001 From: Christophe Meneses Date: Mon, 9 Dec 2019 17:30:28 +0100 Subject: [PATCH 0068/7107] Remove unused use statement --- security/custom_authentication_provider.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 24856c151ee..a1732e8f08b 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -203,7 +203,6 @@ the ``PasswordDigest`` header value matches with the user's password:: use Symfony\Component\Security\Core\Authentication\Provider\AuthenticationProviderInterface; use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; - use Symfony\Component\Security\Core\Exception\NonceExpiredException; use Symfony\Component\Security\Core\User\UserProviderInterface; class WsseProvider implements AuthenticationProviderInterface From db960650c59f906d986276723d1f32ef497bb00c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 9 Dec 2019 17:32:07 +0100 Subject: [PATCH 0069/7107] Fixed code indentation --- service_container.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/service_container.rst b/service_container.rst index 63c8e7b0bc9..09991a63e5c 100644 --- a/service_container.rst +++ b/service_container.rst @@ -36,8 +36,8 @@ service's class or interface name. Want to :doc:`log ` something? No p class ProductController { /** - * @Route("/products") - */ + * @Route("/products") + */ public function list(LoggerInterface $logger) { $logger->info('Look! I just used a service'); @@ -194,8 +194,8 @@ each time you ask for it. ->defaults() ->autowire() // Automatically injects dependencies in your services. ->autoconfigure() // Automatically registers your services as commands, event subscribers, etc. - ; - + ; + // makes classes in src/ available to be used as services // this creates a service per class whose id is the fully-qualified class name $services->load('App\\', '../src/*') From 9322a00f689a2380b34c3f59887ef91e1b2489e8 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Mon, 9 Dec 2019 23:31:49 +0100 Subject: [PATCH 0070/7107] Fix output of before() example --- components/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/string.rst b/components/string.rst index eff09aa0361..03edb616d87 100644 --- a/components/string.rst +++ b/components/string.rst @@ -238,7 +238,7 @@ Methods to Append and Prepend // returns the contents found before/after the first occurrence of the given string u('hello world')->before('world'); // 'hello ' - u('hello world')->before('o'); // 'hell ' + u('hello world')->before('o'); // 'hell' u('hello world')->before('o', true); // 'hello' u('hello world')->after('hello'); // ' world' From 6793fbecc8d042896c265b6bb9a352b6e9183489 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Mon, 9 Dec 2019 23:32:47 +0100 Subject: [PATCH 0071/7107] Fix UnicodeString::fromCodePoints example --- components/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/string.rst b/components/string.rst index eff09aa0361..59098a8bf8d 100644 --- a/components/string.rst +++ b/components/string.rst @@ -125,7 +125,7 @@ There are also some specialized constructors:: $foo = ByteString::fromRandom(12); // CodePointString and UnicodeString can create a string from code points - $foo = UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); + $foo = (string) UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); // $foo = 'नमस्ते' Methods to Transform String Objects From ff0a9230cf0a691315a56418f8df528c874fa861 Mon Sep 17 00:00:00 2001 From: Jacob Dreesen Date: Tue, 10 Dec 2019 08:57:50 +0100 Subject: [PATCH 0072/7107] Remove superfluous space --- components/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/string.rst b/components/string.rst index eff09aa0361..a3b92c8b605 100644 --- a/components/string.rst +++ b/components/string.rst @@ -211,7 +211,7 @@ Methods to Change Case The methods of all string classes are case-sensitive by default. You can perform case-insensitive operations with the ``ignoreCase()`` method:: - u('abc')->indexOf('B'); // null + u('abc')->indexOf('B'); // null u('abc')->ignoreCase()->indexOf('B'); // 1 Methods to Append and Prepend From 1d6eeb28cc9e42a541d3eabad83cc0f2673c7b4b Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 10 Dec 2019 09:58:08 +0100 Subject: [PATCH 0073/7107] Fix build error Warning, treated as error: /home/travis/build/symfony/symfony-docs/components/phpunit_bridge.rst:313: WARNING: Mismatch: both interpreted text role prefix and reference suffix. --- components/phpunit_bridge.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index b2b6a1fac47..43199504e92 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -311,7 +311,7 @@ Deprecation Notices at Autoloading Time ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, the PHPUnit Bridge uses ``DebugClassLoader`` from the -:doc:`ErrorHandler component `_ to throw deprecation +:doc:`ErrorHandler component ` to throw deprecation notices at class autoloading time. This can be disabled with the ``debug-class-loader`` option. From 390e54bff765969c9be5773e185a19a22082945f Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 10 Dec 2019 10:15:15 +0100 Subject: [PATCH 0074/7107] Typo in command name. refs #12785 --- service_container.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/service_container.rst b/service_container.rst index c0d40ae9caa..a09187552f7 100644 --- a/service_container.rst +++ b/service_container.rst @@ -793,9 +793,9 @@ Linting Service Definitions .. versionadded:: 4.4 - The ``lint:conainer`` command was introduced in Symfony 4.4. + The ``lint:container`` command was introduced in Symfony 4.4. -The ``lint:conainer`` command checks that the arguments injected into services +The ``lint:container`` command checks that the arguments injected into services match their type declarations. It's useful to run it before deploying your application to production (e.g. in your continuous integration server): From b04c20b0f1f14ebc912841526224a85c2cdeffd0 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 10 Dec 2019 10:17:05 +0100 Subject: [PATCH 0075/7107] Removed old versionadded directives --- mailer.rst | 4 ---- service_container.rst | 4 ---- 2 files changed, 8 deletions(-) diff --git a/mailer.rst b/mailer.rst index b9ebbf7c32e..f818fe899f7 100644 --- a/mailer.rst +++ b/mailer.rst @@ -273,10 +273,6 @@ transports, which is useful to debug errors. ID of the message (being the original random ID generated by Symfony or the new ID generated by the mailer provider). - .. versionadded:: 4.4 - - The ``getMessageId()`` method was introduced in Symfony 4.4. - The exceptions related to mailer transports (those which implement :class:`Symfony\\Component\\Mailer\\Exception\\TransportException`) also provide this debug information via the ``getDebug()`` method. diff --git a/service_container.rst b/service_container.rst index e17cd722d8f..f918be188cf 100644 --- a/service_container.rst +++ b/service_container.rst @@ -787,10 +787,6 @@ constructor arguments without any configuration. Linting Service Definitions --------------------------- -.. versionadded:: 4.4 - - The ``lint:container`` command was introduced in Symfony 4.4. - The ``lint:container`` command checks that the arguments injected into services match their type declarations. It's useful to run it before deploying your application to production (e.g. in your continuous integration server): From c070711ef3dbffd766eff55d85807966d07c0887 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Dec 2019 13:37:17 +0100 Subject: [PATCH 0076/7107] [Console] Mention that CommandTester doesn't dispatch console events --- console.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/console.rst b/console.rst index 2dadcbb5daf..ad00db815a2 100644 --- a/console.rst +++ b/console.rst @@ -306,6 +306,12 @@ console:: You can also test a whole console application by using :class:`Symfony\\Component\\Console\\Tester\\ApplicationTester`. +.. caution:: + + When testing commands using the ``CommandTester`` class, console events are + not dispatched. If you need to test those events, use the + :class:`Symfony\\Component\\Console\\Tester\\ApplicationTester` instead. + .. note:: When using the Console component in a standalone project, use From e52a6663d7bc0e7f3861f539ecbd8b8d4bd3f930 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Dec 2019 15:12:50 +0100 Subject: [PATCH 0077/7107] Minor tweak --- components/string.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/string.rst b/components/string.rst index 257564de6b1..068f7fc02a2 100644 --- a/components/string.rst +++ b/components/string.rst @@ -125,8 +125,8 @@ There are also some specialized constructors:: $foo = ByteString::fromRandom(12); // CodePointString and UnicodeString can create a string from code points - $foo = (string) UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); - // $foo = 'नमस्ते' + $foo = UnicodeString::fromCodePoints(0x928, 0x92E, 0x938, 0x94D, 0x924, 0x947); + // equivalent to: $foo = new UnicodeString('नमस्ते'); Methods to Transform String Objects ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 9fdac8b2a905a5b09dd420df3b5f1b2f77bd58a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Paris?= Date: Tue, 10 Dec 2019 23:10:52 +0100 Subject: [PATCH 0078/7107] Use a instead of an before consonant sounds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit u is a vowel, but will sometime produce a consonant sound, as in user ([ˈjuːzər]) or URL ([ˌjuːɑːrˈɛl]). See https://www.grammar.com/a-vs-an-when-to-use/ --- components/phpunit_bridge.rst | 2 +- http_cache/cache_invalidation.rst | 2 +- mercure.rst | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 7272bcc02a0..e0cb3ad6d06 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -228,7 +228,7 @@ value). You can have even finer-grained control by using other keys of the ``max`` array, which are ``self``, ``direct``, and ``indirect``. The -``SYMFONY_DEPRECATIONS_HELPER`` environment variable accepts an URL-encoded +``SYMFONY_DEPRECATIONS_HELPER`` environment variable accepts a URL-encoded string, meaning you can combine thresholds and any other configuration setting, like this: ``SYMFONY_DEPRECATIONS_HELPER=max[total]=42&max[self]=0&verbose=0`` diff --git a/http_cache/cache_invalidation.rst b/http_cache/cache_invalidation.rst index 0d062df58b2..8cb1b6fb80e 100644 --- a/http_cache/cache_invalidation.rst +++ b/http_cache/cache_invalidation.rst @@ -9,7 +9,7 @@ Cache Invalidation "There are only two hard things in Computer Science: cache invalidation and naming things." -- Phil Karlton -Once an URL is cached by a gateway cache, the cache will not ask the +Once a URL is cached by a gateway cache, the cache will not ask the application for that content anymore. This allows the cache to provide fast responses and reduces the load on your application. However, you risk delivering outdated content. A way out of this dilemma is to use long diff --git a/mercure.rst b/mercure.rst index 63865613a72..48faf3f6158 100644 --- a/mercure.rst +++ b/mercure.rst @@ -7,7 +7,7 @@ Pushing Data to Clients Using the Mercure Protocol Being able to broadcast data in real-time from servers to clients is a requirement for many modern web and mobile applications. -Creating an UI reacting in live to changes made by other users +Creating a UI reacting in live to changes made by other users (e.g. a user changes the data currently browsed by several other users, all UIs are instantly updated), notifying the user when :doc:`an asynchronous job ` has been @@ -175,7 +175,7 @@ of the resource being dispatched. Usually, this parameter contains the original URL of the resource transmitted to the client, but it can be any valid `IRI`_, it doesn't -have to be an URL that exists (similarly to XML namespaces). +have to be a URL that exists (similarly to XML namespaces). The second parameter of the constructor is the content of the update. It can be anything, stored in any format. @@ -229,7 +229,7 @@ and to use URI Templates as patterns: .. tip:: - Test if a URI Template match an URL using `the online debugger`_ + Test if a URI Template match a URL using `the online debugger`_ Async dispatching ----------------- From b6f4e0946c4970e960da3aecec1ca31a1daf5a7f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Dec 2019 12:29:25 +0100 Subject: [PATCH 0079/7107] Tweak the explanation about event priorities --- event_dispatcher.rst | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 1152da89856..ebbb2bcecac 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -115,11 +115,11 @@ using a special "tag": method executed by default is ``onKernelException()``. The other optional tag attribute is called ``priority``, which defaults to - ``0`` and it controls the order in which listeners are executed (the higher - the number the earlier a listener is executed). This is useful when you - need to guarantee that one listener is executed before another. The priorities - of the internal Symfony listeners usually range from ``-255`` to ``255`` but - your own listeners can use any positive or negative integer. + ``0`` and it controls the order in which listeners are executed for a given + event (the higher the number the earlier a listener is executed). This is + useful when you need to guarantee that one listener is executed before + another. The priorities of the internal Symfony listeners usually range from + ``-255`` to ``255`` but your own listeners can use any positive or negative integer. .. _events-subscriber: @@ -131,10 +131,12 @@ that defines one or more methods that listen to one or various events. The main difference with the event listeners is that subscribers always know which events they are listening to. -In a given subscriber, different methods can listen to the same event. The order -in which methods are executed is defined by the ``priority`` parameter of each -method (the higher the number the earlier the method is called). To learn more -about event subscribers, read :doc:`/components/event_dispatcher`. +If different event subscriber methods listen to the same event, their order is +defined by the ``priority`` parameter. This value is a positive or negative +integer which defaults to ``0``. The higher the number, the earlier the method +is called. **Priority is aggregated for all listeners and subscribers**, so your +methods could be executed before or after the methods defined in other listeners +and subscribers. To learn more about event subscribers, read :doc:`/components/event_dispatcher`. The following example shows an event subscriber that defines several methods which listen to the same ``kernel.exception`` event:: From 71f352bfecf10992ef86d0c64d0fcec5ca4f89b6 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 10 Dec 2019 13:04:42 +0100 Subject: [PATCH 0080/7107] Mention the issues of ETag-based validation and Apache compression --- http_cache/validation.rst | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/http_cache/validation.rst b/http_cache/validation.rst index 5bae7bf38a4..d2f115f149f 100644 --- a/http_cache/validation.rst +++ b/http_cache/validation.rst @@ -38,13 +38,15 @@ to implement the validation model: ``ETag`` and ``Last-Modified``. Validation with the ``ETag`` Header ----------------------------------- -The ``ETag`` header is a string header (called the "entity-tag") that uniquely -identifies one representation of the target resource. It's entirely generated -and set by your application so that you can tell, for example, if the ``/about`` -resource that's stored by the cache is up-to-date with what your application -would return. An ``ETag`` is like a fingerprint and is used to quickly compare -if two different versions of a resource are equivalent. Like fingerprints, -each ``ETag`` must be unique across all representations of the same resource. +The `HTTP ETag`_ ("entity-tag") header is an optional HTTP header whose value is +an arbitrary string that uniquely identifies one representation of the target +resource. It's entirely generated and set by your application so that you can +tell, for example, if the ``/about`` resource that's stored by the cache is +up-to-date with what your application would return. + +An ``ETag`` is like a fingerprint and is used to quickly compare if two +different versions of a resource are equivalent. Like fingerprints, each +``ETag`` must be unique across all representations of the same resource. To see a simple implementation, generate the ETag as the md5 of the content:: @@ -72,6 +74,20 @@ method compares the ``If-None-Match`` header with the ``ETag`` response header. If the two match, the method automatically sets the ``Response`` status code to 304. +.. note:: + + When using ``mod_deflate`` or ``mod_brotli`` in Apache 2.4, the original + ``ETag`` value is modified (e.g. if ``ETag`` was ``foo``, Apache turns it + into ``foo-gzip`` or ``foo-br``), which breaks the ETag-based validation. + + You can control this behavior with the `DeflateAlterETag`_ and `BrotliAlterETag`_ + directives. Alternatively, you can use the following Apache configuration to + keep both the original ETag and the modified one when compressing responses: + + .. code-block:: apache + + RequestHeader edit "If-None-Match" '^"((.*)-(gzip|br))"$' '"$1", "$2"' + .. note:: The cache sets the ``If-None-Match`` header on the request to the ``ETag`` @@ -219,3 +235,6 @@ headers that must not be present for ``304`` responses (see :method:`Symfony\\Component\\HttpFoundation\\Response::setNotModified`). .. _`expiration model`: https://tools.ietf.org/html/rfc2616#section-13.2 +.. _`HTTP ETag`: https://en.wikipedia.org/wiki/HTTP_ETag +.. _`DeflateAlterETag`: https://httpd.apache.org/docs/trunk/mod/mod_deflate.html#deflatealteretag +.. _`BrotliAlterETag`: https://httpd.apache.org/docs/2.4/mod/mod_brotli.html#brotlialteretag From b9f315ffe7eb9318831e195f129f636eabf733a1 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 22 Oct 2019 10:01:05 -0400 Subject: [PATCH 0081/7107] Middleware clarification about being called on \"receive\" --- components/messenger.rst | 6 +++++- messenger.rst | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/components/messenger.rst b/components/messenger.rst index c17220d25a3..63761ec3dfc 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -54,7 +54,9 @@ Concepts For instance: logging, validating a message, starting a transaction, ... They are also responsible for calling the next middleware in the chain, which means they can tweak the envelope, by adding stamps to it or even - replacing it, as well as interrupt the middleware chain. + replacing it, as well as interrupt the middleware chain. Middleware are called + both when a message is originally dispatched and again later when a message + is received from a tansport, **Envelope** Messenger specific concept, it gives full flexibility inside the message bus, @@ -174,6 +176,8 @@ Hence you can inspect the envelope content and its stamps, or add any:: // You could for example add another stamp. $envelope = $envelope->with(new AnotherStamp(/* ... */)); + } else { + // Message was just originally dispatched } return $stack->next()->handle($envelope, $stack); diff --git a/messenger.rst b/messenger.rst index 1c4f8c06d91..185da3f5640 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1297,6 +1297,10 @@ for each bus looks like this: These middleware names are actually shortcuts names. The real service ids are prefixed with ``messenger.middleware.``. +The middleware are executed when the message is dispatched but *also* again when +a message is received via the worker (for messages that were sent to a transport +to be handled asynchronously). Keep this in mind if you create your own middleware. + You can add your own middleware to this list, or completely disable the default middleware and *only* include your own: From f89f52139307c3a120c5db0dab82486d6b3ecb93 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 11 Dec 2019 17:12:50 +0100 Subject: [PATCH 0082/7107] Tweak --- components/messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/messenger.rst b/components/messenger.rst index 37e55675a79..ba7acf6da49 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -56,7 +56,7 @@ Concepts which means they can tweak the envelope, by adding stamps to it or even replacing it, as well as interrupt the middleware chain. Middleware are called both when a message is originally dispatched and again later when a message - is received from a tansport, + is received from a transport, **Envelope** Messenger specific concept, it gives full flexibility inside the message bus, From d9fd6a7617cb2d520addf38e38cb371be67f1dc1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 11:13:37 +0100 Subject: [PATCH 0083/7107] [Messenger] Added a missing class import --- components/messenger.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/messenger.rst b/components/messenger.rst index ba7acf6da49..fa4b4a7d81b 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -163,6 +163,7 @@ Instead of dealing directly with the messages in the middleware you receive the Hence you can inspect the envelope content and its stamps, or add any:: use App\Message\Stamp\AnotherStamp; + use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Middleware\MiddlewareInterface; use Symfony\Component\Messenger\Middleware\StackInterface; use Symfony\Component\Messenger\Stamp\ReceivedStamp; From 70503a75fbdc998bd7344131dca329e2f48c2ac1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 15:54:02 +0100 Subject: [PATCH 0084/7107] [Messenger] Minor tweaks for the main Messenger article --- messenger.rst | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/messenger.rst b/messenger.rst index 533482d957e..ad8732691b5 100644 --- a/messenger.rst +++ b/messenger.rst @@ -50,9 +50,10 @@ serialized:: .. _messenger-handler: -A message handler is a PHP callable, the recommended way to create it is to create a class that -implements ``MessageHandlerInterface`` and has an ``__invoke()`` method that's -type-hinted with the message class (or a message interface):: +A message handler is a PHP callable, the recommended way to create it is to +create a class that implements :class:`Symfony\\Component\\Messenger\\Handler\\MessageHandlerInterface` +and has an ``__invoke()`` method that's type-hinted with the message class (or a +message interface):: // src/MessageHandler/SmsNotificationHandler.php namespace App\MessageHandler; @@ -111,7 +112,7 @@ Transports: Async/Queued Messages By default, messages are handled as soon as they are dispatched. If you want to handle a message asynchronously, you can configure a transport. A transport is capable of sending messages (e.g. to a queueing system) and then -:ref:`receiving them via a worker`. Messenger supports +:ref:`receiving them via a worker `. Messenger supports :ref:`multiple transports `. .. note:: @@ -503,7 +504,7 @@ different messages to them. For example: # queue_name is specific to the doctrine transport queue_name: high - # for amqp send to a separate exchange then queue + # for AMQP send to a separate exchange then queue #exchange: # name: high #queues: @@ -1240,7 +1241,7 @@ Envelopes & Stamps ~~~~~~~~~~~~~~~~~~ A message can be any PHP object. Sometimes, you may need to configure something -extra about the message - like the way it should be handled inside Amqp or adding +extra about the message - like the way it should be handled inside AMQP or adding a delay before the message should be handled. You can do that by adding a "stamp" to your message:: @@ -1294,8 +1295,8 @@ for each bus looks like this: .. note:: - These middleware names are actually shortcuts names. The real service ids - are prefixed with ``messenger.middleware.``. + These middleware names are actually shortcut names. The real service ids + are prefixed with ``messenger.middleware.`` (e.g. ``messenger.middleware.handle_message``). The middleware are executed when the message is dispatched but *also* again when a message is received via the worker (for messages that were sent to a transport From 403cc509d3823b3cefd56fa9bc4019f3f0c1b223 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 12 Dec 2019 17:50:44 +0100 Subject: [PATCH 0085/7107] [Mailer] Minor tweaks in the mailer docs --- mailer.rst | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mailer.rst b/mailer.rst index aecb585eb87..4d54c3bef00 100644 --- a/mailer.rst +++ b/mailer.rst @@ -121,7 +121,9 @@ and create an :class:`Symfony\\Component\\Mime\\Email` object:: ->text('Sending emails is fun again!') ->html('

See Twig integration for better HTML integration!

'); - $mailer->send($email); + /** @var Symfony\Component\Mailer\SentMessage $sentEmail */ + $sentEmail = $mailer->send($email); + // $messageId = $sentEmail->getMessageId(); // ... } @@ -157,7 +159,8 @@ both strings or address objects:: Instead of calling ``->from()`` *every* time you create a new email, you can create an :doc:`event subscriber ` and listen to the - ``MessageEvent::class`` event to set the same ``From`` email to all messages. + :class:`Symfony\\Component\\Mailer\\Event\\MessageEvent` event to set the + same ``From`` email to all messages. Multiple addresses are defined with the ``addXXX()`` methods:: From c0ea4d29e21c911253b3531ded5e678d25aebb42 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 13 Dec 2019 10:15:26 +0100 Subject: [PATCH 0086/7107] Fixed method names when using the method directive --- components/options_resolver.rst | 2 +- components/property_info.rst | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/components/options_resolver.rst b/components/options_resolver.rst index fec225e5bf1..05e6ece5b98 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -748,7 +748,7 @@ method:: When using an option deprecated by you in your own library, you can pass ``false`` as the second argument of the - :method:`Symfony\\Component\\OptionsResolver\\Options::offsetGet()` method + :method:`Symfony\\Component\\OptionsResolver\\Options::offsetGet` method to not trigger the deprecation warning. Instead of passing the message, you may also pass a closure which returns diff --git a/components/property_info.rst b/components/property_info.rst index d800c14d845..dce587e629e 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -120,11 +120,11 @@ Extractable Information The :class:`Symfony\\Component\\PropertyInfo\\PropertyInfoExtractor` class exposes public methods to extract several types of information: -* :ref:`List of properties `: :method:`Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface::getProperties()` -* :ref:`Property type `: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getTypes()` -* :ref:`Property description `: :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getShortDescription()` and :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getLongDescription()` -* :ref:`Property access details `: :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isReadable()` and :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isWritable()` -* :ref:`Property initializable through the constructor `: :method:`Symfony\\Component\\PropertyInfo\\PropertyInitializableExtractorInterface::isInitializable()` +* :ref:`List of properties `: :method:`Symfony\\Component\\PropertyInfo\\PropertyListExtractorInterface::getProperties` +* :ref:`Property type `: :method:`Symfony\\Component\\PropertyInfo\\PropertyTypeExtractorInterface::getTypes` +* :ref:`Property description `: :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getShortDescription` and :method:`Symfony\\Component\\PropertyInfo\\PropertyDescriptionExtractorInterface::getLongDescription` +* :ref:`Property access details `: :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isReadable` and :method:`Symfony\\Component\\PropertyInfo\\PropertyAccessExtractorInterface::isWritable` +* :ref:`Property initializable through the constructor `: :method:`Symfony\\Component\\PropertyInfo\\PropertyInitializableExtractorInterface::isInitializable` .. note:: From 91eb804097fb09ca69ec4be0ccdac65c2be0e0df Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 13 Dec 2019 11:03:54 +0100 Subject: [PATCH 0087/7107] Tweaked the PropertyAccess doc --- components/property_access.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/property_access.rst b/components/property_access.rst index c368d3581ac..d1732b29893 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -158,13 +158,13 @@ getters, this means that you can do something like this:: $person = new Person(); if ($propertyAccessor->getValue($person, 'author')) { - var_dump('He is an author'); + var_dump('This person is an author'); } if ($propertyAccessor->getValue($person, 'children')) { - var_dump('He has children'); + var_dump('This person has children'); } -This will produce: ``He is an author`` +This will produce: ``This person is an author`` Magic ``__get()`` Method ~~~~~~~~~~~~~~~~~~~~~~~~ From fc44076e1edb32e8da65cf664f73ba43abfa2b02 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 13 Dec 2019 11:09:52 +0100 Subject: [PATCH 0088/7107] [PropertyAccess] Update the method directives --- components/property_access.rst | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/components/property_access.rst b/components/property_access.rst index c18eccdcd30..5c91e343204 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -21,7 +21,7 @@ Usage ----- The entry point of this component is the -:method:`PropertyAccess::createPropertyAccessor` +:method:`Symfony\\Component\\PropertyAccess\\PropertyAccess::createPropertyAccessor` factory. This factory will create a new instance of the :class:`Symfony\\Component\\PropertyAccess\\PropertyAccessor` class with the default configuration:: @@ -34,8 +34,8 @@ Reading from Arrays ------------------- You can read an array with the -:method:`PropertyAccessor::getValue` -method. This is done using the index notation that is used in PHP:: +:method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue` method. +This is done using the index notation that is used in PHP:: // ... $person = [ @@ -175,7 +175,7 @@ Accessing a non Existing Property Path Symfony 4.3. By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException` -is thrown if the property path passed to :method:`PropertyAccessor::getValue` +is thrown if the property path passed to :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue` does not exist. You can change this behavior using the :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::disableExceptionOnInvalidPropertyPath` method:: @@ -259,7 +259,7 @@ enable this feature by using :class:`Symfony\\Component\\PropertyAccess\\Propert .. caution:: The ``__call()`` feature is disabled by default, you can enable it by calling - :method:`PropertyAccessorBuilder::enableMagicCall` + :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessorBuilder::enableMagicCall` see `Enable other Features`_. Writing to Arrays @@ -267,8 +267,7 @@ Writing to Arrays The ``PropertyAccessor`` class can do more than just read an array, it can also write to an array. This can be achieved using the -:method:`PropertyAccessor::setValue` -method:: +:method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::setValue` method:: // ... $person = []; @@ -404,10 +403,9 @@ Checking Property Paths ----------------------- When you want to check whether -:method:`PropertyAccessor::getValue` -can safely be called without actually calling that method, you can use -:method:`PropertyAccessor::isReadable` -instead:: +:method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::getValue` can +safely be called without actually calling that method, you can use +:method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::isReadable` instead:: $person = new Person(); @@ -415,9 +413,8 @@ instead:: // ... } -The same is possible for :method:`PropertyAccessor::setValue`: -Call the -:method:`PropertyAccessor::isWritable` +The same is possible for :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::setValue`: +Call the :method:`Symfony\\Component\\PropertyAccess\\PropertyAccessor::isWritable` method to find out whether a property path can be updated:: $person = new Person(); From 775703e1d383451c052c9c5eb1b64d4648f534b4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 15:31:38 +0100 Subject: [PATCH 0089/7107] [ErrorHandler] Simplified docs --- components/error_handler.rst | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/components/error_handler.rst b/components/error_handler.rst index 7452ebce3e5..08e179efa20 100644 --- a/components/error_handler.rst +++ b/components/error_handler.rst @@ -22,14 +22,9 @@ Installation Usage ----- -The ErrorHandler component provides several tools to help you debug PHP code: - -* An **error handler** that turns PHP errors into exceptions; -* An **exception handler** that turns uncaught PHP exceptions into nice PHP responses; -* A **debug class loader** that provides better errors when a class is not found. - +The ErrorHandler component provides several tools to help you debug PHP code. Call this method (e.g. in your :ref:`front controller `) -to enable all these features in your application:: +to enable all of them in your application:: // public/index.php use Symfony\Component\ErrorHandler\Debug; @@ -52,9 +47,10 @@ Turning PHP Errors into Exceptions ---------------------------------- The :class:`Symfony\\Component\\ErrorHandler\\ErrorHandler` class catches PHP -errors and turns them into PHP's :phpclass:`ErrorException` objects, except for -fatal PHP errors, which are turned into Symfony's -:class:`Symfony\\Component\\ErrorHandler\\Exception\\FatalErrorException` objects. +errors and uncaught PHP exceptions and turns them into PHP's +:phpclass:`ErrorException` objects, except for fatal PHP errors, which are +turned into Symfony's :class:`Symfony\\Component\\ErrorHandler\\Exception\\FatalErrorException` +objects. If the application uses the FrameworkBundle, this error handler is enabled by default in the :ref:`production environment ` @@ -120,26 +116,6 @@ wrap several function calls inside an anonymous function:: return $data; }); -Debugging Uncaught PHP Exceptions ---------------------------------- - -The :class:`Symfony\\Component\\ErrorHandler\\ExceptionHandler` class catches -uncaught PHP exceptions and turns them into a nice response, so you can debug -them. It is useful in :ref:`debug mode ` to replace the default -PHP/XDebug output with something prettier and more useful. - -If the :doc:`HttpFoundation component ` is -available, the handler returns a Symfony's -:class:`Symfony\\Component\\HttpFoundation\\Response` object. Otherwise, it returns -a generic PHP response. - -Use the following code (e.g. in your :ref:`front controller `) -to enable this exception handler:: - - use Symfony\Component\ErrorHandler\ExceptionHandler; - - ExceptionHandler::register(); - .. _component-debug-class-loader: Class Loading Debugger From 82119af0455a3700f6d83387a840a0aa183d5753 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 15:52:19 +0100 Subject: [PATCH 0090/7107] [Monolog] Add a caution note about Symfony Mailer and Monolog --- logging/monolog_email.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/logging/monolog_email.rst b/logging/monolog_email.rst index 14d4fe092c2..9e824a77def 100644 --- a/logging/monolog_email.rst +++ b/logging/monolog_email.rst @@ -4,6 +4,11 @@ How to Configure Monolog to Email Errors ======================================== +.. caution:: + + This feature is not compatible yet with the new :doc:`Symfony mailer `, + so it requires using SwiftMailer. + `Monolog`_ can be configured to send an email when an error occurs with an application. The configuration for this requires a few nested handlers in order to avoid receiving too many emails. This configuration looks From da354dab68187512502cc84125443256bf45abc8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 16:49:23 +0100 Subject: [PATCH 0091/7107] [Routing] Documented the option to exclude patterns --- routing.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index d7397f16978..5d69151732c 100644 --- a/routing.rst +++ b/routing.rst @@ -1174,6 +1174,8 @@ the common configuration using options when importing the routes. # An imported route with an empty URL will become "/blog/" # Uncomment this option to make that URL "/blog" instead # trailing_slash_on_root: false + # you can optionally exclude some files/subdirectories when loading annotations + # exclude: '../src/Controller/{DebugEmailController}.php' .. code-block:: xml @@ -1187,11 +1189,13 @@ the common configuration using options when importing the routes. + name-prefix="blog_" + exclude="../src/Controller/{DebugEmailController}.php"> en|es|fr @@ -1211,6 +1215,8 @@ the common configuration using options when importing the routes. use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { + // use the optional fifth argument of import() to exclude some files + // or subdirectories when loading annotations $routes->import('../src/Controller/', 'annotation') // this is added to the beginning of all imported route URLs ->prefix('/blog') @@ -1224,6 +1230,11 @@ the common configuration using options when importing the routes. ; }; +.. versionadded:: 4.4 + + The option to exclude some files or subdirectories when loading annotations + was introduced in Symfony 4.4. + In this example, the route of the ``index()`` action will be called ``blog_index`` and its URL will be ``/blog/``. The route of the ``show()`` action will be called ``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes From b7b52ab261d25bde44fbeb3d24edd94ce353b88a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 17:17:42 +0100 Subject: [PATCH 0092/7107] [Validation] Mention the option to pass stringable objects --- validation/custom_constraint.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 0c0bc2960cf..9af22a03480 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -85,6 +85,7 @@ The validator class is also simple, and only has one required method ``validate( } if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) { + // the argument must be a string or an object implementing __toString() $this->context->buildViolation($constraint->message) ->setParameter('{{ string }}', $value) ->addViolation(); @@ -92,6 +93,11 @@ The validator class is also simple, and only has one required method ``validate( } } +.. versionadded:: 4.4 + + The feature to allow passing an object as the ``buildViolation()`` argument + was introduced in Symfony 4.4. + Inside ``validate``, you don't need to return a value. Instead, you add violations to the validator's ``context`` property and a value will be considered valid if it causes no violations. The ``buildViolation()`` method takes the error From 9d1e2e038a63771609a95de74b4c0343d52b4a28 Mon Sep 17 00:00:00 2001 From: Abdouni Abdelkarim Date: Tue, 17 Dec 2019 09:28:14 +0100 Subject: [PATCH 0093/7107] Update database.rst MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hello, I just add return type hint like the parent class : https://github.com/sebastianbergmann/phpunit/blob/master/src/Framework/TestCase.php Cheers 😉 --- testing/database.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/database.rst b/testing/database.rst index ed587f3427e..9be53774e8b 100644 --- a/testing/database.rst +++ b/testing/database.rst @@ -221,7 +221,7 @@ so, get the entity manager via the service container as follows:: */ private $entityManager; - protected function setUp() + protected function setUp(): void { $kernel = self::bootKernel(); @@ -240,7 +240,7 @@ so, get the entity manager via the service container as follows:: $this->assertSame(14.50, $product->getPrice()); } - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); From fcb2b89a2d8592c949f71b5e782b5b3ec438b8f4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 16:16:46 +0100 Subject: [PATCH 0094/7107] Added the docs for the UUID polyfill --- components/polyfill_uuid.rst | 57 ++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 components/polyfill_uuid.rst diff --git a/components/polyfill_uuid.rst b/components/polyfill_uuid.rst new file mode 100644 index 00000000000..0fd080d39d4 --- /dev/null +++ b/components/polyfill_uuid.rst @@ -0,0 +1,57 @@ +.. index:: + single: Polyfill + single: PHP + single: Components; Polyfill + +The Symfony Polyfill / UUID Component +===================================== + + This component provides ``uuid_*`` functions to users who run PHP versions + without the UUID extension. + +Installation +------------ + +.. code-block:: terminal + + $ composer require symfony/polyfill-uuid + +.. include:: /components/require_autoload.rst.inc + +Usage +----- + +Once this component is installed in your application, you can use the following +functions, no matter if the `PHP UUID extension`_ is installed or not in your +server. + +Provided Constants +~~~~~~~~~~~~~~~~~~ + +* ``UUID_VARIANT_NCS`` (value = 0) +* ``UUID_VARIANT_DCE`` (value = 1) +* ``UUID_VARIANT_MICROSOFT`` (value = 2) +* ``UUID_VARIANT_OTHER`` (value = 3) +* ``UUID_TYPE_DEFAULT`` (value = 0) +* ``UUID_TYPE_TIME`` (value = 1) +* ``UUID_TYPE_DCE`` (value = 4) +* ``UUID_TYPE_NAME`` (value = 1) +* ``UUID_TYPE_RANDOM`` (value = 4) +* ``UUID_TYPE_NULL`` (value = -1) +* ``UUID_TYPE_INVALID`` (value = -42) + +Provided Functions +~~~~~~~~~~~~~~~~~~ + +* :phpfunction:`uuid_create` +* :phpfunction:`uuid_is_valid` +* :phpfunction:`uuid_compare` +* :phpfunction:`uuid_is_null` +* :phpfunction:`uuid_type` +* :phpfunction:`uuid_variant` +* :phpfunction:`uuid_time` +* :phpfunction:`uuid_mac` +* :phpfunction:`uuid_parse` +* :phpfunction:`uuid_unparse` + +.. _`PHP UUID extension`: https://pecl.php.net/package/uuid From ea7a85798c9c115cf17c0ff56602553bace025ac Mon Sep 17 00:00:00 2001 From: Johann Pardanaud Date: Tue, 17 Dec 2019 11:21:00 +0100 Subject: [PATCH 0095/7107] Add a note about voters with access_control Explain how the Access Decision Strategy can impact the way access_control works. --- security/access_control.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/security/access_control.rst b/security/access_control.rst index 9c0378ff79d..0daab78c71c 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -160,6 +160,13 @@ options: can learn how to use your custom attributes by reading :ref:`security/custom-voter`. +.. caution:: + + If you define both ``roles`` and ``allow_if``, and your Access Decision + Strategy is the default one (``affirmative``), then the user will be granted + access if there's at least one valid condition. See :doc:`/security/voters` + to change your strategy to something more suited to your needs. + .. tip:: If access is denied, the system will try to authenticate the user if not From 6a22af87a89253b9364b08491427ff0e99a229d5 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 17 Dec 2019 11:22:35 +0100 Subject: [PATCH 0096/7107] [Routing] Removed old versionadded directive --- routing.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/routing.rst b/routing.rst index acfa313d2b3..637986f3e72 100644 --- a/routing.rst +++ b/routing.rst @@ -1221,11 +1221,6 @@ the common configuration using options when importing the routes. ; }; -.. versionadded:: 4.4 - - The option to exclude some files or subdirectories when loading annotations - was introduced in Symfony 4.4. - In this example, the route of the ``index()`` action will be called ``blog_index`` and its URL will be ``/blog/``. The route of the ``show()`` action will be called ``blog_show`` and its URL will be ``/blog/{_locale}/posts/{slug}``. Both routes From a8fc4742acd9de50ce30c642666f264b6f96e197 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 17 Dec 2019 11:23:00 +0100 Subject: [PATCH 0097/7107] [Validator] Removed old versionadded directive --- validation/custom_constraint.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 9af22a03480..69fcfe07ee1 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -93,11 +93,6 @@ The validator class is also simple, and only has one required method ``validate( } } -.. versionadded:: 4.4 - - The feature to allow passing an object as the ``buildViolation()`` argument - was introduced in Symfony 4.4. - Inside ``validate``, you don't need to return a value. Instead, you add violations to the validator's ``context`` property and a value will be considered valid if it causes no violations. The ``buildViolation()`` method takes the error From d505c9736215b8ac7874238757020e58e267edff Mon Sep 17 00:00:00 2001 From: Adoni Pavlakis Date: Fri, 20 Dec 2019 14:55:11 +0000 Subject: [PATCH 0098/7107] Update references to 4.4 version As version `4.4` is an LTS, would be useful for the docs to reference the `4.4` version specifically when updating to this version. --- setup/upgrade_minor.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/setup/upgrade_minor.rst b/setup/upgrade_minor.rst index 78999251f7b..840e555c52b 100644 --- a/setup/upgrade_minor.rst +++ b/setup/upgrade_minor.rst @@ -45,14 +45,15 @@ are like this: At the bottom of your ``composer.json`` file, in the ``extra`` block you can find a data setting for the symfony version. Make sure to also upgrade -this one. For instance, update it to ``4.3.*`` to upgrade to Symfony 4.3: +this one. For instance, update it to `` +.*`` to upgrade to Symfony 4.4: .. code-block:: json "extra": { "symfony": { "allow-contrib": false, - "require": "4.3.*" + "require": "4.4.*" } } From 33888b6a6960802b1f09ce5eb5874e88495779b9 Mon Sep 17 00:00:00 2001 From: sparrowek Date: Thu, 12 Dec 2019 21:23:43 +0100 Subject: [PATCH 0099/7107] Update configuration.rst As is explained elsewhere "The real environment variables defined in the server always win over the env vars created by the ``.env`` files" so the word override is misleading here. The .env file does not override server variables. --- configuration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.rst b/configuration.rst index 89961f0e5ef..d658714e4b3 100644 --- a/configuration.rst +++ b/configuration.rst @@ -563,7 +563,7 @@ Configuring Environment Variables in Production ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In production, the ``.env`` files are also parsed and loaded on each request so -you can override the env vars already defined in the server. In order to improve +you can add env vars to those already defined in the server. In order to improve performance, you can run the ``dump-env`` command (available when using :ref:`Symfony Flex ` 1.2 or later). From 673711d3ec214cbd08b18b9404988a761085d8dc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 20 Dec 2019 17:13:53 +0100 Subject: [PATCH 0100/7107] Minor fix --- setup/upgrade_minor.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup/upgrade_minor.rst b/setup/upgrade_minor.rst index 840e555c52b..3eedda40e43 100644 --- a/setup/upgrade_minor.rst +++ b/setup/upgrade_minor.rst @@ -45,8 +45,7 @@ are like this: At the bottom of your ``composer.json`` file, in the ``extra`` block you can find a data setting for the symfony version. Make sure to also upgrade -this one. For instance, update it to `` -.*`` to upgrade to Symfony 4.4: +this one. For instance, update it to ``4.4.*`` to upgrade to Symfony 4.4: .. code-block:: json From 9268f637d924389181f7e798c307db5d5506d711 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 16 Dec 2019 16:05:58 +0100 Subject: [PATCH 0101/7107] [Performance] Document the container.dumper.inline_factories parameter --- performance.rst | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/performance.rst b/performance.rst index 893ba7877ba..28b9f38dfbe 100644 --- a/performance.rst +++ b/performance.rst @@ -12,6 +12,7 @@ Symfony Application Checklist ----------------------------- #. :ref:`Install APCu Polyfill if your server uses APC ` +#. :ref:`Dump the service container into a single file ` Production Server Checklist --------------------------- @@ -33,6 +34,51 @@ OPcache, install the `APCu Polyfill component`_ in your application to enable compatibility with `APCu PHP functions`_ and unlock support for advanced Symfony features, such as the APCu Cache adapter. +.. _performance-service-container-single-file: + +Dump the Service Container into a Single File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 4.4 + + The ``container.dumper.inline_factories`` parameter was introduced in + Symfony 4.4. + +Symfony compiles the :doc:`service container ` into multiple +small files by default. Set this parameter to ``true`` to compile the entire +container into a single file, which could improve performance when using +"class preloading" in PHP 7.4 or newer versions: + +.. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + parameters: + # ... + container.dumper.inline_factories: true + + .. code-block:: xml + + + + + + + + true + + + + .. code-block:: php + + // config/services.php + + // ... + $container->setParameter('container.dumper.inline_factories', true); + .. _performance-use-opcache: Use the OPcache Byte Code Cache From 111ae11eeed902cdac0b34532862aa354e3b9b79 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 20 Dec 2019 17:26:27 +0100 Subject: [PATCH 0102/7107] Minor tweaks --- components/process.rst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/components/process.rst b/components/process.rst index 9a53f06080b..cce427238c6 100644 --- a/components/process.rst +++ b/components/process.rst @@ -139,16 +139,16 @@ environment variables using the second argument of the ``run()``, // On both Unix-like and Windows $process->run(null, ['MESSAGE' => 'Something to output']); -To help write command lines that are independent from the operating system, -you can also write the above code as such:: +If you prefer to create portable commands that are independent from the +operating system, you can write the above command as follows:: - // On both Unix-like and Windows + // works the same on Windows , Linux and macOS $process = Process::fromShellCommandline('echo "${:MESSAGE}"'); -This requires using a syntax that is specific to the component: when enclosing -a variable name into ``"{$:`` and ``}"`` exactly, the process object will -replace it with its escaped value, or will fail if the variable is not found in -the list of environment variables attached to the command. +Portable commands require using a syntax that is specific to the component: when +enclosing a variable name into ``"{$:`` and ``}"`` exactly, the process object +will replace it with its escaped value, or will fail if the variable is not +found in the list of environment variables attached to the command. .. versionadded:: 4.4 From 2052995834f26a3ed9be153fa7de1c8f9f1fef4e Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Tue, 24 Dec 2019 23:20:53 +0100 Subject: [PATCH 0103/7107] Update routing.rst --- routing.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/routing.rst b/routing.rst index f5aebf15337..ffcb92e1431 100644 --- a/routing.rst +++ b/routing.rst @@ -1507,7 +1507,6 @@ host name: ; }; - return $routes; The value of the ``host`` option can include parameters (which is useful in multi-tenant applications) and these parameters can be validated too with From 085f5fba99eefec0d721e29f96bca4fa500eee2d Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 01:49:54 +0100 Subject: [PATCH 0104/7107] Update routing.rst --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index f5aebf15337..95b62838bc4 100644 --- a/routing.rst +++ b/routing.rst @@ -2061,7 +2061,7 @@ each route explicitly: .. code-block:: php-annotations - // src/Controller/MainController.php + // src/Controller/SecurityController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; From 3d0fed089955677bc8d112f535b505c1403f2179 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 02:07:09 +0100 Subject: [PATCH 0105/7107] Update routing.rst - Fix wrong XML --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index f5aebf15337..677fa00a956 100644 --- a/routing.rst +++ b/routing.rst @@ -2155,7 +2155,7 @@ defined as annotations: https://symfony.com/schema/routing/routing-1.0.xsd"> - HTTPS + HTTPS From a49af0d7297b891942336d1e2fe2494410c0523b Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 02:21:51 +0100 Subject: [PATCH 0106/7107] Make custom routers compatible with the LoaderInterface --- routing/custom_route_loader.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 036b7f9a7ba..753d67d0139 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -253,7 +253,7 @@ you do. The resource name itself is not actually used in the example:: { private $isLoaded = false; - public function load($resource, $type = null) + public function load($resource, string $type = null) { if (true === $this->isLoaded) { throw new \RuntimeException('Do not add the "extra" loader twice'); @@ -280,7 +280,7 @@ you do. The resource name itself is not actually used in the example:: return $routes; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'extra' === $type; } @@ -419,7 +419,7 @@ configuration file - you can call the class AdvancedLoader extends Loader { - public function load($resource, $type = null) + public function load($resource, string $type = null) { $routes = new RouteCollection(); @@ -433,7 +433,7 @@ configuration file - you can call the return $routes; } - public function supports($resource, $type = null) + public function supports($resource, string $type = null) { return 'advanced_extra' === $type; } From c71ca312b37ea7bfcfec47c54990e60059b09e5b Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 02:28:06 +0100 Subject: [PATCH 0107/7107] Update custom_route_loader.rst | Fix wrong tag --- routing/custom_route_loader.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 8f9be5dee5c..12541ce8ac1 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -214,7 +214,7 @@ extend or implement any special class, but the called method must return a If you're using :ref:`autoconfigure `, your class should implement the :class:`Symfony\\Bundle\\FrameworkBundle\\Routing\\RouteLoaderInterface` interface to be tagged automatically. If you're **not using autoconfigure**, -tag it manually with ``routing.route_loader``. +tag it manually with ``routing.loader``. .. deprecated:: 4.4 From 0e7a1ec3babcbaae53c0d24a0cdbc12c3afff9ef Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 15:20:06 +0100 Subject: [PATCH 0108/7107] Update argument_value_resolver.rst --- controller/argument_value_resolver.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index 703a2736ae7..a32166778ee 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -32,8 +32,8 @@ Symfony ships with the following value resolvers in the works like :doc:`autowiring `. :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver\\SessionValueResolver` - Injects the configured session class extending ``SessionInterface`` if - type-hinted with ``SessionInterface`` or a class extending + Injects the configured session class implementing ``SessionInterface`` if + type-hinted with ``SessionInterface`` or a class implementing ``SessionInterface``. :class:`Symfony\\Component\\HttpKernel\\Controller\\ArgumentResolver\\DefaultValueResolver` From f5bbc44878057648984d1a73014da9d90e36c769 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Thu, 26 Dec 2019 20:43:43 +0100 Subject: [PATCH 0109/7107] Update password_migration.rst --- security/password_migration.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/password_migration.rst b/security/password_migration.rst index 7ce2d08d153..b703e278bc4 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -188,7 +188,7 @@ Trigger Password Migration From a Custom Encoder If you're using a custom password encoder, you can trigger the password migration by returning ``true`` in the ``needsRehash()`` method:: - // src/Security/UserProvider.php + // src/Security/CustomPasswordEncoder.php namespace App\Security; // ... From eb4a0adf11c8d07514d9476fbe6631d91a82d867 Mon Sep 17 00:00:00 2001 From: Abdouni Abdelkarim Date: Thu, 26 Dec 2019 23:00:08 +0100 Subject: [PATCH 0110/7107] Update security.rst --- security.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security.rst b/security.rst index 3bfb384121d..64a4fb61cb8 100644 --- a/security.rst +++ b/security.rst @@ -239,7 +239,7 @@ important section is ``firewalls``: pattern: ^/(_(profiler|wdt)|css|images|js)/ security: false main: - anonymous: ~ + anonymous: lazy .. code-block:: xml From 7771a2bfacf0318f907a2ae74b20abff0f066a99 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Fri, 27 Dec 2019 00:21:04 +0100 Subject: [PATCH 0111/7107] Update guard_authentication.rst --- security/guard_authentication.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index a3027dd7e4b..82c722287bb 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -241,7 +241,7 @@ Finally, configure your ``firewalls`` key in ``security.yaml`` to use this authe 'logout' => true, 'guard' => [ 'authenticators' => [ - TokenAuthenticator::class + TokenAuthenticator::class, ], ], // ... @@ -300,7 +300,7 @@ Each authenticator needs the following methods: (or throw an :ref:`AuthenticationException `), authentication will fail. -**onAuthenticationSuccess(Request $request, TokenInterface $token, $providerKey)** +**onAuthenticationSuccess(Request $request, TokenInterface $token, string $providerKey)** This is called after successful authentication and your job is to either return a :class:`Symfony\\Component\\HttpFoundation\\Response` object that will be sent to the client or ``null`` to continue the request @@ -321,7 +321,7 @@ Each authenticator needs the following methods: the user authenticate (e.g. a 401 response that says "token is missing!"). **supportsRememberMe()** - If you want to support "remember me" functionality, return true from this method. + If you want to support "remember me" functionality, return ``true`` from this method. You will still need to activate ``remember_me`` under your firewall for it to work. Since this is a stateless API, you do not want to support "remember me" functionality in this example. @@ -330,7 +330,7 @@ Each authenticator needs the following methods: If you are implementing the :class:`Symfony\\Component\\Security\\Guard\\AuthenticatorInterface` instead of extending the :class:`Symfony\\Component\\Security\\Guard\\AbstractGuardAuthenticator` class, you have to implement this method. It will be called - after a successful authentication to create and return the token + after a successful authentication to create and return the token (a class implementing :class:`Symfony\\Component\\Security\\Guard\\Token\\GuardTokenInterface`) for the user, who was supplied as the first argument. The picture below shows how Symfony calls Guard Authenticator methods: From 5ed10787c4c921a248dcbf3d3e1635c46986d4ec Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 27 Dec 2019 09:24:15 +0100 Subject: [PATCH 0112/7107] remove old versionadded directive --- performance.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/performance.rst b/performance.rst index 69bd27bf30f..12cf5bde312 100644 --- a/performance.rst +++ b/performance.rst @@ -39,11 +39,6 @@ features, such as the APCu Cache adapter. Dump the Service Container into a Single File ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The ``container.dumper.inline_factories`` parameter was introduced in - Symfony 4.4. - Symfony compiles the :doc:`service container ` into multiple small files by default. Set this parameter to ``true`` to compile the entire container into a single file, which could improve performance when using From 992f0d84581d70320297be56fb10b5d9ee507ee9 Mon Sep 17 00:00:00 2001 From: Artyum Date: Fri, 27 Dec 2019 10:54:15 +0400 Subject: [PATCH 0113/7107] Update Valid.rst Changed few double-quotes to single-quotes for code consistency --- reference/constraints/Valid.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index c5bb19fa89f..5ccc42bdb29 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -157,7 +157,7 @@ stores an ``Address`` instance in the ``$address`` property:: { $metadata->addPropertyConstraint('street', new Assert\NotBlank()); $metadata->addPropertyConstraint('zipCode', new Assert\NotBlank()); - $metadata->addPropertyConstraint('zipCode', new Assert\Length(["max" => 5])); + $metadata->addPropertyConstraint('zipCode', new Assert\Length(['max' => 5])); } } @@ -172,7 +172,7 @@ stores an ``Address`` instance in the ``$address`` property:: public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('firstName', new Assert\NotBlank()); - $metadata->addPropertyConstraint('firstName', new Assert\Length(["min" => 4])); + $metadata->addPropertyConstraint('firstName', new Assert\Length(['min' => 4])); $metadata->addPropertyConstraint('lastName', new Assert\NotBlank()); } } From 2683376fd9962b211e0ac134acb70dd380de4980 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Fri, 27 Dec 2019 16:30:40 +0100 Subject: [PATCH 0114/7107] Removed Translation component documentation --- _build/redirection_map | 2 + components/form.rst | 2 +- components/translation.rst | 231 -------- components/translation/custom_formats.rst | 125 ----- .../translation/custom_message_formatter.rst | 38 -- components/translation/usage.rst | 500 ------------------ introduction/from_flat_php_to_symfony.rst | 3 +- reference/configuration/framework.rst | 4 - reference/dic_tags.rst | 10 - translation.rst | 386 ++++++++++++-- translation/xliff.rst | 44 ++ 11 files changed, 391 insertions(+), 954 deletions(-) delete mode 100644 components/translation.rst delete mode 100644 components/translation/custom_formats.rst delete mode 100644 components/translation/custom_message_formatter.rst delete mode 100644 components/translation/usage.rst create mode 100644 translation/xliff.rst diff --git a/_build/redirection_map b/_build/redirection_map index 681f00f5b99..21a74195a20 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -369,3 +369,5 @@ /contributing/community/other /contributing/community /setup/composer /setup /components/debug https://github.com/symfony/debug +/components/translation https://github.com/symfony/translation +/components/translation/usage /translation diff --git a/components/form.rst b/components/form.rst index bdc7ba20d21..84b4664d671 100644 --- a/components/form.rst +++ b/components/form.rst @@ -54,7 +54,7 @@ support for very important features: The Symfony Form component relies on other libraries to solve these problems. Most of the time you will use Twig and the Symfony :doc:`HttpFoundation `, -:doc:`Translation ` and :doc:`Validator ` +:doc:`Translation ` and :doc:`Validator ` components, but you can replace any of these with a different library of your choice. The following sections explain how to plug these libraries into the form diff --git a/components/translation.rst b/components/translation.rst deleted file mode 100644 index a578d04c34c..00000000000 --- a/components/translation.rst +++ /dev/null @@ -1,231 +0,0 @@ -.. index:: - single: Translation - single: Components; Translation - -The Translation Component -========================= - - The Translation component provides tools to internationalize your - application. - -Installation ------------- - -.. code-block:: terminal - - $ composer require symfony/translation:^3.4 - -.. include:: /components/require_autoload.rst.inc - -.. seealso:: - - This article explains how to use the Translation features as an independent - component in any PHP application. Read the :doc:`/translation` article to - learn about how to internationalize and manage the user locale in Symfony - applications. - -Constructing the Translator ---------------------------- - -The main access point of the Translation component is -:class:`Symfony\\Component\\Translation\\Translator`. Before you can use it, -you need to configure it and load the messages to translate (called *message -catalogs*). - -Configuration -~~~~~~~~~~~~~ - -The constructor of the ``Translator`` class needs one argument: The locale:: - - use Symfony\Component\Translation\Translator; - - $translator = new Translator('fr_FR'); - -.. note:: - - The locale set here is the default locale to use. You can override this - locale when translating strings. - -.. note:: - - The term *locale* refers roughly to the user's language and country. It - can be any string that your application uses to manage translations and - other format differences (e.g. currency format). The `ISO 639-1`_ - *language* code, an underscore (``_``), then the `ISO 3166-1 alpha-2`_ - *country* code (e.g. ``fr_FR`` for French/France) is recommended. - -.. _component-translator-message-catalogs: - -Loading Message Catalogs -~~~~~~~~~~~~~~~~~~~~~~~~ - -The messages are stored in message catalogs inside the ``Translator`` -class. A message catalog is like a dictionary of translations for a specific -locale. - -The Translation component uses Loader classes to load catalogs. You can load -multiple resources for the same locale, which will then be combined into one -catalog. - -The component comes with some default Loaders and you can create your own -Loader too. The default loaders are: - -* :class:`Symfony\\Component\\Translation\\Loader\\ArrayLoader` - to load - catalogs from PHP arrays. -* :class:`Symfony\\Component\\Translation\\Loader\\CsvFileLoader` - to load - catalogs from CSV files. -* :class:`Symfony\\Component\\Translation\\Loader\\IcuDatFileLoader` - to load - catalogs from resource bundles. -* :class:`Symfony\\Component\\Translation\\Loader\\IcuResFileLoader` - to load - catalogs from resource bundles. -* :class:`Symfony\\Component\\Translation\\Loader\\IniFileLoader` - to load - catalogs from ini files. -* :class:`Symfony\\Component\\Translation\\Loader\\MoFileLoader` - to load - catalogs from gettext files. -* :class:`Symfony\\Component\\Translation\\Loader\\PhpFileLoader` - to load - catalogs from PHP files. -* :class:`Symfony\\Component\\Translation\\Loader\\PoFileLoader` - to load - catalogs from gettext files. -* :class:`Symfony\\Component\\Translation\\Loader\\QtFileLoader` - to load - catalogs from QT XML files. -* :class:`Symfony\\Component\\Translation\\Loader\\XliffFileLoader` - to load - catalogs from Xliff files. -* :class:`Symfony\\Component\\Translation\\Loader\\JsonFileLoader` - to load - catalogs from JSON files. -* :class:`Symfony\\Component\\Translation\\Loader\\YamlFileLoader` - to load - catalogs from Yaml files (requires the :doc:`Yaml component`). - -All file loaders require the :doc:`Config component `. - -You can also :doc:`create your own Loader `, -in case the format is not already supported by one of the default loaders. - -At first, you should add one or more loaders to the ``Translator``:: - - // ... - $translator->addLoader('array', new ArrayLoader()); - -The first argument is the name to which you can refer the loader in the -translator and the second argument is an instance of the loader itself. After -this, you can add your resources using the correct loader. - -Loading Messages with the ``ArrayLoader`` -......................................... - -Loading messages can be done by calling -:method:`Symfony\\Component\\Translation\\Translator::addResource`. The first -argument is the loader name (this was the first argument of the ``addLoader()`` -method), the second is the resource and the third argument is the locale:: - - // ... - $translator->addResource('array', [ - 'Hello World!' => 'Bonjour', - ], 'fr_FR'); - -Loading Messages with the File Loaders -...................................... - -If you use one of the file loaders, you should also use the ``addResource()`` -method. The only difference is that you should put the file name to the resource -file as the second argument, instead of an array:: - - // ... - $translator->addLoader('yaml', new YamlFileLoader()); - $translator->addResource('yaml', 'path/to/messages.fr.yml', 'fr_FR'); - -The Translation Process ------------------------ - -To actually translate the message, the Translator uses a simple process: - -* A catalog of translated messages is loaded from translation resources defined - for the ``locale`` (e.g. ``fr_FR``). Messages from the - :ref:`components-fallback-locales` are also loaded and added to the - catalog, if they don't already exist. The end result is a large "dictionary" - of translations; - -* If the message is located in the catalog, the translation is returned. If - not, the translator returns the original message. - -You start this process by calling -:method:`Symfony\\Component\\Translation\\Translator::trans` or -:method:`Symfony\\Component\\Translation\\Translator::transChoice`. Then, the -Translator looks for the exact string inside the appropriate message catalog -and returns it (if it exists). - -.. _components-fallback-locales: - -Fallback Locales -~~~~~~~~~~~~~~~~ - -If the message is not located in the catalog of the specific locale, the -translator will look into the catalog of one or more fallback locales. For -example, assume you're trying to translate into the ``fr_FR`` locale: - -#. First, the translator looks for the translation in the ``fr_FR`` locale; - -#. If it wasn't found, the translator looks for the translation in the ``fr`` - locale; - -#. If the translation still isn't found, the translator uses the one or more - fallback locales set explicitly on the translator. - -For (3), the fallback locales can be set by calling -:method:`Symfony\\Component\\Translation\\Translator::setFallbackLocales`:: - - // ... - $translator->setFallbackLocales(['en']); - -.. _using-message-domains: - -Using Message Domains ---------------------- - -As you've seen, message files are organized into the different locales that -they translate. The message files can also be organized further into "domains". - -The domain is specified in the fourth argument of the ``addResource()`` -method. The default domain is ``messages``. For example, suppose that, for -organization, translations were split into three different domains: -``messages``, ``admin`` and ``navigation``. The French translation would be -loaded like this:: - - // ... - $translator->addLoader('xlf', new XliffFileLoader()); - - $translator->addResource('xlf', 'messages.fr.xlf', 'fr_FR'); - $translator->addResource('xlf', 'admin.fr.xlf', 'fr_FR', 'admin'); - $translator->addResource( - 'xlf', - 'navigation.fr.xlf', - 'fr_FR', - 'navigation' - ); - -When translating strings that are not in the default domain (``messages``), -you must specify the domain as the third argument of ``trans()``:: - - $translator->trans('Symfony is great', [], 'admin'); - -Symfony will now look for the message in the ``admin`` domain of the -specified locale. - -Usage ------ - -Read how to use the Translation component in :doc:`/components/translation/usage`. - -Learn More ----------- - -.. toctree:: - :maxdepth: 1 - :glob: - - /components/translation/* - /translation - /translation/* - /validation/translations - -.. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes -.. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes diff --git a/components/translation/custom_formats.rst b/components/translation/custom_formats.rst deleted file mode 100644 index 5ebd3fe8599..00000000000 --- a/components/translation/custom_formats.rst +++ /dev/null @@ -1,125 +0,0 @@ -.. index:: - single: Translation; Adding Custom Format Support - -Adding Custom Format Support -============================ - -Sometimes, you need to deal with custom formats for translation files. The -Translation component is flexible enough to support this. Just create a -loader (to load translations) and, optionally, a dumper (to dump translations). - -Imagine that you have a custom format where translation messages are defined -using one line for each translation and parentheses to wrap the key and the -message. A translation file would look like this: - -.. code-block:: text - - (welcome)(accueil) - (goodbye)(au revoir) - (hello)(bonjour) - -.. _components-translation-custom-loader: - -Creating a Custom Loader ------------------------- - -To define a custom loader that is able to read these kinds of files, you must create a -new class that implements the -:class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface`. The -:method:`Symfony\\Component\\Translation\\Loader\\LoaderInterface::load` -method will get a filename and parse it into an array. Then, it will -create the catalog that will be returned:: - - use Symfony\Component\Translation\Loader\LoaderInterface; - use Symfony\Component\Translation\MessageCatalogue; - - class MyFormatLoader implements LoaderInterface - { - public function load($resource, $locale, $domain = 'messages') - { - $messages = []; - $lines = file($resource); - - foreach ($lines as $line) { - if (preg_match('/\(([^\)]+)\)\(([^\)]+)\)/', $line, $matches)) { - $messages[$matches[1]] = $matches[2]; - } - } - - $messageCatalog = new MessageCatalogue($locale); - $messageCatalog->add($messages, $domain); - - return $messageCatalog; - } - - } - -Once created, it can be used as any other loader:: - - use Symfony\Component\Translation\Translator; - - $translator = new Translator('fr_FR'); - $translator->addLoader('my_format', new MyFormatLoader()); - - $translator->addResource('my_format', __DIR__.'/translations/messages.txt', 'fr_FR'); - - var_dump($translator->trans('welcome')); - -It will print *"accueil"*. - -.. _components-translation-custom-dumper: - -Creating a Custom Dumper ------------------------- - -It is also possible to create a custom dumper for your format, which is -useful when using the extraction commands. To do so, a new class -implementing the -:class:`Symfony\\Component\\Translation\\Dumper\\DumperInterface` -must be created. To write the dump contents into a file, extending the -:class:`Symfony\\Component\\Translation\\Dumper\\FileDumper` class -will save a few lines:: - - use Symfony\Component\Translation\Dumper\FileDumper; - use Symfony\Component\Translation\MessageCatalogue; - - class MyFormatDumper extends FileDumper - { - public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []) - { - $output = ''; - - foreach ($messages->all($domain) as $source => $target) { - $output .= sprintf("(%s)(%s)\n", $source, $target); - } - - return $output; - } - - protected function getExtension() - { - return 'txt'; - } - } - -.. sidebar:: Format a message catalog - - In some cases, you want to send the dump contents as a response instead of - writing them in files. To do this, you can use the ``formatCatalogue`` - method. In this case, you must pass the domain argument, which determines - the list of messages that should be dumped. - -The :method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::formatCatalogue` -method creates the output string, that will be used by the -:method:`Symfony\\Component\\Translation\\Dumper\\FileDumper::dump` method -of the FileDumper class to create the file. The dumper can be used like any other -built-in dumper. In the following example, the translation messages defined in the -YAML file are dumped into a text file with the custom format:: - - use Symfony\Component\Translation\Loader\YamlFileLoader; - - $loader = new YamlFileLoader(); - $translations = $loader->load(__DIR__ . '/translations/messages.fr_FR.yml' , 'fr_FR'); - - $dumper = new MyFormatDumper(); - $dumper->dump($translations, ['path' => __DIR__.'/dumps']); diff --git a/components/translation/custom_message_formatter.rst b/components/translation/custom_message_formatter.rst deleted file mode 100644 index 81e40a4c544..00000000000 --- a/components/translation/custom_message_formatter.rst +++ /dev/null @@ -1,38 +0,0 @@ -.. index:: - single: Translation; Create Custom Message formatter - -Create a Custom Message Formatter -================================= - -The default message formatter provided by Symfony solves the most common needs -when translating messages, such as using variables and pluralization. However, -if your needs are different, you can create your own message formatter. - -Message formatters are PHP classes that implement the -:class:`Symfony\\Component\\Translation\\Formatter\\MessageFormatterInterface`:: - - - use Symfony\Component\Translation\Formatter\MessageFormatterInterface; - - class MyCustomMessageFormatter implements MessageFormatterInterface - { - public function format($message, $locale, array $parameters = []) - { - // ... format the message according to your needs - - return $message; - } - } - -Now, pass an instance of this formatter as the second argument of the translator -to use it when translating messages:: - - use Symfony\Component\Translation\Translator; - - $translator = new Translator('fr_FR', new IntlMessageFormatter()); - $message = $translator->trans($originalMessage, $translationParameters); - -If you want to use this formatter to translate all messages in your Symfony -application, define a service for the formatter and use the -:ref:`translator.formatter ` option -to set that service as the default formatter. diff --git a/components/translation/usage.rst b/components/translation/usage.rst deleted file mode 100644 index 65f3442c75d..00000000000 --- a/components/translation/usage.rst +++ /dev/null @@ -1,500 +0,0 @@ -.. index:: - single: Translation; Usage - -Using the Translator -==================== - -Imagine you want to translate the string *"Symfony is great"* into French:: - - use Symfony\Component\Translation\Loader\ArrayLoader; - use Symfony\Component\Translation\Translator; - - $translator = new Translator('fr_FR'); - $translator->addLoader('array', new ArrayLoader()); - $translator->addResource('array', [ - 'Symfony is great!' => 'Symfony est super !', - ], 'fr_FR'); - - var_dump($translator->trans('Symfony is great!')); - -In this example, the message *"Symfony is great!"* will be translated into -the locale set in the constructor (``fr_FR``) if the message exists in one of -the message catalogs. - -.. _component-translation-placeholders: - -Message Placeholders --------------------- - -Sometimes, a message containing a variable needs to be translated:: - - // ... - $translated = $translator->trans('Hello '.$name); - - var_dump($translated); - -However, creating a translation for this string is impossible since the translator -will try to look up the exact message, including the variable portions -(e.g. *"Hello Ryan"* or *"Hello Fabien"*). Instead of writing a translation -for every possible iteration of the ``$name`` variable, you can replace the -variable with a "placeholder":: - - // ... - $translated = $translator->trans( - 'Hello %name%', - ['%name%' => $name] - ); - - var_dump($translated); - -Symfony will now look for a translation of the raw message (``Hello %name%``) -and *then* replace the placeholders with their values. Creating a translation -is done just as before: - -.. configuration-block:: - - .. code-block:: xml - - - - - - - Hello %name% - Bonjour %name% - - - - - - .. code-block:: yaml - - 'Hello %name%': Bonjour %name% - - .. code-block:: php - - return [ - 'Hello %name%' => 'Bonjour %name%', - ]; - -.. note:: - - The placeholders can take on any form as the full message is reconstructed - using the PHP :phpfunction:`strtr function`. But the ``%...%`` form - is recommended, to avoid problems when using Twig. - -As you've seen, creating a translation is a two-step process: - -#. Abstract the message that needs to be translated by processing it through - the ``Translator``. - -#. Create a translation for the message in each locale that you choose to - support. - -The second step is done by creating message catalogs that define the translations -for any number of different locales. - -Creating Translations ---------------------- - -The act of creating translation files is an important part of "localization" -(often abbreviated `L10n`_). Translation files consist of a series of -id-translation pairs for the given domain and locale. The source is the identifier -for the individual translation, and can be the message in the main locale (e.g. -*"Symfony is great"*) of your application or a unique identifier (e.g. -``symfony.great`` - see the sidebar below). - -Translation files can be created in several formats, XLIFF being the -recommended format. These files are parsed by one of the loader classes. - -.. configuration-block:: - - .. code-block:: xml - - - - - - - Symfony is great - J'aime Symfony - - - symfony.great - J'aime Symfony - - - - - - .. code-block:: yaml - - Symfony is great: J'aime Symfony - symfony.great: J'aime Symfony - - .. code-block:: php - - return [ - 'Symfony is great' => 'J\'aime Symfony', - 'symfony.great' => 'J\'aime Symfony', - ]; - -.. _translation-real-vs-keyword-messages: - -.. sidebar:: Using Real or Keyword Messages - - This example illustrates the two different philosophies when creating - messages to be translated:: - - $translator->trans('Symfony is great'); - - $translator->trans('symfony.great'); - - In the first method, messages are written in the language of the default - locale (English in this case). That message is then used as the "id" - when creating translations. - - In the second method, messages are actually "keywords" that convey the - idea of the message. The keyword message is then used as the "id" for - any translations. In this case, translations must be made for the default - locale (i.e. to translate ``symfony.great`` to ``Symfony is great``). - - The second method is handy because the message key won't need to be changed - in every translation file if you decide that the message should actually - read "Symfony is really great" in the default locale. - - The choice of which method to use is entirely up to you, but the "keyword" - format is often recommended for multi-language applications, whereas for - shared bundles that contain translation resources we recommend the real - message, so your application can choose to disable the translator layer - and you will see a readable message. - - Additionally, the ``php`` and ``yaml`` file formats support nested ids to - avoid repeating yourself if you use keywords instead of real text for your - ids: - - .. configuration-block:: - - .. code-block:: yaml - - symfony: - is: - great: Symfony is great - amazing: Symfony is amazing - has: - bundles: Symfony has bundles - user: - login: Login - - .. code-block:: php - - [ - 'symfony' => [ - 'is' => [ - 'great' => 'Symfony is great', - 'amazing' => 'Symfony is amazing', - ], - 'has' => [ - 'bundles' => 'Symfony has bundles', - ], - ], - 'user' => [ - 'login' => 'Login', - ], - ]; - - The multiple levels are flattened into single id/translation pairs by - adding a dot (``.``) between every level, therefore the above examples are - equivalent to the following: - - .. configuration-block:: - - .. code-block:: yaml - - symfony.is.great: Symfony is great - symfony.is.amazing: Symfony is amazing - symfony.has.bundles: Symfony has bundles - user.login: Login - - .. code-block:: php - - return [ - 'symfony.is.great' => 'Symfony is great', - 'symfony.is.amazing' => 'Symfony is amazing', - 'symfony.has.bundles' => 'Symfony has bundles', - 'user.login' => 'Login', - ]; - -.. _component-translation-pluralization: - -Pluralization -------------- - -Message pluralization is a tough topic as the rules can be quite complex. For -instance, here is the mathematical representation of the Russian pluralization -rules:: - - (($number % 10 == 1) && ($number % 100 != 11)) - ? 0 - : ((($number % 10 >= 2) - && ($number % 10 <= 4) - && (($number % 100 < 10) - || ($number % 100 >= 20))) - ? 1 - : 2 - ); - -As you can see, in Russian, you can have three different plural forms, each -given an index of 0, 1 or 2. For each form, the plural is different, and -so the translation is also different. - -When a translation has different forms due to pluralization, you can provide -all the forms as a string separated by a pipe (``|``):: - - 'There is one apple|There are %count% apples' - -To translate pluralized messages, use the -:method:`Symfony\\Component\\Translation\\Translator::transChoice` method:: - - // the %count% placeholder is assigned to the second argument... - $translator->transChoice( - 'There is one apple|There are %count% apples', - 10 - ); - - // ...but you can define more placeholders if needed - $translator->transChoice( - 'Hurry up %name%! There is one apple left.|There are %count% apples left.', - 10, - // no need to include %count% here; Symfony does that for you - ['%name%' => $user->getName()] - ); - -The second argument (``10`` in this example) is the *number* of objects being -described and is used to determine which translation to use and also to populate -the ``%count%`` placeholder. - -.. versionadded:: 3.2 - - Before Symfony 3.2, the placeholder used to select the plural (``%count%`` - in this example) must be included in the third optional argument of the - ``transChoice()`` method:: - - $translator->transChoice( - 'There is one apple|There are %count% apples', - 10, - ['%count%' => 10] - ); - - Starting from Symfony 3.2, when the only placeholder is ``%count%``, you - don't have to pass this third argument. - -Based on the given number, the translator chooses the right plural form. -In English, most words have a singular form when there is exactly one object -and a plural form for all other numbers (0, 2, 3...). So, if ``count`` is -``1``, the translator will use the first string (``There is one apple``) -as the translation. Otherwise it will use ``There are %count% apples``. - -Here is the French translation: - -.. code-block:: text - - 'Il y a %count% pomme|Il y a %count% pommes' - -Even if the string looks similar (it is made of two sub-strings separated by a -pipe), the French rules are different: the first form (no plural) is used when -``count`` is ``0`` or ``1``. So, the translator will automatically use the -first string (``Il y a %count% pomme``) when ``count`` is ``0`` or ``1``. - -Each locale has its own set of rules, with some having as many as six different -plural forms with complex rules behind which numbers map to which plural form. -The rules are quite simple for English and French, but for Russian, you'd -may want a hint to know which rule matches which string. To help translators, -you can optionally "tag" each string: - -.. code-block:: text - - 'one: There is one apple|some: There are %count% apples' - - 'none_or_one: Il y a %count% pomme|some: Il y a %count% pommes' - -The tags are really only hints for translators and don't affect the logic -used to determine which plural form to use. The tags can be any descriptive -string that ends with a colon (``:``). The tags also do not need to be the -same in the original message as in the translated one. - -.. tip:: - - As tags are optional, the translator doesn't use them (the translator will - only get a string based on its position in the string). - -Explicit Interval Pluralization -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The easiest way to pluralize a message is to let the Translator use internal -logic to choose which string to use based on a given number. Sometimes, you'll -need more control or want a different translation for specific cases (for -``0``, or when the count is negative, for example). For such cases, you can -use explicit math intervals: - -.. code-block:: text - - '{0} There are no apples|{1} There is one apple|]1,19] There are %count% apples|[20,Inf[ There are many apples' - -The intervals follow the `ISO 31-11`_ notation. The above string specifies -four different intervals: exactly ``0``, exactly ``1``, ``2-19``, and ``20`` -and higher. - -You can also mix explicit math rules and standard rules. In this case, if -the count is not matched by a specific interval, the standard rules take -effect after removing the explicit rules: - -.. code-block:: text - - '{0} There are no apples|[20,Inf[ There are many apples|There is one apple|a_few: There are %count% apples' - -For example, for ``1`` apple, the standard rule ``There is one apple`` will -be used. For ``2-19`` apples, the second standard rule -``There are %count% apples`` will be selected. - -An :class:`Symfony\\Component\\Translation\\Interval` can represent a finite set -of numbers: - -.. code-block:: text - - {1,2,3,4} - -Or numbers between two other numbers: - -.. code-block:: text - - [1, +Inf[ - ]-1,2[ - -The left delimiter can be ``[`` (inclusive) or ``]`` (exclusive). The right -delimiter can be ``[`` (exclusive) or ``]`` (inclusive). Beside numbers, you -can use ``-Inf`` and ``+Inf`` for the infinite. - -Forcing the Translator Locale ------------------------------ - -When translating a message, the Translator uses the specified locale or the -``fallback`` locale if necessary. You can also manually specify the locale to -use for translation:: - - $translator->trans( - 'Symfony is great', - [], - 'messages', - 'fr_FR' - ); - - $translator->transChoice( - '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', - 10, - [], - 'messages', - 'fr_FR' - ); - -.. note:: - - Starting from Symfony 3.2, the third argument of ``transChoice()`` is - optional when the only placeholder in use is ``%count%``. In previous - Symfony versions you needed to always define it:: - - $translator->transChoice( - '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', - 10, - ['%count%' => 10], - 'messages', - 'fr_FR' - ); - -.. _retrieving-the-message-catalogue: - -Retrieving the Message Catalog ------------------------------- - -In case you want to use the same translation catalog outside your application -(e.g. use translation on the client side), it's possible to fetch raw translation -messages. Just specify the required locale:: - - $catalog = $translator->getCatalogue('fr_FR'); - $messages = $catalog->all(); - while ($catalog = $catalog->getFallbackCatalogue()) { - $messages = array_replace_recursive($catalog->all(), $messages); - } - -The ``$messages`` variable will have the following structure:: - - [ - 'messages' => [ - 'Hello world' => 'Bonjour tout le monde', - ], - 'validators' => [ - 'Value should not be empty' => 'Valeur ne doit pas être vide', - 'Value is too long' => 'Valeur est trop long', - ], - ]; - -Adding Notes to Translation Contents ------------------------------------- - -.. versionadded:: 3.4 - - The feature to load and dump translation notes was introduced in Symfony 3.4. - -Sometimes translators need additional context to better decide how to translate -some content. This context can be provided with notes, which are a collection of -comments used to store end user readable information. The only format that -supports loading and dumping notes is XLIFF version 2.0. - -If the XLIFF 2.0 document contains ```` nodes, they are automatically -loaded/dumped when using this component inside a Symfony application: - -.. code-block:: xml - - - - - - - new - true - user login - - - original-content - translated-content - - - - - -When using the standalone Translation component, call the ``setMetadata()`` -method of the catalog and pass the notes as arrays. This is for example the -code needed to generate the previous XLIFF file:: - - use Symfony\Component\Translation\Dumper\XliffFileDumper; - use Symfony\Component\Translation\MessageCatalogue; - - $catalog = new MessageCatalogue('en_US'); - $catalog->add([ - 'original-content' => 'translated-content', - ]); - $catalog->setMetadata('original-content', ['notes' => [ - ['category' => 'state', 'content' => 'new'], - ['category' => 'approved', 'content' => 'true'], - ['category' => 'section', 'content' => 'user login', 'priority' => '1'], - ]]); - - $dumper = new XliffFileDumper(); - $dumper->formatCatalogue($catalog, 'messages', [ - 'default_locale' => 'fr_FR', - 'xliff_version' => '2.0' - ]); - -.. _`L10n`: https://en.wikipedia.org/wiki/Internationalization_and_localization -.. _`ISO 31-11`: https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals diff --git a/introduction/from_flat_php_to_symfony.rst b/introduction/from_flat_php_to_symfony.rst index 661d84767c4..13b61f7eb79 100644 --- a/introduction/from_flat_php_to_symfony.rst +++ b/introduction/from_flat_php_to_symfony.rst @@ -736,7 +736,7 @@ migrating the blog from flat PHP to Symfony has improved your life: :doc:`Templating `, :doc:`Security `, :doc:`Form `, `Validator`_ and - :doc:`Translation ` components (to name + `Translation`_ components (to name a few); * The application now enjoys **fully-flexible URLs** thanks to the Routing @@ -753,6 +753,7 @@ A good selection of `Symfony community tools`_ can be found on GitHub. .. _`Model-View-Controller`: https://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller .. _`Doctrine`: http://www.doctrine-project.org +.. _Translation: https://github.com/symfony/translation .. _`Composer`: https://getcomposer.org .. _`download Composer`: https://getcomposer.org/download/ .. _`Validator`: https://github.com/symfony/validator diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index b421a6c5d3a..a0003f08062 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1726,10 +1726,6 @@ formatter The ID of the service used to format translation messages. The service class must implement the :class:`Symfony\\Component\\Translation\\Formatter\\MessageFormatterInterface`. -.. seealso:: - - For more details, see :doc:`/components/translation/custom_message_formatter`. - .. _reference-translator-paths: paths diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 35a44883808..0ff2dbf9c1b 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -1045,11 +1045,6 @@ translation.loader By default, translations are loaded from the filesystem in a variety of different formats (YAML, XLIFF, PHP, etc). -.. seealso:: - - Learn how to :ref:`load custom formats ` - in the components section. - Now, register your loader as a service and tag it with ``translation.loader``: .. configuration-block:: @@ -1235,11 +1230,6 @@ This is the name that's used to determine which dumper should be used. $container->register(JsonFileDumper::class) ->addTag('translation.dumper', ['alias' => 'json']); -.. seealso:: - - Learn how to :ref:`dump to custom formats ` - in the components section. - .. _reference-dic-tags-twig-extension: twig.extension diff --git a/translation.rst b/translation.rst index 95ed03e51bb..66b6b58a1b2 100644 --- a/translation.rst +++ b/translation.rst @@ -28,10 +28,7 @@ into the language of the user:: *language* code, an underscore (``_``), then the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for French/France) is recommended. -In this article, you'll learn how to use the Translation component in the -Symfony Framework. You can read the -:doc:`Translation component documentation ` -to learn even more. Overall, the process has several steps: +The translation process has several steps: #. :ref:`Enable and configure ` Symfony's translation service; @@ -122,10 +119,15 @@ When this code is executed, Symfony will attempt to translate the message you need to tell Symfony how to translate the message via a "translation resource", which is usually a file that contains a collection of translations for a given locale. This "dictionary" of translations can be created in several -different formats, XLIFF being the recommended format: +different formats: .. configuration-block:: + .. code-block:: yaml + + # messages.fr.yml + Symfony is great: J'aime Symfony + .. code-block:: xml @@ -141,11 +143,6 @@ different formats, XLIFF being the recommended format: - .. code-block:: yaml - - # messages.fr.yml - Symfony is great: J'aime Symfony - .. code-block:: php // messages.fr.php @@ -160,27 +157,121 @@ Now, if the language of the user's locale is French (e.g. ``fr_FR`` or ``fr_BE`` the message will be translated into ``J'aime Symfony``. You can also translate the message inside your :ref:`templates `. +.. _translation-real-vs-keyword-messages: + +.. sidebar:: Using Real or Keyword Messages + + This example illustrates the two different philosophies when creating + messages to be translated:: + + $translator->trans('Symfony is great'); + + $translator->trans('symfony.great'); + + In the first method, messages are written in the language of the default + locale (English in this case). That message is then used as the "id" + when creating translations. + + In the second method, messages are actually "keywords" that convey the + idea of the message. The keyword message is then used as the "id" for + any translations. In this case, translations must be made for the default + locale (i.e. to translate ``symfony.great`` to ``Symfony is great``). + + The second method is handy because the message key won't need to be changed + in every translation file if you decide that the message should actually + read "Symfony is really great" in the default locale. + + The choice of which method to use is entirely up to you, but the "keyword" + format is often recommended for multi-language applications, whereas for + shared bundles that contain translation resources we recommend the real + message, so your application can choose to disable the translator layer + and you will see a readable message. + + Additionally, the ``php`` and ``yaml`` file formats support nested ids to + avoid repeating yourself if you use keywords instead of real text for your + ids: + + .. configuration-block:: + + .. code-block:: yaml + + symfony: + is: + # id is symfony.is.great + great: Symfony is great + # id is symfony.is.amazing + amazing: Symfony is amazing + has: + # id is symfony.has.bundles + bundles: Symfony has bundles + user: + # id is user.login + login: Login + + .. code-block:: php + + [ + 'symfony' => [ + 'is' => [ + // id is symfony.is.great + 'great' => 'Symfony is great', + // id is symfony.is.amazing + 'amazing' => 'Symfony is amazing', + ], + 'has' => [ + // id is symfony.has.bundles + 'bundles' => 'Symfony has bundles', + ], + ], + 'user' => [ + // id is user.login + 'login' => 'Login', + ], + ]; + The Translation Process ~~~~~~~~~~~~~~~~~~~~~~~ To actually translate the message, Symfony uses a simple process: -* The ``locale`` of the current user, which is stored on the request is determined; +#. The ``locale`` of the current user, which is stored on the request is determined; -* A catalog (e.g. big collection) of translated messages is loaded from translation - resources defined for the ``locale`` (e.g. ``fr_FR``). Messages from the - :ref:`fallback locale ` are also loaded and - added to the catalog if they don't already exist. The end result is a large - "dictionary" of translations. +#. A catalog (i.e. big collection) of translated messages is loaded from translation + resources defined for the ``locale`` (e.g. ``fr_FR``). Messages from the + :ref:`fallback locale ` are also loaded and + added to the catalog if they don't already exist. The end result is a large + "dictionary" of translations. -* If the message is located in the catalog, the translation is returned. If - not, the translator returns the original message. +#. If the message is located in the catalog, the translation is returned. If + not, the translator returns the original message. When using the ``trans()`` method, Symfony looks for the exact string inside the appropriate message catalog and returns it (if it exists). +.. _using-message-domains: + +Using Message Domains +~~~~~~~~~~~~~~~~~~~~~ + +As you've seen, message files are organized into the different locales that +they translate. The message files can also be organized further into "domains". + +The domain is the filename without the extension. The default domain is +``messages``. Translations can for example be split into three different +domains: ``messages``, ``admin`` and ``navigation``. The French translation +would be organized in these files: + +* ``app/Resources/translations/messages.fr.yml`` +* ``app/Resources/translations/admin.fr.yml`` +* ``app/Resources/translations/navigation.fr.yml`` + +When translating strings that are not in the default domain (``messages``), +you must specify the domain as the third argument of ``trans()``:: + + $translator->trans('Symfony is great', [], 'admin'); + Message Placeholders --------------------- +~~~~~~~~~~~~~~~~~~~~ Sometimes, a message containing a variable needs to be translated:: @@ -193,10 +284,65 @@ Sometimes, a message containing a variable needs to be translated:: However, creating a translation for this string is impossible since the translator will try to look up the exact message, including the variable portions -(e.g. *"Hello Ryan"* or *"Hello Fabien"*). +(e.g. *"Hello Ryan"* or *"Hello Fabien"*). Instead of writing a translation +for every possible iteration of the ``$name`` variable, you can replace the +variable with a "placeholder":: + + // ... + + public function indexAction($name) + { + $translated = $this->get('translator')->trans('Hello %name%'); + + // ... + } + +Symfony will now look for a translation of the raw message (``Hello %name%``) +and *then* replace the placeholders with their values. Creating a translation +is done just as before: + +.. configuration-block:: + + .. code-block:: yaml + + 'Hello %name%': Bonjour %name% + + .. code-block:: xml + + + + + + + Hello %name% + Bonjour %name% + + + + + + .. code-block:: php + + return [ + 'Hello %name%' => 'Bonjour %name%', + ]; -For details on how to handle this situation, see :ref:`component-translation-placeholders` -in the components documentation. For how to do this in templates, see :ref:`translation-tags`. +.. note:: + + The placeholders can take on any form as the full message is reconstructed + using the PHP :phpfunction:`strtr function`. But the ``%...%`` form + is recommended, to avoid problems when using Twig. + +As you've seen, creating a translation is a two-step process: + +#. Abstract the message that needs to be translated by processing it through + the ``Translator``. + +#. Create a translation for the message in each locale that you choose to + support. + +The second step is done by creating message catalogs that define the translations +for any number of different locales. Pluralization ------------- @@ -209,11 +355,133 @@ plural, based on some variable: There is one apple. There are 5 apples. -To handle this, use the :method:`Symfony\\Component\\Translation\\Translator::transChoice` +When a translation has different forms due to pluralization, you can provide +all the forms as a string separated by a pipe (``|``):: + + 'There is one apple|There are %count% apples' + +To translate these messages, use the +:method:`Symfony\\Component\\Translation\\Translator::transChoice` method or the ``transchoice`` tag/filter in your :ref:`template `. +To translate pluralized messages, use the +:method:`Symfony\\Component\\Translation\\Translator::transChoice` method:: + + // the %count% placeholder is assigned to the second argument... + $this->get('translator')->transChoice( + 'There is one apple|There are %count% apples', + 10 + ); + + // ...but you can define more placeholders if needed + $this->get('translator')->transChoice( + 'Hurry up %name%! There is one apple left.|There are %count% apples left.', + 10, + // no need to include %count% here; Symfony does that for you + ['%name%' => $user->getName()] + ); + +The second argument (``10`` in this example) is the *number* of objects being +described and is used to determine which translation to use and also to populate +the ``%count%`` placeholder. + +.. versionadded:: 3.2 + + Before Symfony 3.2, the placeholder used to select the plural (``%count%`` + in this example) must be included in the third optional argument of the + ``transChoice()`` method:: + + $translator->transChoice( + 'There is one apple|There are %count% apples', + 10, + ['%count%' => 10] + ); + + Starting from Symfony 3.2, when the only placeholder is ``%count%``, you + don't have to pass this third argument. + +Based on the given number, the translator chooses the right plural form. +In English, most words have a singular form when there is exactly one object +and a plural form for all other numbers (0, 2, 3...). So, if ``count`` is +``1``, the translator will use the first string (``There is one apple``) +as the translation. Otherwise it will use ``There are %count% apples``. + +Here is the French translation:: + + 'Il y a %count% pomme|Il y a %count% pommes' + +Even if the string looks similar (it is made of two sub-strings separated by a +pipe), the French rules are different: the first form (no plural) is used when +``count`` is ``0`` or ``1``. So, the translator will automatically use the +first string (``Il y a %count% pomme``) when ``count`` is ``0`` or ``1``. -For much more information, see :ref:`component-translation-pluralization` -in the Translation component documentation. +Each locale has its own set of rules, with some having as many as six different +plural forms with complex rules behind which numbers map to which plural form. +The rules are quite simple for English and French, but for Russian, you'd +may want a hint to know which rule matches which string. To help translators, +you can optionally "tag" each string: + +.. code-block:: text + + 'one: There is one apple|some: There are %count% apples' + + 'none_or_one: Il y a %count% pomme|some: Il y a %count% pommes' + +The tags are really only hints for translators and don't affect the logic +used to determine which plural form to use. The tags can be any descriptive +string that ends with a colon (``:``). The tags also do not need to be the +same in the original message as in the translated one. + +.. tip:: + + As tags are optional, the translator doesn't use them (the translator will + only get a string based on its position in the string). + +Explicit Interval Pluralization +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The easiest way to pluralize a message is to let the Translator use internal +logic to choose which string to use based on a given number. Sometimes, you'll +need more control or want a different translation for specific cases (for +``0``, or when the count is negative, for example). For such cases, you can +use explicit math intervals: + +.. code-block:: text + + '{0} There are no apples|{1} There is one apple|]1,19] There are %count% apples|[20,Inf[ There are many apples' + +The intervals follow the `ISO 31-11`_ notation. The above string specifies +four different intervals: exactly ``0``, exactly ``1``, ``2-19``, and ``20`` +and higher. + +You can also mix explicit math rules and standard rules. In this case, if +the count is not matched by a specific interval, the standard rules take +effect after removing the explicit rules: + +.. code-block:: text + + '{0} There are no apples|[20,Inf[ There are many apples|There is one apple|a_few: There are %count% apples' + +For example, for ``1`` apple, the standard rule ``There is one apple`` will +be used. For ``2-19`` apples, the second standard rule +``There are %count% apples`` will be selected. + +An :class:`Symfony\\Component\\Translation\\Interval` can represent a finite set +of numbers: + +.. code-block:: text + + {1,2,3,4} + +Or numbers between two other numbers: + +.. code-block:: text + + [1, +Inf[ + ]-1,2[ + +The left delimiter can be ``[`` (inclusive) or ``]`` (exclusive). The right +delimiter can be ``[`` (exclusive) or ``]`` (inclusive). Beside numbers, you +can use ``-Inf`` and ``+Inf`` for the infinite. Translations in Templates ------------------------- @@ -326,6 +594,28 @@ The translator service is accessible in PHP templates through the ['%count%' => 10] ) ?> +Forcing the Translator Locale +----------------------------- + +When translating a message, the translator uses the specified locale or the +``fallback`` locale if necessary. You can also manually specify the locale to +use for translation:: + + $translator->trans( + 'Symfony is great', + [], + 'messages', + 'fr_FR' + ); + + $translator->transChoice( + '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', + 10, + [], + 'messages', + 'fr_FR' + ); + Extracting Translation Contents and Updating Catalogs Automatically ------------------------------------------------------------------- @@ -388,15 +678,32 @@ must be named according to the following path: ``domain.locale.loader``: ``php``, ``yml``, etc). The loader can be the name of any registered loader. By default, Symfony -provides many loaders, including: - -* ``xlf``: XLIFF file; -* ``php``: PHP file; -* ``yml``: YAML file. +provides many loaders: + +* ``.yaml``: YAML file +* ``.xlf``: XLIFF file; +* ``.php``: Returning a PHP array; +* ``.csv``: CSV file; +* ``.json``: JSON file; +* ``.ini``: INI file; +* ``.dat``, ``.res``: ICU resource bundle; +* ``.mo``: Machine object format; +* ``.po``: Portable object format; +* ``.qt``: QT Translations XML file; The choice of which loader to use is entirely up to you and is a matter of -taste. The recommended option is to use ``xlf`` for translations. -For more options, see :ref:`component-translator-message-catalogs`. +taste. The recommended option is to use YAML for simple projects and use XLIFF +if you're generating translations with specialized programs or teams. + +.. caution:: + + Each time you create a *new* message catalog (or install a bundle + that includes a translation catalog), be sure to clear your cache so + that Symfony can discover the new translation resources: + + .. code-block:: terminal + + $ php bin/console cache:clear .. note:: @@ -451,16 +758,6 @@ For more options, see :ref:`component-translator-message-catalogs`. :class:`Symfony\\Component\\Translation\\Loader\\LoaderInterface` interface. See the :ref:`dic-tags-translation-loader` tag for more information. -.. caution:: - - Each time you create a *new* translation resource (or install a bundle - that includes a translation resource), be sure to clear your cache so - that Symfony can discover the new translation resources: - - .. code-block:: terminal - - $ php bin/console cache:clear - .. _translation-fallback: Fallback Translation Locales @@ -515,8 +812,7 @@ steps: * Abstract messages in your application by wrapping each in either the :method:`Symfony\\Component\\Translation\\Translator::trans` or - :method:`Symfony\\Component\\Translation\\Translator::transChoice` methods - (learn about this in :doc:`/components/translation/usage`); + :method:`Symfony\\Component\\Translation\\Translator::transChoice` methods; * Translate each message into multiple locales by creating translation message files. Symfony discovers and processes each file because its name follows @@ -533,9 +829,11 @@ Learn more :glob: /translation/* + /validation/translations .. _`i18n`: https://en.wikipedia.org/wiki/Internationalization_and_localization .. _`ISO 3166-1 alpha-2`: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes +.. _`ISO 31-11`: https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals .. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes .. _`Translatable Extension`: http://atlantic18.github.io/DoctrineExtensions/doc/translatable.html .. _`Translatable Behavior`: https://github.com/KnpLabs/DoctrineBehaviors diff --git a/translation/xliff.rst b/translation/xliff.rst new file mode 100644 index 00000000000..c81620929b8 --- /dev/null +++ b/translation/xliff.rst @@ -0,0 +1,44 @@ +The XLIFF format +================ + +Most professional translation tools support XLIFF_. These files use the XML +format and are supported by Symfony by default. Besides supporting +:doc:`all Symfony translation features `, the XLIFF format also +has some specific features. + +Adding Notes to Translation Contents +------------------------------------ + +.. versionadded:: 3.4 + + The feature to load and dump translation notes was introduced in Symfony 3.4. + +Sometimes translators need additional context to better decide how to translate +some content. This context can be provided with notes, which are a collection of +comments used to store end user readable information. The only format that +supports loading and dumping notes is XLIFF version 2. + +If the XLIFF 2.0 document contains ```` nodes, they are automatically +loaded/dumped inside a Symfony application: + +.. code-block:: xml + + + + + + + new + true + user login + + + original-content + translated-content + + + + + +.. _XLIFF: http://docs.oasis-open.org/xliff/xliff-core/v2.1/xliff-core-v2.1.html From ea43e0dc50e7d9fc9a53a60ff853373c843c8a3b Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Thu, 26 Dec 2019 20:40:20 +0100 Subject: [PATCH 0115/7107] Document PasswordAuthenticatedInterface --- security/password_migration.rst | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/security/password_migration.rst b/security/password_migration.rst index 7ce2d08d153..45351bb3d8c 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -119,14 +119,41 @@ Upgrade the Password Upon successful login, the Security system checks whether a better algorithm is available to hash the user's password. If it is, it'll hash the correct -password using the new hash. You can enable this behavior by implementing how -this newly hashed password should be stored: +password using the new hash. If you use a Guard authenticator, you first need to +`provide the original password to the Security system `_. + +You can enable the upgrade behavior by implementing how this newly hashed +password should be stored: * `When using Doctrine's entity user provider `_ * `When using a custom user provider `_ After this, you're done and passwords are always hashed as secure as possible! +Provide the Password when using Guard +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When you're using a custom :doc:`guard authenticator `, +you need to implement :class:`Symfony\\Component\\Security\\Guard\\PasswordAuthenticatedInterface`. +This interface defines a ``getPassword()`` method that returns the password +for this login request. This password is used in the migration process:: + + // src/Security/CustomAuthenticator.php + namespace App\Security; + + use Symfony\Component\Security\Guard\PasswordAuthenticatedInterface; + // ... + + class CustomAuthenticator extends AbstractGuardAuthenticator implements PasswordAuthenticatedInterface + { + // ... + + public function getPassword($credentials): ?string + { + return $credentials['password']; + } + } + Upgrade the Password when using Doctrine ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From aa34b5909e59cc682ed1655e1ad998c09010bb42 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Sat, 28 Dec 2019 14:59:53 +0100 Subject: [PATCH 0116/7107] Update user_checkers.rst --- security/user_checkers.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/security/user_checkers.rst b/security/user_checkers.rst index 24d0e4051e1..c188139d9ec 100644 --- a/security/user_checkers.rst +++ b/security/user_checkers.rst @@ -23,7 +23,6 @@ are not met, an exception should be thrown which extends the use App\Exception\AccountDeletedException; use App\Security\User as AppUser; use Symfony\Component\Security\Core\Exception\AccountExpiredException; - use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; use Symfony\Component\Security\Core\User\UserCheckerInterface; use Symfony\Component\Security\Core\User\UserInterface; From ff6ce214557474e03139104657c366d505518f7b Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Sat, 28 Dec 2019 15:09:04 +0100 Subject: [PATCH 0117/7107] Update multiple_guard_authenticators.rst --- security/multiple_guard_authenticators.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/multiple_guard_authenticators.rst b/security/multiple_guard_authenticators.rst index 53e8972557c..356015681b0 100644 --- a/security/multiple_guard_authenticators.rst +++ b/security/multiple_guard_authenticators.rst @@ -68,7 +68,7 @@ This is how your security configuration can look in action: 'default' => [ 'anonymous' => null, 'guard' => [ - 'entry_point' => '', + 'entry_point' => LoginFormAuthenticator::class, 'authenticators' => [ LoginFormAuthenticator::class, FacebookConnectAuthenticator::class, From 9a4d9cdbaab623b52da8945e22b74b14819744fe Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Sun, 29 Dec 2019 00:14:30 +0100 Subject: [PATCH 0118/7107] Add documentation for new reverse() method --- components/string.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/components/string.rst b/components/string.rst index 068f7fc02a2..dc49c565f31 100644 --- a/components/string.rst +++ b/components/string.rst @@ -358,6 +358,19 @@ Methods to Join, Split and Truncate // breaks the string into pieces of the length given as argument u('0123456789')->chunk(3); // ['012', '345', '678', '9'] +.. versionadded:: 5.1 + + The reverse() method was introduced in Symfony 5.1. + +Method to Reverse +~~~~~~~~~~~~~~~~~ + +:: + + // reverses the order of characters in a string + u('foo bar')->reverse(); // 'rab oof' + u('さよなら')->reverse(); // 'らなよさ' + Methods Added by ByteString ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 50898ae6fe413bb034bfa1b82153b523a46e7be4 Mon Sep 17 00:00:00 2001 From: HypeMC Date: Tue, 31 Dec 2019 16:25:53 +0100 Subject: [PATCH 0119/7107] Replace references to Goutte with HttpBrowser --- components/browser_kit.rst | 7 ++++--- components/dom_crawler.rst | 16 +++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index 1fa554a5c0f..8108bf8f816 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -59,9 +59,10 @@ This method accepts a request and should return a response:: } For a simple implementation of a browser based on the HTTP layer, have a look -at `Goutte`_. For an implementation based on ``HttpKernelInterface``, have -a look at the :class:`Symfony\\Component\\HttpKernel\\Client` provided by -the :doc:`HttpKernel component `. +at the :class:`Symfony\\Component\\BrowserKit\\HttpBrowser` provided by +:ref:`this component `. For an implementation based +on ``HttpKernelInterface``, have a look at the :class:`Symfony\\Component\\HttpKernel\\Client` +provided by the :doc:`HttpKernel component `. Making Requests ~~~~~~~~~~~~~~~ diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index cdf2d6faa0b..33715b56e28 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -581,15 +581,18 @@ of the information you need to create a POST request for the form:: // now use some HTTP client and post using this information -One great example of an integrated system that uses all of this is `Goutte`_. -Goutte understands the Symfony Crawler object and can use it to submit forms +One great example of an integrated system that uses all of this is +the :class:`Symfony\\Component\\BrowserKit\\HttpBrowser` provided by +the :doc:`BrowserKit component `. +It understands the Symfony Crawler object and can use it to submit forms directly:: - use Goutte\Client; + use Symfony\Component\BrowserKit\HttpBrowser; + use Symfony\Component\HttpClient\HttpClient; // makes a real request to an external site - $client = new Client(); - $crawler = $client->request('GET', 'https://github.com/login'); + $browser = new HttpBrowser(HttpClient::create()); + $crawler = $browser->request('GET', 'https://github.com/login'); // select the form and fill in some values $form = $crawler->selectButton('Sign in')->form(); @@ -597,7 +600,7 @@ directly:: $form['password'] = 'anypass'; // submits the given form - $crawler = $client->submit($form); + $crawler = $browser->submit($form); .. _components-dom-crawler-invalid: @@ -622,5 +625,4 @@ Learn more * :doc:`/testing` * :doc:`/components/css_selector` -.. _`Goutte`: https://github.com/FriendsOfPHP/Goutte .. _`html5-php library`: https://github.com/Masterminds/html5-php From 8c68270589aa1a4e21e48e1ce655766083038f2a Mon Sep 17 00:00:00 2001 From: Wojciech M Date: Tue, 31 Dec 2019 16:46:23 +0100 Subject: [PATCH 0120/7107] add url to bootstrap.php for older versions doc states that "changes can be made to any Symfony 3.4 or higher app", which requires different bootstrap.php --- configuration/dot-env-changes.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/configuration/dot-env-changes.rst b/configuration/dot-env-changes.rst index 280a40c8d63..c0161b18a23 100644 --- a/configuration/dot-env-changes.rst +++ b/configuration/dot-env-changes.rst @@ -47,7 +47,8 @@ changes can be made to any Symfony 3.4 or higher app: #. Create a new `config/bootstrap.php`_ file in your project. This file loads Composer's autoloader and loads all the ``.env`` files as needed (note: in an earlier recipe, - this file was called ``src/.bootstrap.php``). + this file was called ``src/.bootstrap.php``). + For Symfony 3.3 - 4.1 please use `3.3/config/bootstrap.php`_ #. Update your `public/index.php`_ (`index.php diff`_) file to load the new ``config/bootstrap.php`` file. If you've customized this file, make sure to keep those changes (but use @@ -89,6 +90,7 @@ changes can be made to any Symfony 3.4 or higher app: file. .. _`config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/config/bootstrap.php +.. _`3.3/config/bootstrap.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/3.3/config/bootstrap.php .. _`public/index.php`: https://github.com/symfony/recipes/blob/master/symfony/framework-bundle/4.2/public/index.php .. _`index.php diff`: https://github.com/symfony/recipes/compare/8a4e5555e30d5dff64275e2788a901f31a214e79...86e2b6795c455f026e5ab0cba2aff2c7a18511f7#diff-7d73eabd1e5eb7d969ddf9a7ce94f954 .. _`bin/console`: https://github.com/symfony/recipes/blob/master/symfony/console/3.3/bin/console From 122e48788935104f48f7fd21e310f935544f9c56 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 1 Jan 2020 11:09:07 +0100 Subject: [PATCH 0121/7107] backport some tweaks from 5.0 docs --- security/guard_authentication.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index 734a8c3efac..14159a25cc0 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -333,7 +333,7 @@ Finally, configure your ``firewalls`` key in ``security.yml`` to use this authen 'logout' => true, 'guard' => [ 'authenticators' => [ - TokenAuthenticator::class + TokenAuthenticator::class, ], ], // ... @@ -419,7 +419,7 @@ Each authenticator needs the following methods: the user authenticate (e.g. a 401 response that says "token is missing!"). **supportsRememberMe()** - If you want to support "remember me" functionality, return true from this method. + If you want to support "remember me" functionality, return ``true`` from this method. You will still need to activate ``remember_me`` under your firewall for it to work. Since this is a stateless API, you do not want to support "remember me" functionality in this example. @@ -428,7 +428,8 @@ Each authenticator needs the following methods: If you are implementing the :class:`Symfony\\Component\\Security\\Guard\\AuthenticatorInterface` instead of extending the :class:`Symfony\\Component\\Security\\Guard\\AbstractGuardAuthenticator` class, you have to implement this method. It will be called - after a successful authentication to create and return the token + after a successful authentication to create and return the token (a + class implementing :class:`Symfony\\Component\\Security\\Guard\\Token\\GuardTokenInterface`) for the user, who was supplied as the first argument. The picture below shows how Symfony calls Guard Authenticator methods: From 43f4422098f6145894386c90181962dc56cbcd48 Mon Sep 17 00:00:00 2001 From: Mikhail Kamarouski <4569734+boajer@users.noreply.github.com> Date: Tue, 24 Dec 2019 15:41:41 +0300 Subject: [PATCH 0122/7107] Update injection_types.rst Typo fixed in the code snippet --- service_container/injection_types.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container/injection_types.rst b/service_container/injection_types.rst index fd383ff11ed..2a728de4879 100644 --- a/service_container/injection_types.rst +++ b/service_container/injection_types.rst @@ -353,7 +353,7 @@ Another possibility is setting public fields of the class directly:: return function(ContainerConfigurator $configurator) { $services = $configurator->services(); - $services->set('app.newsletter_manager, NewsletterManager::class) + $services->set('app.newsletter_manager', NewsletterManager::class) ->property('mailer', ref('mailer')); }; From 3d26e1f1ecc79a4806ad4e2cc212725e6abb600b Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 1 Jan 2020 11:20:18 +0100 Subject: [PATCH 0123/7107] minor tweaks --- security/password_migration.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/password_migration.rst b/security/password_migration.rst index 7ba3c6e43cd..5565677133c 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -120,7 +120,7 @@ Upgrade the Password Upon successful login, the Security system checks whether a better algorithm is available to hash the user's password. If it is, it'll hash the correct password using the new hash. If you use a Guard authenticator, you first need to -`provide the original password to the Security system `_. +`provide the original password to the Security system `_. You can enable the upgrade behavior by implementing how this newly hashed password should be stored: @@ -150,7 +150,7 @@ for this login request. This password is used in the migration process:: public function getPassword($credentials): ?string { - return $credentials['password']; + return $credentials['password'] ?? null; } } From 4c73d383300f2e63638c336d27fb4131174d00a5 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Sat, 21 Dec 2019 20:31:18 +0100 Subject: [PATCH 0124/7107] Update custom-transport.rst --- messenger/custom-transport.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger/custom-transport.rst b/messenger/custom-transport.rst index 045f8ffa389..09b356407ac 100644 --- a/messenger/custom-transport.rst +++ b/messenger/custom-transport.rst @@ -17,7 +17,7 @@ DSN. You will need a transport factory:: class YourTransportFactory implements TransportFactoryInterface { - public function createTransport(string $dsn, array $options): TransportInterface + public function createTransport(string $dsn, array $options, SerializerInterface $serializer): TransportInterface { return new YourTransport(/* ... */); } From 1a1e9c6b8d2046616aaf2bdce5a39d617037f9b6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 1 Jan 2020 11:24:31 +0100 Subject: [PATCH 0125/7107] [#12835] add use statement --- messenger/custom-transport.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/messenger/custom-transport.rst b/messenger/custom-transport.rst index 09b356407ac..e0fbcb3ca23 100644 --- a/messenger/custom-transport.rst +++ b/messenger/custom-transport.rst @@ -12,6 +12,7 @@ DSN. You will need a transport factory:: use Symfony\Component\Messenger\Transport\Receiver\ReceiverInterface; use Symfony\Component\Messenger\Transport\Sender\SenderInterface; + use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface; use Symfony\Component\Messenger\Transport\TransportFactoryInterface; use Symfony\Component\Messenger\Transport\TransportInterface; From d507793989968a3e9216faa6706dcdedb7cb0c0e Mon Sep 17 00:00:00 2001 From: fancyweb Date: Wed, 1 Jan 2020 15:19:04 +0100 Subject: [PATCH 0126/7107] [String] Replace codePoint by codePointsAt --- components/string.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/string.rst b/components/string.rst index 068f7fc02a2..b388e02a2d1 100644 --- a/components/string.rst +++ b/components/string.rst @@ -388,8 +388,8 @@ objects:: // returns the value of the code point stored at the given position // (code points of 'नमस्ते' graphemes = [2344, 2350, 2360, 2340] - u('नमस्ते')->codePoint(0); // 2344 - u('नमस्ते')->codePoint(2); // 2360 + u('नमस्ते')->codePointsAt(0); // 2344 + u('नमस्ते')->codePointsAt(2); // 2360 `Unicode equivalence`_ is the specification by the Unicode standard that different sequences of code points represent the same character. For example, From caecbec6dbad5801bcf6b1c87256f63d2eaa693b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 08:45:12 +0100 Subject: [PATCH 0127/7107] Minor tweak --- security/password_migration.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/security/password_migration.rst b/security/password_migration.rst index 5565677133c..d71e8754275 100644 --- a/security/password_migration.rst +++ b/security/password_migration.rst @@ -125,8 +125,8 @@ password using the new hash. If you use a Guard authenticator, you first need to You can enable the upgrade behavior by implementing how this newly hashed password should be stored: -* `When using Doctrine's entity user provider `_ -* `When using a custom user provider `_ +* `When using Doctrine's entity user provider `_ +* `When using a custom user provider `_ After this, you're done and passwords are always hashed as secure as possible! @@ -150,7 +150,7 @@ for this login request. This password is used in the migration process:: public function getPassword($credentials): ?string { - return $credentials['password'] ?? null; + return $credentials['password']; } } From 9fb4110b7ed54d0b3aa249cdcbfaf593ebb2b1ac Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 08:53:42 +0100 Subject: [PATCH 0128/7107] Minor tweaks --- components/string.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/string.rst b/components/string.rst index b388e02a2d1..83a3f875491 100644 --- a/components/string.rst +++ b/components/string.rst @@ -386,10 +386,10 @@ objects:: u('さよなら')->ascii(); // 'sayonara' u('спасибо')->ascii(); // 'spasibo' - // returns the value of the code point stored at the given position + // returns an array with the code point or points stored at the given position // (code points of 'नमस्ते' graphemes = [2344, 2350, 2360, 2340] - u('नमस्ते')->codePointsAt(0); // 2344 - u('नमस्ते')->codePointsAt(2); // 2360 + u('नमस्ते')->codePointsAt(0); // [2344] + u('नमस्ते')->codePointsAt(2); // [2360] `Unicode equivalence`_ is the specification by the Unicode standard that different sequences of code points represent the same character. For example, From 4874152fe4585e33847f0c71497fdcb0fe5a7522 Mon Sep 17 00:00:00 2001 From: Zairig Imad Date: Tue, 31 Dec 2019 19:24:55 +0100 Subject: [PATCH 0129/7107] SMimeEncrypter add Tip --- mailer.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mailer.rst b/mailer.rst index e7b1794eb30..eff89f78027 100644 --- a/mailer.rst +++ b/mailer.rst @@ -656,6 +656,11 @@ and it will select the appropriate certificate depending on the ``To`` option:: $firstEncryptedEmail = $encrypter->encrypt($firstEmail); $secondEncryptedEmail = $encrypter->encrypt($secondEmail); +.. tip:: + + The ``SMimeEncrypter`` class defines a second argument to choose + an algorithm to encrypt the message. the cipher must be one of these PHP constants: https://www.php.net/manual/en/openssl.ciphers.php + Sending Messages Async ---------------------- From ad4f1d21b0c1219f10d0cf3b84b48ab8d4f7ec74 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 09:18:12 +0100 Subject: [PATCH 0130/7107] Tweaks --- mailer.rst | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/mailer.rst b/mailer.rst index eff89f78027..691ea2d83c6 100644 --- a/mailer.rst +++ b/mailer.rst @@ -647,6 +647,8 @@ and it will select the appropriate certificate depending on the ``To`` option:: // ... ->to('john@example.com'); + // the second optional argument of SMimeEncrypter defines which encryption algorithm is used + // (it must be one of these constants: https://www.php.net/manual/en/openssl.ciphers.php) $encrypter = new SMimeEncrypter([ // key = email recipient; value = path to the certificate file 'jane@example.com' => '/path/to/first-certificate.crt', @@ -656,11 +658,6 @@ and it will select the appropriate certificate depending on the ``To`` option:: $firstEncryptedEmail = $encrypter->encrypt($firstEmail); $secondEncryptedEmail = $encrypter->encrypt($secondEmail); -.. tip:: - - The ``SMimeEncrypter`` class defines a second argument to choose - an algorithm to encrypt the message. the cipher must be one of these PHP constants: https://www.php.net/manual/en/openssl.ciphers.php - Sending Messages Async ---------------------- From 35130effcd4e1319770c02ae94e253e53e7da66f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 09:50:57 +0100 Subject: [PATCH 0131/7107] Minor tweaks --- configuration/dot-env-changes.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configuration/dot-env-changes.rst b/configuration/dot-env-changes.rst index c0161b18a23..7484c4e1603 100644 --- a/configuration/dot-env-changes.rst +++ b/configuration/dot-env-changes.rst @@ -47,8 +47,8 @@ changes can be made to any Symfony 3.4 or higher app: #. Create a new `config/bootstrap.php`_ file in your project. This file loads Composer's autoloader and loads all the ``.env`` files as needed (note: in an earlier recipe, - this file was called ``src/.bootstrap.php``). - For Symfony 3.3 - 4.1 please use `3.3/config/bootstrap.php`_ + this file was called ``src/.bootstrap.php``; if you are upgrading from Symfony 3.3 + or 4.1, use the `3.3/config/bootstrap.php`_ file instead). #. Update your `public/index.php`_ (`index.php diff`_) file to load the new ``config/bootstrap.php`` file. If you've customized this file, make sure to keep those changes (but use From 17cbf7f0e3c6bce14b32bd094ee779e27637e53e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 10:31:32 +0100 Subject: [PATCH 0132/7107] Minor tweaks --- components/string.rst | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/components/string.rst b/components/string.rst index 6f27ad6ffab..c678a3cb2aa 100644 --- a/components/string.rst +++ b/components/string.rst @@ -317,8 +317,8 @@ Methods to Search and Replace return '['.$match[0].']'; }); // result = '[1][2][3]' -Methods to Join, Split and Truncate -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Methods to Join, Split, Truncate and Reverse +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :: @@ -358,19 +358,14 @@ Methods to Join, Split and Truncate // breaks the string into pieces of the length given as argument u('0123456789')->chunk(3); // ['012', '345', '678', '9'] -.. versionadded:: 5.1 - - The reverse() method was introduced in Symfony 5.1. - -Method to Reverse -~~~~~~~~~~~~~~~~~ - -:: - - // reverses the order of characters in a string + // reverses the order of the string contents u('foo bar')->reverse(); // 'rab oof' u('さよなら')->reverse(); // 'らなよさ' +.. versionadded:: 5.1 + + The ``reverse()`` method was introduced in Symfony 5.1. + Methods Added by ByteString ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 4835920e2a7ce5cfc03d1efd7ab250126cc53ec3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Thu, 2 Jan 2020 10:45:20 +0100 Subject: [PATCH 0133/7107] Fixed broken link --- mailer.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index 4d54c3bef00..53a3a50e0ff 100644 --- a/mailer.rst +++ b/mailer.rst @@ -235,7 +235,7 @@ Embedding Images If you want to display images inside your email, you must embed them instead of adding them as attachments. When using Twig to render the email -contents, as explained `later in this article `_, +contents, as explained :ref:`later in this article `, the images are embedded automatically. Otherwise, you need to embed them manually. First, use the ``embed()`` or ``embedFromPath()`` method to add an image from a @@ -347,6 +347,8 @@ the ``TemplatedEmail`` class: // ... ; +.. _reference-mailer-twig-embedding-images: + Embedding Images ~~~~~~~~~~~~~~~~ From e56576e0dfb7a0c479ae70334fe55ec8f86cae27 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 10:54:57 +0100 Subject: [PATCH 0134/7107] Minor tweak --- mailer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mailer.rst b/mailer.rst index 53a3a50e0ff..6dd02d58c35 100644 --- a/mailer.rst +++ b/mailer.rst @@ -235,7 +235,7 @@ Embedding Images If you want to display images inside your email, you must embed them instead of adding them as attachments. When using Twig to render the email -contents, as explained :ref:`later in this article `, +contents, as explained :ref:`later in this article `, the images are embedded automatically. Otherwise, you need to embed them manually. First, use the ``embed()`` or ``embedFromPath()`` method to add an image from a @@ -347,7 +347,7 @@ the ``TemplatedEmail`` class: // ... ; -.. _reference-mailer-twig-embedding-images: +.. _mailer-twig-embedding-images: Embedding Images ~~~~~~~~~~~~~~~~ From 72ac457f98c6a962fd7c30848b7fcd5db2cd7bf3 Mon Sep 17 00:00:00 2001 From: Andrii Dembitskyi Date: Fri, 27 Dec 2019 16:42:44 +0200 Subject: [PATCH 0135/7107] Fixed problem normalizer example --- controller/error_pages.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 471bb55d4f6..2e3743eab14 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -206,10 +206,10 @@ to change the output contents, create a new Normalizer that supports the public function normalize($exception, $format = null, array $context = []) { return [ - 'content': 'This is my custom problem normalizer.', - 'exception': [ - 'message': $exception->getMessage(), - 'code': $exception->getStatusCode(), + 'content' => 'This is my custom problem normalizer.', + 'exception'=> [ + 'message' => $exception->getMessage(), + 'code' => $exception->getStatusCode(), ], ]; } From fb3d7c1ef4042071cdb6df8b27fd7342388e0d7a Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 17:09:14 +0100 Subject: [PATCH 0136/7107] Update error_pages.rst --- controller/error_pages.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 2e3743eab14..951b7c6cb02 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -193,7 +193,7 @@ To override non-HTML error output, the Serializer component needs to be installe $ composer require serializer The Serializer component has a built-in ``FlattenException`` normalizer -(``ProblemNormalizer``) and JSON/XML/CSV/YAML encoders. When your application +(:class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`) and JSON/XML/CSV/YAML encoders. When your application throws an exception, Symfony can output it in one of those formats. If you want to change the output contents, create a new Normalizer that supports the ``FlattenException`` input:: @@ -201,9 +201,11 @@ to change the output contents, create a new Normalizer that supports the # src/App/Serializer/MyCustomProblemNormalizer.php namespace App\Serializer; + use Symfony\Component\Serializer\Normalizer\NormalizerInterface; + class MyCustomProblemNormalizer implements NormalizerInterface { - public function normalize($exception, $format = null, array $context = []) + public function normalize($exception, string $format = null, array $context = []) { return [ 'content' => 'This is my custom problem normalizer.', @@ -214,7 +216,7 @@ to change the output contents, create a new Normalizer that supports the ]; } - public function supportsNormalization($data, $format = null) + public function supportsNormalization($data, string $format = null) { return $data instanceof FlattenException; } @@ -252,14 +254,14 @@ configuration option to point to it: https://symfony.com/schema/dic/services/services-1.0.xsd"> - App\Controller\ErrorController::showAction + App\Controller\ErrorController::showAction .. code-block:: php - // config/packages/twig.php + // config/packages/framework.php $container->loadFromExtension('framework', [ 'error_controller' => 'App\Controller\ErrorController::showAction', // ... From b8d8b83dfca5c74e3bd099e1b5bdff05e7c25c67 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 12:06:41 +0100 Subject: [PATCH 0137/7107] Minor tweak --- controller/error_pages.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/controller/error_pages.rst b/controller/error_pages.rst index 951b7c6cb02..f713b909035 100644 --- a/controller/error_pages.rst +++ b/controller/error_pages.rst @@ -193,10 +193,10 @@ To override non-HTML error output, the Serializer component needs to be installe $ composer require serializer The Serializer component has a built-in ``FlattenException`` normalizer -(:class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`) and JSON/XML/CSV/YAML encoders. When your application -throws an exception, Symfony can output it in one of those formats. If you want -to change the output contents, create a new Normalizer that supports the -``FlattenException`` input:: +(:class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`) and +JSON/XML/CSV/YAML encoders. When your application throws an exception, Symfony +can output it in one of those formats. If you want to change the output +contents, create a new Normalizer that supports the ``FlattenException`` input:: # src/App/Serializer/MyCustomProblemNormalizer.php namespace App\Serializer; From 2fcb72f1f92b65721cea67282486b25b3ed4bc1d Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 25 Dec 2019 16:10:00 +0100 Subject: [PATCH 0138/7107] Update error_handler.rst --- components/error_handler.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/error_handler.rst b/components/error_handler.rst index 08e179efa20..fe5afd0af1b 100644 --- a/components/error_handler.rst +++ b/components/error_handler.rst @@ -49,7 +49,7 @@ Turning PHP Errors into Exceptions The :class:`Symfony\\Component\\ErrorHandler\\ErrorHandler` class catches PHP errors and uncaught PHP exceptions and turns them into PHP's :phpclass:`ErrorException` objects, except for fatal PHP errors, which are -turned into Symfony's :class:`Symfony\\Component\\ErrorHandler\\Exception\\FatalErrorException` +turned into Symfony's :class:`Symfony\\Component\\ErrorHandler\\Error\\FatalError` objects. If the application uses the FrameworkBundle, this error handler is enabled by From 20520f215b473e730a59255a2ca315e57fa60d24 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Tue, 24 Dec 2019 01:24:57 +0100 Subject: [PATCH 0139/7107] Update event_dispatcher.rst --- components/event_dispatcher.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/event_dispatcher.rst b/components/event_dispatcher.rst index 6cfff941a4f..6c472d90e97 100644 --- a/components/event_dispatcher.rst +++ b/components/event_dispatcher.rst @@ -404,7 +404,7 @@ from being called. In other words, the listener needs to be able to tell the dispatcher to stop all propagation of the event to future listeners (i.e. to not notify any more listeners). This can be accomplished from inside a listener via the -:method:`Symfony\\Component\\EventDispatcher\\Event::stopPropagation` method:: +:method:`Symfony\\Contracts\\EventDispatcher\\Event::stopPropagation` method:: use Acme\Store\Event\OrderPlacedEvent; From c23db3921d5aa2cc5e5eedef7cc2e0c84a67ed2b Mon Sep 17 00:00:00 2001 From: Johnny Peck Date: Thu, 2 Jan 2020 06:59:01 -0500 Subject: [PATCH 0140/7107] Update doctrine.rst Grammar. --- doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctrine.rst b/doctrine.rst index 3791ae898a9..0eadc82edee 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -742,7 +742,7 @@ Querying with the Query Builder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Doctrine also provides a `Query Builder`_, an object-oriented way to write -queries. It is recommended to use this when queries and build dynamically (i.e. +queries. It is recommended to use this when queries are built dynamically (i.e. based on PHP conditions):: // src/Repository/ProductRepository.php From 8bef406ce2951cc6fdb5503ae8303aef52a82e97 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 2 Jan 2020 15:23:41 +0100 Subject: [PATCH 0141/7107] Minor tweak --- security/access_control.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/access_control.rst b/security/access_control.rst index 0daab78c71c..0e5fd218c61 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -164,8 +164,8 @@ options: If you define both ``roles`` and ``allow_if``, and your Access Decision Strategy is the default one (``affirmative``), then the user will be granted - access if there's at least one valid condition. See :doc:`/security/voters` - to change your strategy to something more suited to your needs. + access if there's at least one valid condition. If this behavior doesn't fit + your needs, :ref:`change the Access Decision Strategy `. .. tip:: From 2cf09a947582e08d1c0ed846b650a08a35ecf928 Mon Sep 17 00:00:00 2001 From: Vyacheslav Demyanov Date: Wed, 11 Dec 2019 11:20:35 +0300 Subject: [PATCH 0142/7107] Use HttpKernel Component We need to import Symfony\Component\HttpKernel before using it. --- create_framework/http_kernel_httpkernelinterface.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/create_framework/http_kernel_httpkernelinterface.rst b/create_framework/http_kernel_httpkernelinterface.rst index ed1870706fd..3ec76549b2e 100644 --- a/create_framework/http_kernel_httpkernelinterface.rst +++ b/create_framework/http_kernel_httpkernelinterface.rst @@ -56,6 +56,7 @@ PHP; it implements ``HttpKernelInterface`` and wraps another // example.com/web/front.php // ... + use Symfony\Component\HttpKernel; $framework = new Simplex\Framework($dispatcher, $matcher, $controllerResolver, $argumentResolver); $framework = new HttpKernel\HttpCache\HttpCache( From 8f96598d8ffb4e867337a1be7e6cafe4a5600052 Mon Sep 17 00:00:00 2001 From: Vyacheslav Demyanov Date: Tue, 10 Dec 2019 17:06:48 +0300 Subject: [PATCH 0143/7107] It's needed to change the returned string Following the documentation, we check the Calendar application and get the string "Yep, this is a leap year!" instead of "Hello Fabien". --- create_framework/unit_testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/create_framework/unit_testing.rst b/create_framework/unit_testing.rst index 3a0d0a5f5ff..099ada7e704 100644 --- a/create_framework/unit_testing.rst +++ b/create_framework/unit_testing.rst @@ -183,7 +183,7 @@ Response:: $response = $framework->handle(new Request()); $this->assertEquals(200, $response->getStatusCode()); - $this->assertContains('Hello Fabien', $response->getContent()); + $this->assertContains('Yep, this is a leap year!', $response->getContent()); } In this test, we simulate a route that matches and returns a simple From 93668de2f447bdad9cfa961ca5cb0469954160e6 Mon Sep 17 00:00:00 2001 From: rosier Date: Thu, 2 Jan 2020 16:15:34 +0100 Subject: [PATCH 0144/7107] Update service id of the MailerInterface The service id of the MailerInterface was changed in https://github.com/symfony/symfony/pull/31854 to avoid an conflict with SwiftMailer --- mailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index 6dd02d58c35..5516f4564ea 100644 --- a/mailer.rst +++ b/mailer.rst @@ -93,7 +93,7 @@ Creating & Sending Messages --------------------------- To send an email, autowire the mailer using -:class:`Symfony\\Component\\Mailer\\MailerInterface` (service id ``mailer``) +:class:`Symfony\\Component\\Mailer\\MailerInterface` (service id ``mailer.mailer``) and create an :class:`Symfony\\Component\\Mime\\Email` object:: // src/Controller/MailerController.php From 1b92a9fdf4f84b9018e1fba599003eefefad4d19 Mon Sep 17 00:00:00 2001 From: Abdouni Abdelkarim Date: Thu, 10 Oct 2019 11:23:57 +0200 Subject: [PATCH 0145/7107] Getting product using Symfony autowiring --- doctrine.rst | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/doctrine.rst b/doctrine.rst index 7a4558240c9..454d6b6339f 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -522,6 +522,24 @@ be able to go to ``/product/1`` to see your new product:: // in the template, print things with {{ product.name }} // return $this->render('product/show.html.twig', ['product' => $product]); } + +Another possibility is to use the ``ProductRepository`` using Symfony's autowiring +and injected by the dependency injection container:: + + // src/Controller/ProductController.php + // ... + use App\Repository\ProductRepository; + + /** + * @Route("/product/{id}", name="product_show") + */ + public function show($id, ProductRepository $productRepository) + { + $product = $productRepository + ->find($id); + + // ... + } Try it out! From 84151dc19fdeaba280bf55970f05a18315036af5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Thu, 2 Jan 2020 16:50:43 +0100 Subject: [PATCH 0146/7107] Fix invalid yaml --- service_container/alias_private.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index b90bdfb5ab0..09b2d11376c 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -175,7 +175,7 @@ or you decided not to maintain it anymore), you can deprecate its definition: deprecated: true # ...but you can also define a custom deprecation message - deprecated: 'The "%alias_id%" alias is deprecated. Don\'t use it anymore.' + deprecated: 'The "%alias_id%" alias is deprecated. Do not use it anymore.' .. code-block:: xml From 0117fe5998a8c7de83bfddba72ecca6d101b5af2 Mon Sep 17 00:00:00 2001 From: Matthieu Lempereur Date: Thu, 2 Jan 2020 23:32:40 +0100 Subject: [PATCH 0147/7107] Fix broken link --- testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing.rst b/testing.rst index 99fcdd2e3bb..620acb538e5 100644 --- a/testing.rst +++ b/testing.rst @@ -484,7 +484,7 @@ script:: AJAX Requests ~~~~~~~~~~~~~ -The Client provides a :method:`Symfony\\Component\\BrowserKit\\Client::xmlHttpRequest` +The Client provides a :method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::xmlHttpRequest` method, which has the same arguments as the ``request()`` method, and it's a shortcut to make AJAX requests:: From 9d8285f89745bd7d0c4b0097cbfdcef85b26c6da Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 3 Jan 2020 17:04:02 +0100 Subject: [PATCH 0148/7107] Fixed a wrong reference --- templating/hinclude.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templating/hinclude.rst b/templating/hinclude.rst index ceebf6ea3b4..def7939ab17 100644 --- a/templating/hinclude.rst +++ b/templating/hinclude.rst @@ -10,7 +10,7 @@ performance you can use the `hinclude.js`_ JavaScript library to embed controllers asynchronously. First, include the `hinclude.js`_ library in your page -ref:`linking to it ` from the template or adding it +:ref:`linking to it ` from the template or adding it to your application JavaScript :doc:`using Webpack Encore `. As the embedded content comes from another page (or controller for that matter), From 03956a8db79e835e3db43cac596cb0da154b2602 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 3 Jan 2020 17:33:12 +0100 Subject: [PATCH 0149/7107] [DependencyInjection] Reworded the article about factories --- service_container/factories.rst | 58 ++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/service_container/factories.rst b/service_container/factories.rst index 7abf0a93236..bc0f73b3475 100644 --- a/service_container/factories.rst +++ b/service_container/factories.rst @@ -4,13 +4,17 @@ Using a Factory to Create Services ================================== -Symfony's Service Container provides a powerful way of controlling the -creation of objects, allowing you to specify arguments passed to the constructor -as well as calling methods and setting parameters. Sometimes, however, this -will not provide you with everything you need to construct your objects. -For this situation, you can use a factory to create the object and tell -the service container to call a method on the factory rather than directly -instantiating the class. +Symfony's Service Container provides multiple features to control the creation +of objects, allowing you to specify arguments passed to the constructor as well +as calling methods and setting parameters. + +However, sometimes you need to apply the `factory design pattern`_ to delegate +the object creation to some special object called "the factory". In those cases, +the service container can call a method on your factory to create the object +rather than directly instantiating the class. + +Static Factories +---------------- Suppose you have a factory that configures and returns a new ``NewsletterManager`` object by calling the static ``createNewsletterManager()`` method:: @@ -27,9 +31,9 @@ object by calling the static ``createNewsletterManager()`` method:: } } -To make the ``NewsletterManager`` object available as a service, you can -configure the service container to use the -``NewsletterManagerStaticFactory::createNewsletterManager()`` factory method: +To make the ``NewsletterManager`` object available as a service, use the +``factory`` option to define which method of which class must be called to +create its object: .. configuration-block:: @@ -40,7 +44,7 @@ configure the service container to use the # ... App\Email\NewsletterManager: - # call the static method + # the first argument is the class and the second argument is the static method factory: ['App\Email\NewsletterManagerStaticFactory', 'createNewsletterManager'] .. code-block:: xml @@ -54,7 +58,7 @@ configure the service container to use the - + + - @@ -144,15 +152,20 @@ Configuration of the service container then looks like this: return function(ContainerConfigurator $configurator) { $services = $configurator->services(); + // first, create a service for the factory $services->set(NewsletterManagerFactory::class); - // call a method on the specified factory service + // second, use the factory service as the first argument of the 'factory' + // method and the factory method as the second argument $services->set(NewsletterManager::class) ->factory([ref(NewsletterManagerFactory::class), 'createNewsletterManager']); }; .. _factories-invokable: +Invokable Factories +------------------- + Suppose you now change your factory method to ``__invoke()`` so that your factory service can be used as a callback:: @@ -234,8 +247,8 @@ Passing Arguments to the Factory Method that's enabled for your service. If you need to pass arguments to the factory method you can use the ``arguments`` -options. For example, suppose the ``createNewsletterManager()`` method in the previous -example takes the ``templating`` service as an argument: +option. For example, suppose the ``createNewsletterManager()`` method in the +previous examples takes the ``templating`` service as an argument: .. configuration-block:: @@ -285,3 +298,4 @@ example takes the ``templating`` service as an argument: ; }; +.. _`factory design pattern`: https://en.wikipedia.org/wiki/Factory_(object-oriented_programming) From 715a4e703197e3307ca85f56818ea6249414b715 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 22 Dec 2019 23:14:12 +0100 Subject: [PATCH 0150/7107] [3.4] Fixed everything found by the spellcheck builder --- .gitignore | 1 + _build/.requirements.txt | 2 +- _build/conf.py | 5 + _build/spelling_word_list.txt | 347 ++++++++++++ best_practices/creating-the-project.rst | 2 +- bundles/best_practices.rst | 2 +- .../adapters/php_array_cache_adapter.rst | 2 +- .../cache/adapters/php_files_adapter.rst | 2 +- components/dotenv.rst | 2 +- components/http_foundation.rst | 8 +- .../http_foundation/session_configuration.rst | 2 +- components/intl.rst | 4 +- components/phpunit_bridge.rst | 4 +- components/process.rst | 6 +- configuration.rst | 8 +- configuration/external_parameters.rst | 2 +- contributing/code/bugs.rst | 2 +- contributing/code/core_team.rst | 2 +- contributing/documentation/format.rst | 2 +- contributing/documentation/overview.rst | 2 +- contributing/documentation/standards.rst | 4 +- controller/soap_web_service.rst | 2 +- create_framework/introduction.rst | 2 +- create_framework/routing.rst | 2 +- deployment/azure-website.rst | 6 +- deployment/fortrabbit.rst | 4 +- deployment/heroku.rst | 2 +- deployment/proxies.rst | 4 +- doctrine/associations.rst | 4 +- doctrine/custom_dql_functions.rst | 2 +- email/spool.rst | 6 +- event_dispatcher/before_after_filters.rst | 2 +- form/csrf_protection.rst | 2 +- form/data_transformers.rst | 6 +- form/form_themes.rst | 4 +- frontend/encore/babel.rst | 4 +- frontend/encore/postcss.rst | 4 +- frontend/encore/sourcemaps.rst | 3 +- frontend/encore/versioning.rst | 4 +- frontend/encore/versus-assetic.rst | 40 +- frontend/encore/vuejs.rst | 4 +- http_cache/form_csrf_caching.rst | 2 +- http_cache/validation.rst | 13 +- logging/channels_handlers.rst | 2 +- logging/monolog_console.rst | 2 +- page_creation.rst | 2 +- performance.rst | 4 +- profiler/data_collector.rst | 2 +- profiler/storage.rst | 2 +- reference/configuration/assetic.rst | 2 +- reference/configuration/debug.rst | 24 +- reference/configuration/doctrine.rst | 22 +- reference/configuration/framework.rst | 534 +++++++++--------- reference/configuration/security.rst | 114 ++-- reference/configuration/swiftmailer.rst | 110 ++-- reference/configuration/twig.rst | 84 +-- reference/configuration/web_profiler.rst | 20 +- reference/constraints/All.rst | 4 +- reference/constraints/Bic.rst | 8 +- reference/constraints/Blank.rst | 4 +- reference/constraints/Callback.rst | 4 +- reference/constraints/CardScheme.rst | 8 +- reference/constraints/Choice.rst | 40 +- reference/constraints/Collection.rst | 24 +- reference/constraints/Count.rst | 20 +- reference/constraints/Country.rst | 4 +- reference/constraints/Currency.rst | 4 +- reference/constraints/Date.rst | 4 +- reference/constraints/DateTime.rst | 4 +- reference/constraints/Email.rst | 16 +- reference/constraints/EqualTo.rst | 4 +- reference/constraints/Expression.rst | 12 +- reference/constraints/File.rst | 94 +-- reference/constraints/GreaterThan.rst | 4 +- reference/constraints/GreaterThanOrEqual.rst | 4 +- reference/constraints/Iban.rst | 14 +- reference/constraints/IdenticalTo.rst | 4 +- reference/constraints/Image.rst | 108 ++-- reference/constraints/Ip.rst | 10 +- reference/constraints/IsFalse.rst | 4 +- reference/constraints/IsNull.rst | 4 +- reference/constraints/IsTrue.rst | 4 +- reference/constraints/Isbn.rst | 26 +- reference/constraints/Issn.rst | 14 +- reference/constraints/Language.rst | 4 +- reference/constraints/Length.rst | 28 +- reference/constraints/LessThan.rst | 4 +- reference/constraints/LessThanOrEqual.rst | 4 +- reference/constraints/Locale.rst | 4 +- reference/constraints/Luhn.rst | 8 +- reference/constraints/NotBlank.rst | 4 +- reference/constraints/NotEqualTo.rst | 4 +- reference/constraints/NotIdenticalTo.rst | 4 +- reference/constraints/NotNull.rst | 4 +- reference/constraints/Range.rst | 20 +- reference/constraints/Regex.rst | 16 +- reference/constraints/Time.rst | 4 +- reference/constraints/Type.rst | 8 +- reference/constraints/UniqueEntity.rst | 28 +- reference/constraints/Url.rst | 18 +- reference/constraints/UserPassword.rst | 4 +- reference/constraints/Uuid.rst | 14 +- reference/constraints/Valid.rst | 4 +- .../_comparison-propertypath-option.rst.inc | 4 +- .../_comparison-value-option.rst.inc | 4 +- reference/constraints/_groups-option.rst.inc | 4 +- reference/constraints/_payload-option.rst.inc | 4 +- reference/dic_tags.rst | 166 +++--- reference/forms/twig_reference.rst | 40 +- reference/forms/types/birthday.rst | 10 +- reference/forms/types/button.rst | 4 +- reference/forms/types/choice.rst | 72 +-- reference/forms/types/collection.rst | 48 +- reference/forms/types/country.rst | 4 +- reference/forms/types/currency.rst | 4 +- reference/forms/types/date.rst | 38 +- reference/forms/types/dateinterval.rst | 102 ++-- reference/forms/types/datetime.rst | 52 +- reference/forms/types/entity.rst | 28 +- reference/forms/types/file.rst | 14 +- reference/forms/types/form.rst | 4 +- reference/forms/types/hidden.rst | 8 +- reference/forms/types/integer.rst | 8 +- reference/forms/types/language.rst | 4 +- reference/forms/types/locale.rst | 4 +- reference/forms/types/money.rst | 12 +- reference/forms/types/number.rst | 8 +- reference/forms/types/options/action.rst.inc | 4 +- reference/forms/types/options/attr.rst.inc | 4 +- .../types/options/auto_initialize.rst.inc | 4 +- .../forms/types/options/block_name.rst.inc | 4 +- .../types/options/button_disabled.rst.inc | 4 +- .../forms/types/options/button_label.rst.inc | 4 +- .../options/button_translation_domain.rst.inc | 4 +- .../forms/types/options/by_reference.rst.inc | 4 +- .../types/options/checkbox_compound.rst.inc | 4 +- .../types/options/checkbox_empty_data.rst.inc | 4 +- .../forms/types/options/choice_attr.rst.inc | 4 +- .../forms/types/options/choice_label.rst.inc | 4 +- .../forms/types/options/choice_name.rst.inc | 4 +- .../options/choice_translation_domain.rst.inc | 4 +- .../types/options/choice_type_trim.rst.inc | 4 +- .../forms/types/options/choice_value.rst.inc | 4 +- .../forms/types/options/compound.rst.inc | 4 +- .../forms/types/options/compound_type.rst.inc | 4 +- .../forms/types/options/constraints.rst.inc | 4 +- reference/forms/types/options/data.rst.inc | 4 +- .../forms/types/options/data_class.rst.inc | 4 +- .../types/options/data_class_date.rst.inc | 4 +- .../forms/types/options/date_format.rst.inc | 4 +- .../forms/types/options/date_input.rst.inc | 4 +- .../forms/types/options/date_widget.rst.inc | 4 +- reference/forms/types/options/days.rst.inc | 4 +- .../forms/types/options/disabled.rst.inc | 4 +- .../forms/types/options/empty_data.rst.inc | 4 +- .../types/options/error_bubbling.rst.inc | 4 +- .../forms/types/options/error_mapping.rst.inc | 6 +- .../forms/types/options/expanded.rst.inc | 4 +- .../options/extra_fields_message.rst.inc | 4 +- .../forms/types/options/group_by.rst.inc | 4 +- .../forms/types/options/grouping.rst.inc | 4 +- reference/forms/types/options/hours.rst.inc | 4 +- reference/forms/types/options/html5.rst.inc | 4 +- .../forms/types/options/inherit_data.rst.inc | 4 +- .../types/options/invalid_message.rst.inc | 4 +- .../invalid_message_parameters.rst.inc | 4 +- reference/forms/types/options/label.rst.inc | 4 +- .../forms/types/options/label_attr.rst.inc | 4 +- .../forms/types/options/label_format.rst.inc | 4 +- reference/forms/types/options/mapped.rst.inc | 4 +- reference/forms/types/options/method.rst.inc | 4 +- reference/forms/types/options/minutes.rst.inc | 4 +- .../types/options/model_timezone.rst.inc | 4 +- reference/forms/types/options/months.rst.inc | 4 +- .../forms/types/options/multiple.rst.inc | 4 +- .../forms/types/options/placeholder.rst.inc | 4 +- .../options/post_max_size_message.rst.inc | 4 +- .../types/options/preferred_choices.rst.inc | 4 +- .../forms/types/options/property_path.rst.inc | 4 +- .../forms/types/options/required.rst.inc | 4 +- reference/forms/types/options/scale.rst.inc | 4 +- reference/forms/types/options/seconds.rst.inc | 4 +- .../types/options/translation_domain.rst.inc | 4 +- reference/forms/types/options/trim.rst.inc | 4 +- .../types/options/validation_groups.rst.inc | 4 +- reference/forms/types/options/value.rst.inc | 4 +- .../forms/types/options/view_timezone.rst.inc | 4 +- .../forms/types/options/with_minutes.rst.inc | 4 +- .../forms/types/options/with_seconds.rst.inc | 4 +- reference/forms/types/options/years.rst.inc | 4 +- reference/forms/types/password.rst | 8 +- reference/forms/types/percent.rst | 8 +- reference/forms/types/repeated.rst | 28 +- reference/forms/types/reset.rst | 4 +- reference/forms/types/submit.rst | 18 +- reference/forms/types/textarea.rst | 2 +- reference/forms/types/time.rst | 46 +- reference/forms/types/timezone.rst | 12 +- reference/forms/types/url.rst | 4 +- reference/twig_reference.rst | 174 +++--- routing/hostname_pattern.rst | 2 +- routing/redirect_in_config.rst | 2 +- security.rst | 12 +- security/access_control.rst | 54 +- security/acl.rst | 2 +- security/api_key_authentication.rst | 14 +- security/custom_password_authenticator.rst | 12 +- security/custom_provider.rst | 2 +- security/ldap.rst | 28 +- service_container.rst | 18 +- service_container/3.3-di-changes.rst | 14 +- .../service_subscribers_locators.rst | 2 +- service_container/tags.rst | 2 +- session/proxy_examples.rst | 6 +- setup.rst | 4 +- setup/_vendor_deps.rst.inc | 2 +- setup/file_permissions.rst | 4 +- setup/flex.rst | 2 +- setup/symfony_server.rst | 4 +- setup/web_server_configuration.rst | 30 +- templating/hinclude.rst | 10 +- web_link.rst | 2 +- 222 files changed, 1940 insertions(+), 1583 deletions(-) create mode 100644 _build/spelling_word_list.txt diff --git a/.gitignore b/.gitignore index a5eb433eea3..6a20088680a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /_build/doctrees +/_build/spelling /_build/html *.pyc diff --git a/_build/.requirements.txt b/_build/.requirements.txt index 53c6c3ddff0..6f1f8953dff 100644 --- a/_build/.requirements.txt +++ b/_build/.requirements.txt @@ -9,5 +9,5 @@ pytz==2017.2 requests==2.20.0 six==1.10.0 snowballstemmer==1.2.1 -Sphinx==1.3.6 +sphinx==1.3.6 git+https://github.com/fabpot/sphinx-php.git@7312eccce9465640752e51373a480da700e02345#egg_name=sphinx-php diff --git a/_build/conf.py b/_build/conf.py index b707b25a477..998fb450a08 100644 --- a/_build/conf.py +++ b/_build/conf.py @@ -37,8 +37,13 @@ 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.todo', 'sensio.sphinx.refinclude', 'sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode', 'sensio.sphinx.bestpractice', 'sensio.sphinx.codeblock', 'symfonycom.sphinx' + #,'sphinxcontrib.spelling' ] +#spelling_show_sugestions=True +#spelling_lang='en_US' +#spelling_word_list_filename='_build/spelling_word_list.txt' + # Add any paths that contain templates here, relative to this directory. # templates_path = ['_theme/_templates'] diff --git a/_build/spelling_word_list.txt b/_build/spelling_word_list.txt new file mode 100644 index 00000000000..10a9c2896e1 --- /dev/null +++ b/_build/spelling_word_list.txt @@ -0,0 +1,347 @@ +accessor +advertize +Akamai +analytics +Ansi +Ansible +Assetic +async +authenticator +authenticators +autocompleted +autocompletion +autoconfiguration +autoconfigure +autoconfigured +autoconfigures +autoconfiguring +autoload +autoloaded +autoloader +autoloaders +autoloading +autoprefixing +autowire +autowireable +autowired +autowiring +backend +backends +balancer +balancers +bcrypt +benchmarking +Bitbucket +bitmask +bitmasks +bitwise +Blackfire +boolean +booleans +Brasseur +browserslist +buildpack +buildpacks +bundler +cacheable +Caddy +callables +camelCase +casted +changelog +changeset +charset +charsets +checkboxes +classmap +classname +clearers +cloner +cloners +codebase +config +configs +configurator +configurators +contrib +cron +cronjobs +cryptographic +cryptographically +Ctrl +ctype +cURL +customizable +customizations +Cygwin +dataset +datepicker +decrypt +denormalization +denormalize +denormalized +denormalizing +deprecations +deserialization +deserialize +deserialized +deserializing +destructor +dev +dn +DNS +docblock +Dotenv +downloader +Doxygen +DSN +Dunglas +easter +Eberlei +emilie +enctype +entrypoints +enum +env +escaper +escpaer +extensibility +extractable +eZPublish +Fabien +failover +filesystem +filesystems +formatter +formatters +fortrabbit +frontend +getter +getters +GitHub +gmail +Gmail +Goutte +grapheme +hardcode +hardcoded +hardcodes +hardcoding +hasser +hassers +headshot +HInclude +hostname +https +iconv +igbinary +incrementing +ini +inlined +inlining +installable +instantiation +interoperable +intl +Intl +invokable +IPv +isser +issers +Jpegoptim +jQuery +js +Karlton +kb +kB +Kévin +Ki +KiB +kibibyte +Kubernetes +Kudu +labelled +latin +Ldap +libketama +licensor +lifecycle +liip +linter +localhost +Loggly +Logplex +lookups +loopback +lorenzo +Luhn +macOS +matcher +matchers +mbstring +mebibyte +memcache +memcached +MiB +michelle +minification +minified +minifier +minifies +minify +minifying +misconfiguration +misconfigured +misgendering +Monolog +mutator +nagle +namespace +namespaced +namespaces +namespacing +natively +nd +netmasks +nginx +normalizer +normalizers +npm +nyholm +OAuth +OPcache +overcomplicate +Packagist +parallelizes +parsers +PHP +PHPUnit +PID +plaintext +polyfill +polyfills +postcss +Potencier +pre +preconfigured +predefines +Predis +preload +preloaded +preloading +prepend +prepended +prepending +prepends +preprocessed +preprocessors +Procfile +profiler +programmatically +prototyped +rebase +reconfiguring +reconnection +redirections +refactorization +regexes +renderer +resolvers +responder +reStructuredText +reusability +runtime +sandboxing +schemas +screencast +semantical +serializable +serializer +sexualized +Silex +sluggable +socio +specificities +SQLite +stacktrace +stacktraces +storages +stringified +stylesheet +stylesheets +subclasses +subdirectories +subdirectory +sublcasses +sublicense +sublincense +subrequests +subtree +superclass +superglobal +superglobals +symfony +Symfony +symlink +symlinks +syntaxes +templating +testability +th +theming +throbber +timestampable +timezones +TLS +tmpfs +tobias +todo +Tomayko +Toolbelt +tooltip +Traversable +triaging +UI +uid +unary +unauthenticate +uncacheable +uncached +uncomment +uncommented +undelete +unhandled +unicode +Unix +unmapped +unminified +unported +unregister +unrendered +unserialize +unserialized +unserializing +unsubmitted +untracked +uploader +URI +validator +validators +variadic +VirtualBox +Vue +webpack +webpacked +webpackJsonp +webserver +whitespace +whitespaces +woh +Wordpress +Xdebug +xkcd +Xliff +XML +XPath +yaml +yay diff --git a/best_practices/creating-the-project.rst b/best_practices/creating-the-project.rst index dc1f8dd3a50..abcda84b621 100644 --- a/best_practices/creating-the-project.rst +++ b/best_practices/creating-the-project.rst @@ -106,7 +106,7 @@ following: Application Bundles ~~~~~~~~~~~~~~~~~~~ -When Symfony 2.0 was released, most developers naturally adopted the symfony +When Symfony 2.0 was released, most developers naturally adopted the Symfony 1.x way of dividing applications into logical modules. That's why many Symfony applications use bundles to divide their code into logical features: UserBundle, ProductBundle, InvoiceBundle, etc. diff --git a/bundles/best_practices.rst b/bundles/best_practices.rst index 82c2f83b0bf..c9b68c1443b 100644 --- a/bundles/best_practices.rst +++ b/bundles/best_practices.rst @@ -188,7 +188,7 @@ The index file (for example ``Resources/doc/index.rst`` or ``Resources/doc/index.md``) is the only mandatory file and must be the entry point for the documentation. The :doc:`reStructuredText (rST) ` is the format -used to render the documentation on symfony.com. +used to render the documentation on the Symfony website. Installation Instructions ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/cache/adapters/php_array_cache_adapter.rst b/components/cache/adapters/php_array_cache_adapter.rst index a0e351b7f7a..c27e4fd2ecf 100644 --- a/components/cache/adapters/php_array_cache_adapter.rst +++ b/components/cache/adapters/php_array_cache_adapter.rst @@ -2,7 +2,7 @@ single: Cache Pool single: PHP Array Cache -Php Array Cache Adapter +PHP Array Cache Adapter ======================= This adapter is a high performance cache for static data (e.g. application configuration) diff --git a/components/cache/adapters/php_files_adapter.rst b/components/cache/adapters/php_files_adapter.rst index e4b55067052..8e693be63ec 100644 --- a/components/cache/adapters/php_files_adapter.rst +++ b/components/cache/adapters/php_files_adapter.rst @@ -4,7 +4,7 @@ .. _component-cache-files-adapter: -Php Files Cache Adapter +PHP Files Cache Adapter ======================= Similarly to :ref:`Filesystem Adapter `, this cache diff --git a/components/dotenv.rst b/components/dotenv.rst index f09c242e226..85e2b0bccfd 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -28,7 +28,7 @@ Sensitive information and environment-dependent settings should be defined as environment variables (as recommended for `twelve-factor applications`_). Using a ``.env`` file to store those environment variables eases development and CI management by keeping them in one "standard" place and agnostic of the -technology stack you are using (Nginx vs PHP built-in server for instance). +technology stack you are using (nginx vs PHP built-in server for instance). .. note:: diff --git a/components/http_foundation.rst b/components/http_foundation.rst index a9c7117e043..311ecbe08af 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -477,10 +477,10 @@ represented by a PHP callable instead of a string:: Additionally, PHP isn't the only layer that can buffer output. Your web server might also buffer based on its configuration. Some servers, such as - Nginx, let you disable buffering at the config level or by adding a special HTTP + nginx, let you disable buffering at the config level or by adding a special HTTP header in the response:: - // disables FastCGI buffering in Nginx only for this response + // disables FastCGI buffering in nginx only for this response $response->headers->set('X-Accel-Buffering', 'no') .. _component-http-foundation-serving-files: @@ -517,7 +517,7 @@ Alternatively, if you are serving a static file, you can use a The ``BinaryFileResponse`` will automatically handle ``Range`` and ``If-Range`` headers from the request. It also supports ``X-Sendfile`` -(see for `Nginx`_ and `Apache`_). To make use of it, you need to determine +(see for `nginx`_ and `Apache`_). To make use of it, you need to determine whether or not the ``X-Sendfile-Type`` header should be trusted and call :method:`Symfony\\Component\\HttpFoundation\\BinaryFileResponse::trustXSendfileTypeHeader` if it should:: @@ -665,7 +665,7 @@ Learn More /session/* /http_cache/* -.. _Nginx: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/ +.. _nginx: https://www.nginx.com/resources/wiki/start/topics/examples/xsendfile/ .. _Apache: https://tn123.org/mod_xsendfile/ .. _`JSON Hijacking`: http://haacked.com/archive/2009/06/25/json-hijacking.aspx .. _OWASP guidelines: https://www.owasp.org/index.php/OWASP_AJAX_Security_Guidelines#Always_return_JSON_with_an_Object_on_the_outside diff --git a/components/http_foundation/session_configuration.rst b/components/http_foundation/session_configuration.rst index d4669ac85ec..8f8ce6e8ce7 100644 --- a/components/http_foundation/session_configuration.rst +++ b/components/http_foundation/session_configuration.rst @@ -23,7 +23,7 @@ Native PHP Save Handlers ------------------------ So-called native handlers, are save handlers which are either compiled into -PHP or provided by PHP extensions, such as PHP-Sqlite, PHP-Memcached and so on. +PHP or provided by PHP extensions, such as PHP-SQLite, PHP-Memcached and so on. All native save handlers are internal to PHP and as such, have no public facing API. They must be configured by ``php.ini`` directives, usually ``session.save_path`` and diff --git a/components/intl.rst b/components/intl.rst index eec1c2c9573..ae4634ffe30 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -116,7 +116,7 @@ PhpBundleWriter ~~~~~~~~~~~~~~~ The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Writer\\PhpBundleWriter` -writes an array or an array-like object to a .php resource bundle:: +writes an array or an array-like object to a ``.php`` resource bundle:: use Symfony\Component\Intl\ResourceBundle\Writer\PhpBundleWriter; @@ -147,7 +147,7 @@ PhpBundleReader ~~~~~~~~~~~~~~~ The :class:`Symfony\\Component\\Intl\\ResourceBundle\\Reader\\PhpBundleReader` -reads resource bundles from .php files and returns an array or an array-like +reads resource bundles from ``.php`` files and returns an array or an array-like object:: use Symfony\Component\Intl\ResourceBundle\Reader\PhpBundleReader; diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 838c8f7bc7c..409647e3a0c 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -145,7 +145,7 @@ a directory containing multiple test suites with their own ``phpunit.xml.dist``. $ ./vendor/bin/simple-phpunit tests/ The modified PHPUnit script will recursively go through the provided directory, -up to a depth of 3 subfolders or the value specified by the environment variable +up to a depth of 3 subdirectories or the value specified by the environment variable ``SYMFONY_PHPUNIT_MAX_DEPTH``, looking for ``phpunit.xml.dist`` files and then running each suite it finds in parallel, collecting their output and displaying each test suite's results in their own section. @@ -558,7 +558,7 @@ classes' namespace. In order to work as expected, the listener has to run before the tested class ever runs. By default, the mocked functions are created when the annotation are found and the corresponding tests are run. Depending on how your tests are constructed, this might be too late. In this case, you will need to declare -the namespaces of the tested classes in your phpunit.xml.dist +the namespaces of the tested classes in your ``phpunit.xml.dist``. .. code-block:: xml diff --git a/components/process.rst b/components/process.rst index 5b3c66d3924..ea626f31a38 100644 --- a/components/process.rst +++ b/components/process.rst @@ -387,10 +387,10 @@ When running a program asynchronously, you can send it POSIX signals with the // will send a SIGKILL to the process $process->signal(SIGKILL); -Process Pid +Process PID ----------- -You can access the `pid`_ of a running process with the +You can access the `PID`_ of a running process with the :method:`Symfony\\Component\\Process\\Process::getPid` method:: use Symfony\Component\Process\Process; @@ -443,6 +443,6 @@ absolute path of the executable PHP binary available on your server:: $phpBinaryPath = $phpBinaryFinder->find(); // $phpBinaryPath = '/usr/local/bin/php' (the result will be different on your computer) -.. _`pid`: https://en.wikipedia.org/wiki/Process_identifier +.. _`PID`: https://en.wikipedia.org/wiki/Process_identifier .. _`PHP streams`: https://www.php.net/manual/en/book.stream.php .. _`output_buffering`: https://www.php.net/manual/en/outcontrol.configuration.php diff --git a/configuration.rst b/configuration.rst index fc9159be114..49b5589cee8 100644 --- a/configuration.rst +++ b/configuration.rst @@ -8,8 +8,8 @@ Every Symfony application consists of a collection of bundles that add useful to (:doc:`services `) to your project. Each bundle can be customized via configuration files that live - by default - in the ``app/config`` directory. -Configuration: config.yml -------------------------- +Configuration: ``config.yml`` +----------------------------- The main configuration file is called ``config.yml``: @@ -297,8 +297,8 @@ a controller - see :ref:`service-container-parameters`. .. _config-parameters-yml: -The Special parameters.yml File -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The Special ``parameters.yml`` File +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On the surface, ``parameters.yml`` is just like any other configuration file: it is imported by ``config.yml`` and defines several parameters: diff --git a/configuration/external_parameters.rst b/configuration/external_parameters.rst index 632e9b851bd..367ec2bc331 100644 --- a/configuration/external_parameters.rst +++ b/configuration/external_parameters.rst @@ -96,7 +96,7 @@ will be used whenever the corresponding environment variable is *not* found: $container->setParameter('env(DATABASE_HOST)', 'localhost'); Setting environment variables is generally done at the web server level or in the -terminal. If you're using Apache, Nginx or just the console, you can use e.g. one +terminal. If you're using Apache, nginx or just the console, you can use e.g. one of the following: .. configuration-block:: diff --git a/contributing/code/bugs.rst b/contributing/code/bugs.rst index 2a374dedbba..440b2dac519 100644 --- a/contributing/code/bugs.rst +++ b/contributing/code/bugs.rst @@ -15,7 +15,7 @@ Before submitting a bug: framework; * Ask for assistance on `Stack Overflow`_, on the #support channel of - `the Symfony Slack`_ or on the #symfony `IRC channel`_ if you're not sure if + `the Symfony Slack`_ or on the ``#symfony`` `IRC channel`_ if you're not sure if your issue really is a bug. If your problem definitely looks like a bug, report it using the official bug diff --git a/contributing/code/core_team.rst b/contributing/code/core_team.rst index 2f89eea7052..3601d5b3fcd 100644 --- a/contributing/code/core_team.rst +++ b/contributing/code/core_team.rst @@ -148,7 +148,7 @@ A pull request **can be merged** if: * Enough time was given for peer reviews; * At least two **Merger Team** members voted ``+1`` (only one if the submitter - is part of the Merger team) and no Core member voted ``-1`` (via Github + is part of the Merger team) and no Core member voted ``-1`` (via GitHub reviews or as comments). Pull Request Merging Process diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index c1a082d31e4..43147f26341 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -8,7 +8,7 @@ such as HTML and PDF. reStructuredText ---------------- -reStructuredText is a plaintext markup syntax similar to Markdown, but much +reStructuredText is a plain text markup syntax similar to Markdown, but much stricter with its syntax. If you are new to reStructuredText, take some time to familiarize with this format by reading the existing `Symfony documentation`_ source code. diff --git a/contributing/documentation/overview.rst b/contributing/documentation/overview.rst index 7fd6aa55d5b..0a000dec71c 100644 --- a/contributing/documentation/overview.rst +++ b/contributing/documentation/overview.rst @@ -292,7 +292,7 @@ Why Do my Changes Take so Long to Be Reviewed and/or Merged? Please be patient. It can take up to several days before your pull request can be fully reviewed. After merging the changes, it could take again several hours -before your changes appear on the symfony.com website. +before your changes appear on the ``symfony.com`` website. Why Should I Use the Oldest Maintained Branch Instead of the Master Branch? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/contributing/documentation/standards.rst b/contributing/documentation/standards.rst index 7edd66ab061..08787eb0331 100644 --- a/contributing/documentation/standards.rst +++ b/contributing/documentation/standards.rst @@ -63,8 +63,8 @@ Code Examples * To avoid horizontal scrolling on code blocks, we prefer to break a line correctly if it crosses the 85th character; * When you fold one or more lines of code, place ``...`` in a comment at the point - of the fold. These comments are: ``// ...`` (php), ``# ...`` (yaml/bash), ``{# ... #}`` - (twig), ```` (xml/html), ``; ...`` (ini), ``...`` (text); + of the fold. These comments are: ``// ...`` (PHP), ``# ...`` (Yaml/bash), ``{# ... #}`` + (Twig), ```` (XML/HTML), ``; ...`` (INI), ``...`` (text); * When you fold a part of a line, e.g. a variable value, put ``...`` (without comment) at the place of the fold; * Description of the folded code: (optional) diff --git a/controller/soap_web_service.rst b/controller/soap_web_service.rst index 6d1bd2a3be4..a4447c46a5e 100644 --- a/controller/soap_web_service.rst +++ b/controller/soap_web_service.rst @@ -89,7 +89,7 @@ Take note of the calls to ``ob_start()`` and ``ob_get_clean()``. These methods control `output buffering`_ which allows you to "trap" the echoed output of ``$server->handle()``. This is necessary because Symfony expects your controller to return a ``Response`` object with the output as its "content". -You must also remember to set the "Content-Type" header to "text/xml", as +You must also remember to set the ``"Content-Type"`` header to ``"text/xml"``, as this is what the client will expect. So, you use ``ob_start()`` to start buffering the STDOUT and use ``ob_get_clean()`` to dump the echoed output into the content of the Response and clear the output buffer. Finally, you're diff --git a/create_framework/introduction.rst b/create_framework/introduction.rst index 98ae23d3252..d4d9742fee9 100644 --- a/create_framework/introduction.rst +++ b/create_framework/introduction.rst @@ -62,7 +62,7 @@ Before You Start Reading about how to create a framework is not enough. You will have to follow along and actually type all the examples included in this tutorial. For that, you need a recent version of PHP (5.5.9 or later is good enough), a web server -(like Apache, NGinx or PHP's built-in web server), a good knowledge of PHP and +(like Apache, NGINX or PHP's built-in web server), a good knowledge of PHP and an understanding of Object Oriented programming. Ready to go? Read on! diff --git a/create_framework/routing.rst b/create_framework/routing.rst index 628a8a04d39..717ed1068fb 100644 --- a/create_framework/routing.rst +++ b/create_framework/routing.rst @@ -73,7 +73,7 @@ of default values for route attributes (``['name' => 'World']``). Read the :doc:`Routing component documentation ` to learn more about its many features like URL generation, attribute - requirements, HTTP method enforcements, loaders for YAML or XML files, + requirements, HTTP method enforcement, loaders for YAML or XML files, dumpers to PHP or Apache rewrite rules for enhanced performance and much more. diff --git a/deployment/azure-website.rst b/deployment/azure-website.rst index c758c239d1e..71c7cd288a1 100644 --- a/deployment/azure-website.rst +++ b/deployment/azure-website.rst @@ -65,7 +65,7 @@ application code to the Git repository. :alt: Configure Azure Website credentials Congratulations! Your Azure Website is now up and running. You can check -it by browsing to the Website url you configured in the first step. You should +it by browsing to the website URL you configured in the first step. You should see the following display in your web browser: .. image:: /_images/deployment/azure-website/step-05.png @@ -117,8 +117,8 @@ the web server. .. image:: /_images/deployment/azure-website/step-08.png :alt: OPCache Configuration -Tweaking php.ini Configuration Settings -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Tweaking ``php.ini`` Configuration Settings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Microsoft Azure allows you to override the ``php.ini`` global configuration settings by creating a custom ``.user.ini`` file under the project root diff --git a/deployment/fortrabbit.rst b/deployment/fortrabbit.rst index ad1ca05aacf..31195949912 100644 --- a/deployment/fortrabbit.rst +++ b/deployment/fortrabbit.rst @@ -182,7 +182,7 @@ Environment Variables ~~~~~~~~~~~~~~~~~~~~~ Set the ``SYMFONY_ENV`` environment variable to ``prod`` to make sure the right -config files get loaded. ENV vars are configuable in fortrabbit Dashboard as well. +config files get loaded. ENV vars are configurable in fortrabbit Dashboard as well. Document Root ~~~~~~~~~~~~~ @@ -198,7 +198,7 @@ It is assumed that your codebase is under version-control with Git and dependenc are managed with Composer (locally). Every time you push to fortrabbit composer install runs before your code gets -deployed. To finetune the deployment behavior put a `fortrabbit.yml`_. deployment +deployed. To fine-tune the deployment behavior put a `fortrabbit.yml`_. deployment file (optional) in the project root. Add fortrabbit as a (additional) Git remote and add your configuration changes: diff --git a/deployment/heroku.rst b/deployment/heroku.rst index 1fe7748e35a..fbef77703b2 100644 --- a/deployment/heroku.rst +++ b/deployment/heroku.rst @@ -98,7 +98,7 @@ directory of the application and add just the following content: .. note:: - If you prefer to use Nginx, which is also available on Heroku, you can create + If you prefer to use nginx, which is also available on Heroku, you can create a configuration file for it and point to it from your Procfile as described in the `Heroku documentation`_: diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 9015a7165a5..cb2c52718c0 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -18,8 +18,8 @@ via HTTPS, the client's port and the hostname being requested. .. _request-set-trusted-proxies: -Solution: setTrustedProxies() ------------------------------ +Solution: ``setTrustedProxies()`` +--------------------------------- To fix this, you need to tell Symfony which reverse proxy IP addresses to trust and what headers your reverse proxy uses to send information:: diff --git a/doctrine/associations.rst b/doctrine/associations.rst index bf3b618f6c6..24a333c8a36 100644 --- a/doctrine/associations.rst +++ b/doctrine/associations.rst @@ -189,10 +189,10 @@ own a collection of its related ``Product`` objects. .. tip:: - The targetEntity value in the metadata used above can reference any entity + The ``targetEntity`` value in the metadata used above can reference any entity with a valid namespace, not just entities defined in the same namespace. To relate to an entity defined in a different class or bundle, enter a full - namespace as the targetEntity. + namespace as the ``targetEntity``. Now that you've added new properties to both the ``Product`` and ``Category`` classes, you must generate the missing getter and setter methods manually or diff --git a/doctrine/custom_dql_functions.rst b/doctrine/custom_dql_functions.rst index ad3a9bfc7e7..f8af5f86403 100644 --- a/doctrine/custom_dql_functions.rst +++ b/doctrine/custom_dql_functions.rst @@ -79,7 +79,7 @@ In Symfony, you can register your custom DQL functions as follows: .. note:: In case the ``entity_managers`` were named explicitly, configuring the functions with the - orm directly will trigger the exception `Unrecognized option "dql" under "doctrine.orm"`. + ORM directly will trigger the exception ``Unrecognized option "dql" under "doctrine.orm"``. The ``dql`` configuration block must be defined under the named entity manager. .. configuration-block:: diff --git a/email/spool.rst b/email/spool.rst index 040544c828c..ca7b89a76fd 100644 --- a/email/spool.rst +++ b/email/spool.rst @@ -21,7 +21,7 @@ Spool Using Memory When you use spooling to store the emails to memory, they will get sent right before the kernel terminates. This means the email only gets sent if the whole request got executed without any unhandled exception or any errors. To configure -swiftmailer with the memory option, use the following configuration: +Swift Mailer with the memory option, use the following configuration: .. configuration-block:: @@ -63,7 +63,7 @@ Spool Using Files When you use the filesystem for spooling, Symfony creates a folder in the given path for each mail service (e.g. "default" for the default service). This folder will contain files for each email in the spool. So make sure this directory is -writable by Symfony (or your webserver/php)! +writable by Symfony (or your webserver/PHP)! In order to use the spool with files, use the following configuration: @@ -145,7 +145,7 @@ interval. .. caution:: - When you create a message with SwiftMailer, it generates a ``Swift_Message`` + When you create a message with Swift Mailer, it generates a ``Swift_Message`` class. If the ``swiftmailer`` service is lazy loaded, it generates instead a proxy class named ``Swift_Message_``. diff --git a/event_dispatcher/before_after_filters.rst b/event_dispatcher/before_after_filters.rst index 98bb86d8c33..4b5a36bd401 100644 --- a/event_dispatcher/before_after_filters.rst +++ b/event_dispatcher/before_after_filters.rst @@ -174,7 +174,7 @@ After Filters with the ``kernel.response`` Event In addition to having a "hook" that's executed *before* your controller, you can also add a hook that's executed *after* your controller. For this example, -imagine that you want to add a sha1 hash (with a salt using that token) to +imagine that you want to add a ``sha1`` hash (with a salt using that token) to all responses that have passed this token authentication. Another core Symfony event - called ``kernel.response`` (aka ``KernelEvents::RESPONSE``) - diff --git a/form/csrf_protection.rst b/form/csrf_protection.rst index b46de4e67e9..8ad04acf224 100644 --- a/form/csrf_protection.rst +++ b/form/csrf_protection.rst @@ -21,7 +21,7 @@ Symfony automatically validates the presence and accuracy of this token. The ``_token`` field is a hidden field and will be automatically rendered if you include the ``form_end()`` function in your template, which ensures -that all un-rendered fields are output. +that all unrendered fields are output. .. caution:: diff --git a/form/data_transformers.rst b/form/data_transformers.rst index 5beffdd2282..5ad3d017739 100644 --- a/form/data_transformers.rst +++ b/form/data_transformers.rst @@ -7,7 +7,7 @@ How to Use Data Transformers Data transformers are used to translate the data for a field into a format that can be displayed in a form (and back on submit). They're already used internally for many field types. For example, the :doc:`DateType ` field -can be rendered as a ``yyyy-MM-dd``-formatted input textbox. Internally, a data transformer +can be rendered as a ``yyyy-MM-dd``-formatted input text box. Internally, a data transformer converts the starting ``DateTime`` value of the field into the ``yyyy-MM-dd`` string to render the form, and then back into a ``DateTime`` object on submit. @@ -120,9 +120,9 @@ Harder Example: Transforming an Issue Number into an Issue Entity ----------------------------------------------------------------- Say you have a many-to-one relation from the Task entity to an Issue entity (i.e. each -Task has an optional foreign key to its related Issue). Adding a listbox with all +Task has an optional foreign key to its related Issue). Adding a list box with all possible issues could eventually get *really* long and take a long time to load. -Instead, you decide you want to add a textbox, where the user can enter the issue number. +Instead, you decide you want to add a text box, where the user can enter the issue number. Start by setting up the text field like normal:: diff --git a/form/form_themes.rst b/form/form_themes.rst index bc0b1140e8a..9085e2031e2 100644 --- a/form/form_themes.rst +++ b/form/form_themes.rst @@ -132,10 +132,10 @@ Template Fragment Inheritance In some cases, the fragment you want to customize will appear to be missing. For example, there is no ``textarea_errors`` fragment in the default themes -provided with Symfony. So how are the errors for a textarea field rendered? +provided with Symfony. So how are the errors for a ``textarea`` field rendered? The answer is: via the ``form_errors`` fragment. When Symfony renders the errors -for a textarea type, it looks first for a ``textarea_errors`` fragment before +for a ``textarea`` type, it looks first for a ``textarea_errors`` fragment before falling back to the ``form_errors`` fragment. Each field type has a *parent* type (the parent type of ``textarea`` is ``text``, its parent is ``form``), and Symfony uses the fragment for the parent type if the base fragment doesn't diff --git a/frontend/encore/babel.rst b/frontend/encore/babel.rst index f7cba9a4892..a312fd60174 100644 --- a/frontend/encore/babel.rst +++ b/frontend/encore/babel.rst @@ -49,8 +49,8 @@ cache directory: # On Unix run this command. On Windows, clear this directory manually $ rm -rf node_modules/.cache/babel-loader/ -Creating a .babelrc File ------------------------- +Creating a ``.babelrc`` File +---------------------------- Instead of calling ``configureBabel()``, you could create a ``.babelrc`` file at the root of your project. This is a more "standard" way of configuring diff --git a/frontend/encore/postcss.rst b/frontend/encore/postcss.rst index e80f1f7d3c0..a6690bdf666 100644 --- a/frontend/encore/postcss.rst +++ b/frontend/encore/postcss.rst @@ -56,8 +56,8 @@ You can also pass options to the `postcss-loader`_ by passing a callback: .. _browserslist_package_config: -Adding browserslist to package.json ------------------------------------ +Adding browserslist to ``package.json`` +--------------------------------------- The ``autoprefixer`` (and many other tools) need to know what browsers you want to support. The best-practice is to configure this directly in your ``package.json`` diff --git a/frontend/encore/sourcemaps.rst b/frontend/encore/sourcemaps.rst index e46151a5e7f..62d4c6a351b 100644 --- a/frontend/encore/sourcemaps.rst +++ b/frontend/encore/sourcemaps.rst @@ -6,7 +6,8 @@ asset (e.g. the Sass code that was compiled to CSS or the TypeScript code that was compiled to JavaScript). Source maps are useful for debugging purposes but unnecessary when executing the application in production. -Encore's default ``webpack.config.js`` file enables sourcemaps in the ``dev`` build: +Encore's default ``webpack.config.js`` file enables source maps in the ``dev`` +build: .. code-block:: javascript diff --git a/frontend/encore/versioning.rst b/frontend/encore/versioning.rst index 79d06fabf9c..8776cda0ca8 100644 --- a/frontend/encore/versioning.rst +++ b/frontend/encore/versioning.rst @@ -25,8 +25,8 @@ To link to these assets, Encore creates two files ``entrypoints.json`` and .. _load-manifest-files: -Loading Assets from entrypoints.json & manifest.json ----------------------------------------------------- +Loading Assets from ``entrypoints.json`` & ``manifest.json`` +------------------------------------------------------------ Whenever you run Encore, two configuration files are generated: ``entrypoints.json`` and ``manifest.json``. Each file is similar, and contains a map to the final, versioned diff --git a/frontend/encore/versus-assetic.rst b/frontend/encore/versus-assetic.rst index 9f606ae48e3..afc2373b2b7 100644 --- a/frontend/encore/versus-assetic.rst +++ b/frontend/encore/versus-assetic.rst @@ -8,26 +8,26 @@ still works well. So what are the differences between Assetic and Encore? -+--------------------------+-------------------------------+-------------------------+ -| | Assetic | Encore + -+--------------------------+-------------------------------+-------------------------+ -| Language | Pure PHP, relies on other | Node.js | -| | language tools for some tasks | | -+--------------------------+-------------------------------+-------------------------+ -| Combine assets? | Yes | Yes | -+--------------------------+-------------------------------+-------------------------+ -| Minify assets? | Yes (when configured) | Yes (out-of-the-box) | -+--------------------------+-------------------------------+-------------------------+ -| Process Sass/Less? | Yes | Yes | -+--------------------------+-------------------------------+-------------------------+ -| Loads JS Modules? [1]_ | No | Yes | -+--------------------------+-------------------------------+-------------------------+ -| Load CSS Deps in JS? [1] | No | Yes | -+--------------------------+-------------------------------+-------------------------+ -| React, Vue.js support? | No [2]_ | Yes | -+--------------------------+-------------------------------+-------------------------+ -| Support | Not actively maintained | Actively maintained | -+--------------------------+-------------------------------+-------------------------+ ++----------------------------------+-------------------------------+-------------------------+ +| | Assetic | Encore + ++----------------------------------+-------------------------------+-------------------------+ +| Language | Pure PHP, relies on other | Node.js | +| | language tools for some tasks | | ++----------------------------------+-------------------------------+-------------------------+ +| Combine assets? | Yes | Yes | ++----------------------------------+-------------------------------+-------------------------+ +| Minify assets? | Yes (when configured) | Yes (out-of-the-box) | ++----------------------------------+-------------------------------+-------------------------+ +| Process Sass/Less? | Yes | Yes | ++----------------------------------+-------------------------------+-------------------------+ +| Loads JS Modules? [1]_ | No | Yes | ++----------------------------------+-------------------------------+-------------------------+ +| Load CSS dependencies in JS? [1] | No | Yes | ++----------------------------------+-------------------------------+-------------------------+ +| React, Vue.js support? | No [2]_ | Yes | ++----------------------------------+-------------------------------+-------------------------+ +| Support | Not actively maintained | Actively maintained | ++----------------------------------+-------------------------------+-------------------------+ .. [1] JavaScript modules allow you to organize your JavaScript into small files called modules and import them: diff --git a/frontend/encore/vuejs.rst b/frontend/encore/vuejs.rst index 191bb50324e..a92fa1b116b 100644 --- a/frontend/encore/vuejs.rst +++ b/frontend/encore/vuejs.rst @@ -1,5 +1,5 @@ -Enabling Vue.js (vue-loader) -============================ +Enabling Vue.js (``vue-loader``) +================================ Want to use `Vue.js`_? No problem! First enable it in ``webpack.config.js``: diff --git a/http_cache/form_csrf_caching.rst b/http_cache/form_csrf_caching.rst index df174616d90..6e031cc5be9 100644 --- a/http_cache/form_csrf_caching.rst +++ b/http_cache/form_csrf_caching.rst @@ -36,5 +36,5 @@ Another option would be to load the form via an uncached AJAX request, but cache the rest of the HTML response. Or you can even load just the CSRF token with an AJAX request and replace the -form field value with it. Take a look at :doc:`hinclude.js ` +form field value with it. Take a look at :doc:`HInclude ` for a nice solution. diff --git a/http_cache/validation.rst b/http_cache/validation.rst index d2f115f149f..68f0ce1c9cf 100644 --- a/http_cache/validation.rst +++ b/http_cache/validation.rst @@ -13,7 +13,7 @@ The validation model addresses this issue. Under this model, the cache continues to store responses. The difference is that, for each request, the cache asks the application if the cached response is still valid or if it needs to be regenerated. If the cache *is* still valid, your application should return a 304 status code -and no content. This tells the cache that it's ok to return the cached response. +and no content. This tells the cache that it's OK to return the cached response. Under this model, you only save CPU if you're able to determine that the cached response is still valid by doing *less* work than generating the whole @@ -48,7 +48,8 @@ An ``ETag`` is like a fingerprint and is used to quickly compare if two different versions of a resource are equivalent. Like fingerprints, each ``ETag`` must be unique across all representations of the same resource. -To see a simple implementation, generate the ETag as the md5 of the content:: +To see a simple implementation, generate the ``ETag`` as the ``md5`` of the +content:: // src/AppBundle/Controller/DefaultController.php namespace AppBundle\Controller; @@ -78,11 +79,11 @@ to 304. When using ``mod_deflate`` or ``mod_brotli`` in Apache 2.4, the original ``ETag`` value is modified (e.g. if ``ETag`` was ``foo``, Apache turns it - into ``foo-gzip`` or ``foo-br``), which breaks the ETag-based validation. + into ``foo-gzip`` or ``foo-br``), which breaks the ``ETag``-based validation. You can control this behavior with the `DeflateAlterETag`_ and `BrotliAlterETag`_ directives. Alternatively, you can use the following Apache configuration to - keep both the original ETag and the modified one when compressing responses: + keep both the original ``ETag`` and the modified one when compressing responses: .. code-block:: apache @@ -96,7 +97,7 @@ to 304. decide whether or not the resource has been updated since it was cached. This algorithm is simple enough and very generic, but you need to create the -whole ``Response`` before being able to compute the ETag, which is sub-optimal. +whole ``Response`` before being able to compute the ``ETag``, which is sub-optimal. In other words, it saves on bandwidth, but not CPU cycles. In the :ref:`optimizing-cache-validation` section, you'll see how validation @@ -105,7 +106,7 @@ doing so much work. .. tip:: - Symfony also supports weak ETags by passing ``true`` as the second + Symfony also supports weak ``ETag``s by passing ``true`` as the second argument to the :method:`Symfony\\Component\\HttpFoundation\\Response::setEtag` method. diff --git a/logging/channels_handlers.rst b/logging/channels_handlers.rst index 11dbd3bdb0f..92d35c073c3 100644 --- a/logging/channels_handlers.rst +++ b/logging/channels_handlers.rst @@ -120,7 +120,7 @@ You can specify the configuration by many forms: Creating your own Channel ------------------------- -You can change the channel monolog logs to one service at a time. This is done +You can change the channel Monolog logs to one service at a time. This is done either via the :ref:`configuration ` below or by tagging your service with :ref:`monolog.logger` and specifying which channel the service should log to. With the tag, the logger diff --git a/logging/monolog_console.rst b/logging/monolog_console.rst index 46bb96f2155..ab9132ee83d 100644 --- a/logging/monolog_console.rst +++ b/logging/monolog_console.rst @@ -49,7 +49,7 @@ The example above could then be rewritten as:: Depending on the verbosity level that the command is run in and the user's configuration (see below), these messages may or may not be displayed to the console. If they are displayed, they are timestamped and colored appropriately. -Additionally, error logs are written to the error output (php://stderr). +Additionally, error logs are written to the error output (``php://stderr``). There is no need to conditionally handle the verbosity settings anymore. The Monolog console handler is enabled by default in the Symfony Framework. For diff --git a/page_creation.rst b/page_creation.rst index c12b5c40757..c1dd58a5de5 100644 --- a/page_creation.rst +++ b/page_creation.rst @@ -235,7 +235,7 @@ What's Next? Congrats! You're already starting to master Symfony and learn a whole new way of building beautiful, functional, fast and maintainable applications. -Ok, time to finish mastering the fundamentals by reading these articles: +OK, time to finish mastering the fundamentals by reading these articles: * :doc:`/routing` * :doc:`/controller` diff --git a/performance.rst b/performance.rst index 5bf927cd07e..1feb0bd4025 100644 --- a/performance.rst +++ b/performance.rst @@ -163,8 +163,8 @@ possible solutions: .. _performance-configure-realpath-cache: -Configure the PHP realpath Cache -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Configure the PHP ``realpath`` Cache +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When a relative path is transformed into its real and absolute path, PHP caches the result to improve performance. Applications that open many PHP files, diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 55ae1e42ec3..0898d4d81f9 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -77,7 +77,7 @@ request:: Returns the collector identifier, which must be unique in the application. This value is used later to access the collector information (see :doc:`/testing/profiling`) so it's recommended to return a string which is - short, lowercased and without white spaces. + short, lowercase and without white spaces. .. _data_collector_tag: diff --git a/profiler/storage.rst b/profiler/storage.rst index 78bd45164f0..c4cb202a874 100644 --- a/profiler/storage.rst +++ b/profiler/storage.rst @@ -5,7 +5,7 @@ Switching the Profiler Storage ============================== In Symfony versions prior to 3.0, profiles could be stored in files, databases, -services like Redis and Memcache, etc. Starting from Symfony 3.0, the only storage +services like Redis and memcache, etc. Starting from Symfony 3.0, the only storage mechanism with built-in support is the filesystem. By default, the profile stores the collected data in the ``%kernel.cache_dir%/profiler/`` diff --git a/reference/configuration/assetic.rst b/reference/configuration/assetic.rst index c86b93840e4..4ab48915c01 100644 --- a/reference/configuration/assetic.rst +++ b/reference/configuration/assetic.rst @@ -6,7 +6,7 @@ Assetic Configuration Reference (AsseticBundle) .. include:: /assetic/_standard_edition_warning.rst.inc -You can get the full Asstic configuration reference as follows: +You can get the full Assetic configuration reference as follows: .. code-block:: terminal diff --git a/reference/configuration/debug.rst b/reference/configuration/debug.rst index 3799288e71f..bf23d951ea9 100644 --- a/reference/configuration/debug.rst +++ b/reference/configuration/debug.rst @@ -32,16 +32,20 @@ Configuration * `min_depth`_ * `max_string_length`_ -max_items -~~~~~~~~~ +``max_items`` +~~~~~~~~~~~~~ **type**: ``integer`` **default**: ``2500`` This is the maximum number of items to dump. Setting this option to ``-1`` disables the limit. -min_depth -~~~~~~~~~ +``min_depth`` +~~~~~~~~~~~~~ + +.. versionadded:: 3.4 + + The ``min_depth`` option was introduced in Symfony 3.4. **type**: ``integer`` **default**: ``1`` @@ -50,20 +54,16 @@ be cloned. After this depth is reached, only ``max_items`` items will be cloned. The default value is ``1``, which is consistent with older Symfony versions. -.. versionadded:: 3.4 - - The ``min_depth`` option was introduced in Symfony 3.4. - -max_string_length -~~~~~~~~~~~~~~~~~ +``max_string_length`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``integer`` **default**: ``-1`` This option configures the maximum string length before truncating the string. The default value (``-1``) means that strings are never truncated. -dump_destination -~~~~~~~~~~~~~~~~ +``dump_destination`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` diff --git a/reference/configuration/doctrine.rst b/reference/configuration/doctrine.rst index f06420c5dcc..8f9d402683d 100644 --- a/reference/configuration/doctrine.rst +++ b/reference/configuration/doctrine.rst @@ -247,14 +247,14 @@ Explicit definition of all the mapped entities is the only necessary configuration for the ORM and there are several configuration options that you can control. The following configuration options exist for a mapping: -type -.... +``type`` +........ One of ``annotation``, ``xml``, ``yml``, ``php`` or ``staticphp``. This specifies which type of metadata type your mapping uses. -dir -... +``dir`` +....... Path to the mapping or entity files (depending on the driver). If this path is relative, it is assumed to be relative to the bundle root. This only works @@ -262,8 +262,8 @@ if the name of your mapping is a bundle name. If you want to use this option to specify absolute paths you should prefix the path with the kernel parameters that exist in the DIC (for example ``%kernel.project_dir%``). -prefix -...... +``prefix`` +.......... A common namespace prefix that all entities of this mapping share. This prefix should never conflict with prefixes of other defined mappings otherwise @@ -271,15 +271,15 @@ some of your entities cannot be found by Doctrine. This option defaults to the bundle namespace + ``Entity``, for example for an application bundle called AcmeHelloBundle prefix would be ``Acme\HelloBundle\Entity``. -alias -..... +``alias`` +......... Doctrine offers a way to alias entity namespaces to simpler, shorter names to be used in DQL queries or for Repository access. When using a bundle the alias defaults to the bundle name. -is_bundle -......... +``is_bundle`` +............. This option is a derived value from ``dir`` and by default is set to ``true`` if dir is relative proved by a ``file_exists()`` check that returns ``false``. @@ -437,7 +437,7 @@ Default Value of Dir If ``dir`` is not specified, then its default value depends on which configuration driver is being used. For drivers that rely on the PHP files (annotation, -staticphp) it will be ``[Bundle]/Entity``. For drivers that are using +``staticphp``) it will be ``[Bundle]/Entity``. For drivers that are using configuration files (XML, YAML, ...) it will be ``[Bundle]/Resources/config/doctrine``. diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index b421a6c5d3a..d604127b48e 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -215,8 +215,8 @@ Configuration * `transitions`_ * :ref:`type ` -secret -~~~~~~ +``secret`` +~~~~~~~~~~ **type**: ``string`` **required** @@ -241,8 +241,8 @@ out all the application users. .. _configuration-framework-http_method_override: -http_method_override -~~~~~~~~~~~~~~~~~~~~ +``http_method_override`` +~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -276,13 +276,13 @@ named ``kernel.http_method_override``. .. _reference-framework-trusted-proxies: -trusted_proxies -~~~~~~~~~~~~~~~ +``trusted_proxies`` +~~~~~~~~~~~~~~~~~~~ The ``trusted_proxies`` option was removed in Symfony 3.3. See :doc:`/deployment/proxies`. -ide -~~~ +``ide`` +~~~~~~~ **type**: ``string`` **default**: ``null`` @@ -364,8 +364,8 @@ need to escape the percent signs (``%``) by doubling them. .. _reference-framework-test: -test -~~~~ +``test`` +~~~~~~~~ **type**: ``boolean`` @@ -380,8 +380,8 @@ setting should be present in your ``test`` environment (usually via .. _config-framework-default_locale: -default_locale -~~~~~~~~~~~~~~ +``default_locale`` +~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``en`` @@ -395,8 +395,8 @@ method. You can read more information about the default locale in :ref:`translation-default-locale`. -trusted_hosts -~~~~~~~~~~~~~ +``trusted_hosts`` +~~~~~~~~~~~~~~~~~ **type**: ``array`` | ``string`` **default**: ``[]`` @@ -470,13 +470,13 @@ can respond to any given host. .. _reference-framework-form: -form -~~~~ +``form`` +~~~~~~~~ .. _reference-form-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -495,8 +495,8 @@ settings is configured. For more details, see :doc:`/forms`. -csrf_protection -~~~~~~~~~~~~~~~ +``csrf_protection`` +~~~~~~~~~~~~~~~~~~~ .. seealso:: @@ -504,8 +504,8 @@ csrf_protection .. _reference-csrf_protection-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``true`` if form support is enabled, ``false`` otherwise @@ -517,8 +517,8 @@ If you're using forms, but want to avoid starting your session (e.g. using forms in an API-only website), ``csrf_protection`` will need to be set to ``false``. -esi -~~~ +``esi`` +~~~~~~~ .. seealso:: @@ -526,8 +526,8 @@ esi .. _reference-esi-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -566,8 +566,8 @@ You can also set ``esi`` to ``true`` to enable it: 'esi' => true, ]); -fragments -~~~~~~~~~ +``fragments`` +~~~~~~~~~~~~~ .. seealso:: @@ -576,8 +576,8 @@ fragments .. _reference-fragments-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -589,21 +589,21 @@ is configured. .. _reference-fragments-path: -path -.... +``path`` +........ **type**: ``string`` **default**: ``'/_fragment'`` The path prefix for fragments. The fragment listener will only be executed when the request starts with this path. -profiler -~~~~~~~~ +``profiler`` +~~~~~~~~~~~~ .. _reference-profiler-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -617,8 +617,8 @@ and ``test`` environments. the :doc:`WebProfilerBundle configuration ` on how to disable/enable the toolbar. -collect -....... +``collect`` +........... **type**: ``boolean`` **default**: ``true`` @@ -630,24 +630,24 @@ and activate the data collectors manually:: $profiler->enable(); -only_exceptions -............... +``only_exceptions`` +................... **type**: ``boolean`` **default**: ``false`` When this is set to ``true``, the profiler will only be enabled when an exception is thrown during the handling of the request. -only_master_requests -.................... +``only_master_requests`` +........................ **type**: ``boolean`` **default**: ``false`` When this is set to ``true``, the profiler will only be enabled on the master requests (and not on the subrequests). -dsn -... +``dsn`` +....... **type**: ``string`` **default**: ``'file:%kernel.cache_dir%/profiler'`` @@ -658,8 +658,8 @@ The DSN where to store the profiling information. See :doc:`/profiler/storage` for more information about the profiler storage. -matcher -....... +``matcher`` +........... .. caution:: @@ -673,8 +673,8 @@ instance, based on the `ip`_ or :ref:`path `. See :doc:`/profiler/matchers` for more information about using matchers to enable/disable the profiler. -ip -"" +``ip`` +"""""" **type**: ``string`` @@ -682,25 +682,25 @@ If set, the profiler will only be enabled when the current IP address matches. .. _reference-profiler-matcher-path: -path -"""" +``path`` +"""""""" **type**: ``string`` If set, the profiler will only be enabled when the current path matches. -service -""""""" +``service`` +""""""""""" **type**: ``string`` This setting contains the service id of a custom matcher. -request -~~~~~~~ +``request`` +~~~~~~~~~~~ -formats -....... +``formats`` +........... **type**: ``array`` **default**: ``[]`` @@ -759,11 +759,11 @@ To configure a ``jsonp`` format: ], ]); -router -~~~~~~ +``router`` +~~~~~~~~~~ -resource -........ +``resource`` +............ **type**: ``string`` **required** @@ -772,8 +772,8 @@ routes and imports the router should load. .. _reference-router-type: -type -.... +``type`` +........ **type**: ``string`` @@ -781,22 +781,22 @@ The type of the resource to hint the loaders about the format. This isn't needed when you use the default routers with the expected file extensions (``.xml``, ``.yml`` / ``.yaml``, ``.php``). -http_port -......... +``http_port`` +............. **type**: ``integer`` **default**: ``80`` The port for normal http requests (this is used when matching the scheme). -https_port -.......... +``https_port`` +.............. **type**: ``integer`` **default**: ``443`` The port for https requests (this is used when matching the scheme). -strict_requirements -................... +``strict_requirements`` +....................... **type**: ``mixed`` **default**: ``true`` @@ -818,11 +818,11 @@ The value can be one of: ``true`` is recommended in the development environment, while ``false`` or ``null`` might be preferred in production. -session -~~~~~~~ +``session`` +~~~~~~~~~~~ -storage_id -.......... +``storage_id`` +.............. **type**: ``string`` **default**: ``'session.storage.native'`` @@ -830,8 +830,8 @@ The service id used for session storage. The ``session.storage`` service alias will be set to this service id. This class has to implement :class:`Symfony\\Component\\HttpFoundation\\Session\\Storage\\SessionStorageInterface`. -handler_id -.......... +``handler_id`` +.............. **type**: ``string`` **default**: ``'session.handler.native_file'`` @@ -848,8 +848,8 @@ installation. .. _name: -name -.... +``name`` +........ **type**: ``string`` **default**: ``null`` @@ -857,8 +857,8 @@ This specifies the name of the session cookie. By default, it will use the cookie name which is defined in the ``php.ini`` with the ``session.name`` directive. -cookie_lifetime -............... +``cookie_lifetime`` +................... **type**: ``integer`` **default**: ``null`` @@ -867,16 +867,16 @@ This determines the lifetime of the session - in seconds. The default value will be used. Setting this value to ``0`` means the cookie is valid for the length of the browser session. -cookie_path -........... +``cookie_path`` +............... **type**: ``string`` **default**: ``/`` This determines the path to set in the session cookie. By default, it will use ``/``. -cache_limiter -............. +``cache_limiter`` +................. **type**: ``string`` or ``int`` **default**: ``''`` @@ -919,8 +919,8 @@ Unlike the other session options, ``cache_limiter`` is set as a regular 'cache_limiter' => 0, ]); -cookie_domain -............. +``cookie_domain`` +................. **type**: ``string`` **default**: ``''`` @@ -928,15 +928,15 @@ This determines the domain to set in the session cookie. By default, it's blank, meaning the host name of the server which generated the cookie according to the cookie specification. -cookie_secure -............. +``cookie_secure`` +................. **type**: ``boolean`` **default**: ``false`` This determines whether cookies should only be sent over secure connections. -cookie_httponly -............... +``cookie_httponly`` +................... **type**: ``boolean`` **default**: ``true`` @@ -945,15 +945,15 @@ protocol. This means that the cookie won't be accessible by scripting languages, such as JavaScript. This setting can effectively help to reduce identity theft through XSS attacks. -gc_divisor -.......... +``gc_divisor`` +.............. **type**: ``integer`` **default**: ``100`` See `gc_probability`_. -gc_probability -.............. +``gc_probability`` +.................. **type**: ``integer`` **default**: ``1`` @@ -962,8 +962,8 @@ started on every session initialization. The probability is calculated by using ``gc_probability`` / ``gc_divisor``, e.g. 1/100 means there is a 1% chance that the GC process will start on each request. -gc_maxlifetime -.............. +``gc_maxlifetime`` +.................. **type**: ``integer`` **default**: ``1440`` @@ -971,8 +971,8 @@ This determines the number of seconds after which data will be seen as "garbage" and potentially cleaned up. Garbage collection may occur during session start and depends on `gc_divisor`_ and `gc_probability`_. -save_path -......... +``save_path`` +............. **type**: ``string`` **default**: ``%kernel.cache_dir%/sessions`` @@ -1019,8 +1019,8 @@ setting the value to ``null``: .. _reference-session-metadata-update-threshold: -metadata_update_threshold -......................... +``metadata_update_threshold`` +............................. **type**: ``integer`` **default**: ``0`` @@ -1033,8 +1033,8 @@ changed. Previously, you needed to set this option to avoid that behavior. .. _reference-session-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``true`` @@ -1074,8 +1074,8 @@ Whether to enable the session support in the framework. ], ]); -use_cookies -........... +``use_cookies`` +............... **type**: ``boolean`` **default**: ``null`` @@ -1083,13 +1083,13 @@ This specifies if the session ID is stored on the client side using cookies or not. By default, it will use the value defined in the ``php.ini`` with the ``session.use_cookies`` directive. -assets -~~~~~~ +``assets`` +~~~~~~~~~~ .. _reference-assets-base-path: -base_path -......... +``base_path`` +............. **type**: ``string`` @@ -1134,8 +1134,8 @@ This option allows you to define a base path to be used for assets: .. _reference-templating-base-urls: .. _reference-assets-base-urls: -base_urls -......... +``base_urls`` +............. **type**: ``array`` @@ -1182,8 +1182,8 @@ collection each time it generates an asset's path: .. _reference-framework-assets-packages: -packages -........ +``packages`` +............ You can group assets into packages, to specify different base URLs for them: @@ -1251,8 +1251,8 @@ Each package can configure the following options: .. _reference-framework-assets-version: .. _ref-framework-assets-version: -version -....... +``version`` +........... **type**: ``string`` @@ -1326,8 +1326,8 @@ option. .. _reference-templating-version-format: .. _reference-assets-version-format: -version_format -.............. +``version_format`` +.................. **type**: ``string`` **default**: ``%%s?%%s`` @@ -1366,8 +1366,8 @@ is set to ``5``, the asset's path would be ``/images/logo.png?version=5``. .. _reference-assets-version-strategy: .. _reference-templating-version-strategy: -version_strategy -................ +``version_strategy`` +.................... **type**: ``string`` **default**: ``null`` @@ -1453,8 +1453,8 @@ individually for each asset package: .. _reference-assets-json-manifest-path: .. _reference-templating-json-manifest-path: -json_manifest_path -.................. +``json_manifest_path`` +...................... **type**: ``string`` **default**: ``null`` @@ -1550,11 +1550,11 @@ package: If you request an asset that is *not found* in the ``manifest.json`` file, the original - *unmodified* - asset path will be returned. -templating -~~~~~~~~~~ +``templating`` +~~~~~~~~~~~~~~ -hinclude_default_template -......................... +``hinclude_default_template`` +............................. **type**: ``string`` **default**: ``null`` @@ -1563,17 +1563,17 @@ is disabled. This can be either a template name or the content itself. .. seealso:: - See :doc:`/templating/hinclude` for more information about hinclude. + See :doc:`/templating/hinclude` for more information about HInclude. .. _reference-templating-form: -form -.... +``form`` +........ .. _reference-templating-form-resources: -resources -""""""""" +``resources`` +""""""""""""" **type**: ``string[]`` **default**: ``['FrameworkBundle:Form']`` @@ -1645,8 +1645,8 @@ Assume you have custom global form themes in .. _reference-templating-cache: -cache -..... +``cache`` +......... **type**: ``string`` @@ -1658,8 +1658,8 @@ is disabled. When using Twig templating, the caching is already handled by the TwigBundle and doesn't need to be enabled for the FrameworkBundle. -engines -....... +``engines`` +........... **type**: ``string[]`` / ``string`` **required** @@ -1668,8 +1668,8 @@ engine is configured) or an array of engines. At least one engine is required. -loaders -....... +``loaders`` +........... **type**: ``string[]`` @@ -1678,13 +1678,13 @@ templating loaders. Templating loaders are used to find and load templates from a resource (e.g. a filesystem or database). Templating loaders must implement :class:`Symfony\\Component\\Templating\\Loader\\LoaderInterface`. -translator -~~~~~~~~~~ +``translator`` +~~~~~~~~~~~~~~ .. _reference-translator-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -1692,8 +1692,8 @@ Whether or not to enable the ``translator`` service in the service container. .. _fallback: -fallbacks -......... +``fallbacks`` +............. **type**: ``string|array`` **default**: ``['en']`` @@ -1706,8 +1706,8 @@ found. .. _reference-framework-translator-logging: -logging -....... +``logging`` +........... **default**: ``true`` when the debug mode is enabled, ``false`` otherwise. @@ -1718,8 +1718,8 @@ locale and the ``warning`` level if there is no translation to use at all. .. _reference-framework-translator-formatter: -formatter -......... +``formatter`` +............. **type**: ``string`` **default**: ``translator.formatter.default`` @@ -1732,8 +1732,8 @@ must implement the :class:`Symfony\\Component\\Translation\\Formatter\\MessageFo .. _reference-translator-paths: -paths -..... +``paths`` +......... **type**: ``array`` **default**: ``[]`` @@ -1742,8 +1742,8 @@ for translation files. .. _reference-translator-default_path: -default_path -............ +``default_path`` +................ .. versionadded:: 3.4 @@ -1754,11 +1754,11 @@ default_path This option allows to define the path where the application translations files are stored. -property_access -~~~~~~~~~~~~~~~ +``property_access`` +~~~~~~~~~~~~~~~~~~~ -magic_call -.......... +``magic_call`` +.............. **type**: ``boolean`` **default**: ``false`` @@ -1766,31 +1766,31 @@ When enabled, the ``property_accessor`` service uses PHP's :ref:`magic __call() method ` when its ``getValue()`` method is called. -throw_exception_on_invalid_index -................................ +``throw_exception_on_invalid_index`` +.................................... **type**: ``boolean`` **default**: ``false`` When enabled, the ``property_accessor`` service throws an exception when you try to access an invalid index of an array. -property_info -~~~~~~~~~~~~~ +``property_info`` +~~~~~~~~~~~~~~~~~ .. _reference-property-info-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` -validation -~~~~~~~~~~ +``validation`` +~~~~~~~~~~~~~~ .. _reference-validation-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``true`` if :ref:`form support is enabled `, ``false`` otherwise @@ -1802,8 +1802,8 @@ settings is configured. .. _reference-validation-cache: -cache -..... +``cache`` +......... **type**: ``string`` @@ -1815,23 +1815,23 @@ cache provide from the Doctrine project. .. _reference-validation-enable_annotations: -enable_annotations -.................. +``enable_annotations`` +...................... **type**: ``boolean`` **default**: ``false`` If this option is enabled, validation constraints can be defined using annotations. -translation_domain -.................. +``translation_domain`` +...................... **type**: ``string`` **default**: ``validators`` The translation domain that is used when translating validation constraint error messages. -static_method -............. +``static_method`` +................. **type**: ``string | array`` **default**: ``['loadValidatorMetadata']`` @@ -1840,8 +1840,8 @@ metadata of the class. You can define an array of strings with the names of several methods. In that case, all of them will be called in that order to load the metadata. -strict_email -............ +``strict_email`` +................ **type**: ``Boolean`` **default**: ``false`` @@ -1851,26 +1851,26 @@ the validator uses a simple regular expression to validate email addresses. .. _reference-validation-mapping: -mapping -....... +``mapping`` +........... .. _reference-validation-mapping-paths: -paths -""""" +``paths`` +""""""""" **type**: ``array`` **default**: ``[]`` This option allows to define an array of paths with files or directories where the component will look for additional validation files. -annotations -~~~~~~~~~~~ +``annotations`` +~~~~~~~~~~~~~~~ .. _reference-annotations-cache: -cache -..... +``cache`` +......... **type**: ``string`` **default**: ``'file'`` @@ -1883,16 +1883,16 @@ none a service id A service id referencing a `Doctrine Cache`_ implementation -file_cache_dir -.............. +``file_cache_dir`` +.................. **type**: ``string`` **default**: ``'%kernel.cache_dir%/annotations'`` The directory to store cache files for annotations, in case ``annotations.cache`` is set to ``'file'``. -debug -..... +``debug`` +......... **type**: ``boolean`` **default**: ``%kernel.debug%`` @@ -1904,13 +1904,13 @@ default value. .. _configuration-framework-serializer: -serializer -~~~~~~~~~~ +``serializer`` +~~~~~~~~~~~~~~ .. _reference-serializer-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -1918,8 +1918,8 @@ Whether to enable the ``serializer`` service or not in the service container. .. _reference-serializer-cache: -cache -..... +``cache`` +......... **type**: ``string`` @@ -1932,8 +1932,8 @@ has to implement the ``Doctrine\Common\Cache\Cache`` interface. .. _reference-serializer-enable_annotations: -enable_annotations -.................. +``enable_annotations`` +...................... **type**: ``boolean`` **default**: ``false`` @@ -1945,8 +1945,8 @@ If this option is enabled, serialization groups can be defined using annotations .. _reference-serializer-name_converter: -name_converter -.............. +``name_converter`` +.................. **type**: ``string`` @@ -1962,8 +1962,8 @@ value. .. _reference-serializer-circular_reference_handler: -circular_reference_handler -.......................... +``circular_reference_handler`` +.............................. **type** ``string`` @@ -1978,24 +1978,24 @@ method. .. _reference-serializer-mapping: -mapping -....... +``mapping`` +........... .. _reference-serializer-mapping-paths: -paths -""""" +``paths`` +""""""""" **type**: ``array`` **default**: ``[]`` This option allows to define an array of paths with files or directories where the component will look for additional serialization files. -php_errors -~~~~~~~~~~ +``php_errors`` +~~~~~~~~~~~~~~ -log -... +``log`` +....... .. versionadded:: 3.2 @@ -2005,8 +2005,8 @@ log Use the application logger instead of the PHP logger for logging PHP errors. -throw -..... +``throw`` +......... .. versionadded:: 3.2 @@ -2019,13 +2019,13 @@ Throw PHP errors as ``\ErrorException`` instances. The parameter .. _reference-cache: -cache -~~~~~ +``cache`` +~~~~~~~~~ .. _reference-cache-app: -app -... +``app`` +....... **type**: ``string`` **default**: ``cache.adapter.filesystem`` @@ -2043,48 +2043,48 @@ ships with multiple adapters: ``cache.adapter.apcu``, ``cache.adapter.doctrine`` .. _reference-cache-system: -system -...... +``system`` +.......... **type**: ``string`` **default**: ``cache.adapter.system`` The cache adapter used by the ``cache.system`` service. It supports the same adapters available for the ``cache.app`` service. -directory -......... +``directory`` +............. **type**: ``string`` **default**: ``%kernel.cache_dir%/pools`` The path to the cache directory used by services inheriting from the ``cache.adapter.filesystem`` adapter (including ``cache.app``). -default_doctrine_provider -......................... +``default_doctrine_provider`` +............................. **type**: ``string`` The service name to use as your default Doctrine provider. The provider is available as the ``cache.default_doctrine_provider`` service. -default_psr6_provider -..................... +``default_psr6_provider`` +......................... **type**: ``string`` The service name to use as your default PSR-6 provider. It is available as the ``cache.default_psr6_provider`` service. -default_redis_provider -...................... +``default_redis_provider`` +.......................... **type**: ``string`` **default**: ``redis://localhost`` The DSN to use by the Redis provider. The provider is available as the ``cache.default_redis_provider`` service. -default_memcached_provider -.......................... +``default_memcached_provider`` +.............................. .. versionadded:: 3.3 @@ -2095,8 +2095,8 @@ default_memcached_provider The DSN to use by the Memcached provider. The provider is available as the ``cache.default_memcached_provider`` service. -pools -..... +``pools`` +......... **type**: ``array`` @@ -2159,8 +2159,8 @@ To configure a Redis cache pool with a default lifetime of 1 hour, do the follow .. _reference-cache-pools-name: -name -"""" +``name`` +"""""""" **type**: ``prototype`` @@ -2170,8 +2170,8 @@ Name of the pool you want to create. Your pool name must differ from ``cache.app`` or ``cache.system``. -adapter -""""""" +``adapter`` +""""""""""" **type**: ``string`` **default**: ``cache.app`` @@ -2184,22 +2184,22 @@ settings from the base pool as defaults. Your service MUST implement the ``Psr\Cache\CacheItemPoolInterface`` interface. -public -"""""" +``public`` +"""""""""" **type**: ``boolean`` **default**: ``false`` Whether your service should be public or not. -default_lifetime -"""""""""""""""" +``default_lifetime`` +"""""""""""""""""""" **type**: ``integer`` Default lifetime of your cache items in seconds. -provider -"""""""" +``provider`` +"""""""""""" **type**: ``string`` @@ -2208,8 +2208,8 @@ use what is configured as ``default_X_provider`` under ``cache``. See the description of the default provider setting above for the type of adapter you use for information on how to specify the provider. -clearer -""""""" +``clearer`` +""""""""""" **type**: ``string`` @@ -2219,8 +2219,8 @@ The cache clearer used to clear your PSR-6 cache. For more information, see :class:`Symfony\\Component\\HttpKernel\\CacheClearer\\Psr6CacheClearer`. -prefix_seed -........... +``prefix_seed`` +............... .. versionadded:: 3.2 @@ -2240,8 +2240,8 @@ example, when warming caches offline). .. _reference-lock: -lock -~~~~ +``lock`` +~~~~~~~~ **type**: ``string`` | ``array`` @@ -2250,8 +2250,8 @@ available, or to ``flock`` otherwise. Store's DSN are also allowed. .. _reference-lock-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``true`` @@ -2260,8 +2260,8 @@ automatically set to ``true`` when one of the child settings is configured. .. _reference-lock-resources: -resources -......... +``resources`` +............. **type**: ``array`` @@ -2349,8 +2349,8 @@ A list of lock stores to be created by the framework extension. .. _reference-lock-resources-name: -name -"""" +``name`` +"""""""" **type**: ``prototype`` @@ -2368,8 +2368,8 @@ Name of the lock you want to create. decorates: lock.invoice.store arguments: ['@lock.invoice.retry.till.save.store.inner', 100, 50] -workflows -~~~~~~~~~ +``workflows`` +~~~~~~~~~~~~~ **type**: ``array`` @@ -2420,8 +2420,8 @@ A list of workflows to be created by the framework extension: .. _reference-workflows-enabled: -enabled -....... +``enabled`` +........... **type**: ``boolean`` **default**: ``false`` @@ -2430,31 +2430,31 @@ automatically set to ``true`` when one of the child settings is configured. .. _reference-workflows-name: -name -.... +``name`` +........ **type**: ``prototype`` Name of the workflow you want to create. -audit_trail -""""""""""" +``audit_trail`` +""""""""""""""" **type**: ``bool`` If set to ``true``, the :class:`Symfony\\Component\\Workflow\\EventListener\\AuditTrailListener` will be enabled. -initial_place -""""""""""""" +``initial_place`` +""""""""""""""""" **type**: ``string`` **default**: ``null`` One of the ``places`` or ``null``. If not null and the supported object is not already initialized via the workflow, this place will be set. -marking_store -""""""""""""" +``marking_store`` +""""""""""""""""" **type**: ``array`` @@ -2465,28 +2465,28 @@ Each marking store can define any of these options: * ``type`` (**type**: ``string`` **possible values**: ``'multiple_state'`` or ``'single_state'``) -places -"""""" +``places`` +"""""""""" **type**: ``array`` All available places (**type**: ``string``) for the workflow configuration. -supports -"""""""" +``supports`` +"""""""""""" **type**: ``string`` | ``array`` The FQCN (fully-qualified class name) of the object supported by the workflow configuration or an array of FQCN if multiple objects are supported. -support_strategy -"""""""""""""""" +``support_strategy`` +"""""""""""""""""""" **type**: ``string`` -transitions -""""""""""" +``transitions`` +""""""""""""""" **type**: ``array`` @@ -2502,8 +2502,8 @@ Each marking store can define any of these options: .. _reference-workflows-type: -type -"""" +``type`` +"""""""" **type**: ``string`` **possible values**: ``'workflow'`` or ``'state_machine'`` diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 074bb55f68f..99eaa1e5f93 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -45,16 +45,16 @@ separate articles: * `providers`_ * `role_hierarchy`_ -access_denied_url -~~~~~~~~~~~~~~~~~ +``access_denied_url`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` Defines the URL where the user is redirected after a ``403`` HTTP error (unless you define a custom access deny handler). Example: ``/no-permission`` -always_authenticate_before_granting -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``always_authenticate_before_granting`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -62,16 +62,16 @@ If ``true``, the user is asked to authenticate before each call to the ``isGranted()`` method in services and controllers or ``is_granted()`` from templates. -erase_credentials -~~~~~~~~~~~~~~~~~ +``erase_credentials`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` If ``true``, the ``eraseCredentials()`` method of the user object is called after authentication. -hide_user_not_found -~~~~~~~~~~~~~~~~~~~ +``hide_user_not_found`` +~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -83,8 +83,8 @@ If ``false``, the exception thrown is of type :class:`Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException` and it includes the given not found username. -session_fixation_strategy -~~~~~~~~~~~~~~~~~~~~~~~~~ +``session_fixation_strategy`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``SessionAuthenticationStrategy::MIGRATE`` @@ -102,8 +102,8 @@ The possible values of this option are: The entire session is regenerated, so the session ID is updated but all the other session attributes are lost. -access_control --------------- +``access_control`` +------------------ Defines the security protection of the URLs of your application. It's used for example to trigger the user authentication when trying to access to the backend @@ -111,8 +111,8 @@ and to allow anonymous users to the login form page. This option is explained in detail in :doc:`/security/access_control`. -acl ---- +``acl`` +------- This option is used to define `ACL (Access Control List)`_, which allow to associate a list of permissions to an object. This option is deprecated since @@ -122,8 +122,8 @@ Instead of using ACLs, Symfony recommends :doc:`security voters `". -check_path -.......... +``check_path`` +.............. **type**: ``string`` **default**: ``/login_check`` @@ -418,16 +418,16 @@ URL and process the submitted login credentials. Be sure that this URL is covered by your main firewall (i.e. don't create a separate firewall just for ``check_path`` URL). -use_forward -........... +``use_forward`` +............... **type**: ``boolean`` **default**: ``false`` If you'd like the user to be forwarded to the login form instead of being redirected, set this option to ``true``. -username_parameter -.................. +``username_parameter`` +...................... **type**: ``string`` **default**: ``_username`` @@ -435,8 +435,8 @@ This is the field name that you should give to the username field of your login form. When you submit the form to ``check_path``, the security system will look for a POST parameter with this name. -password_parameter -.................. +``password_parameter`` +...................... **type**: ``string`` **default**: ``_password`` @@ -444,8 +444,8 @@ This is the field name that you should give to the password field of your login form. When you submit the form to ``check_path``, the security system will look for a POST parameter with this name. -post_only -......... +``post_only`` +............. **type**: ``boolean`` **default**: ``true`` @@ -455,32 +455,32 @@ request to the ``check_path`` URL. **Options Related to Redirecting after Login** -always_use_default_target_path -.............................. +``always_use_default_target_path`` +.................................. **type**: ``boolean`` **default**: ``false`` If ``true``, users are always redirected to the default target path regardless of the previous URL that was stored in the session. -default_target_path -.................... +``default_target_path`` +........................ **type**: ``string`` **default**: ``/`` The page users are redirected to when there is no previous page stored in the session (for example, when the users browse the login page directly). -target_path_parameter -..................... +``target_path_parameter`` +......................... **type**: ``string`` **default**: ``_target_path`` When using a login form, if you include an HTML element to set the target path, this option lets you change the name of the HTML element itself. -use_referer -........... +``use_referer`` +............... **type**: ``boolean`` **default**: ``false`` @@ -496,8 +496,8 @@ redirected to the ``default_target_path`` to avoid a redirection loop. **Options Related to Logout Configuration** -invalidate_session -~~~~~~~~~~~~~~~~~~ +``invalidate_session`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -509,8 +509,8 @@ The ``invalidate_session`` option allows to redefine this behavior. Set this option to ``false`` in every firewall and the user will only be logged out from the current firewall and not the other ones. -logout_on_user_change -~~~~~~~~~~~~~~~~~~~~~ +``logout_on_user_change`` +~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -528,8 +528,8 @@ The user is considered to have changed when the user class implements required by the :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface` (like the username, password or salt) changes. -success_handler -~~~~~~~~~~~~~~~ +``success_handler`` +~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``'security.logout.success_handler'`` @@ -557,15 +557,15 @@ You can authenticate to an LDAP server using the LDAP variants of the Both authentication providers have the same arguments as their normal counterparts, with the addition of two configuration keys: -service -....... +``service`` +........... **type**: ``string`` **default**: ``ldap`` This is the name of your configured LDAP client. -dn_string -......... +``dn_string`` +............. **type**: ``string`` **default**: ``{username}`` @@ -574,8 +574,8 @@ placeholder will be replaced with the user-provided value (their login). Depending on your LDAP server's configuration, you may need to override this value. -query_string -............ +``query_string`` +................ **type**: ``string`` **default**: ``null`` @@ -748,8 +748,8 @@ a ``user_checker`` option to define the service used to perform those checks. Learn more about user checkers in :doc:`/security/user_checkers`. -providers ---------- +``providers`` +------------- This options defines how the application users are loaded (from a database, an LDAP server, a configuration file, etc.) Read the following articles to learn @@ -760,8 +760,8 @@ more about each of those providers: * :ref:`Load users from a configuration file ` * :doc:`Create your own user provider ` -role_hierarchy --------------- +``role_hierarchy`` +------------------ Instead of associating many roles to users, this option allows you to define role inheritance rules by creating a role hierarchy, as explained in diff --git a/reference/configuration/swiftmailer.rst b/reference/configuration/swiftmailer.rst index 6af38c14f99..dd6033438f2 100644 --- a/reference/configuration/swiftmailer.rst +++ b/reference/configuration/swiftmailer.rst @@ -4,7 +4,7 @@ Mailer Configuration Reference (SwiftmailerBundle) ================================================== -The SwiftmailerBundle integrates the Swiftmailer library in Symfony applications +The SwiftmailerBundle integrates the Swift Mailer library in Symfony applications to :doc:`send emails `. All these options are configured under the ``swiftmailer`` key in your application configuration. @@ -55,112 +55,112 @@ Configuration * `url`_ * `username`_ -url -~~~ +``url`` +~~~~~~~ **type**: ``string`` -The entire SwiftMailer configuration using a DSN-like URL format. +The entire Swift Mailer configuration using a DSN-like URL format. Example: ``smtp://user:pass@host:port/?timeout=60&encryption=ssl&auth_mode=login&...`` -transport -~~~~~~~~~ +``transport`` +~~~~~~~~~~~~~ **type**: ``string`` **default**: ``smtp`` The exact transport method to use to deliver emails. Valid values are: -* smtp -* gmail (see :doc:`/email/gmail`) -* mail (deprecated in SwiftMailer since version 5.4.5) -* sendmail -* null (same as setting `disable_delivery`_ to ``true``) +* ``smtp`` +* ``gmail`` (see :doc:`/email/gmail`) +* ``mail`` (deprecated in Swift Mailer since version 5.4.5) +* ``sendmail`` +* ``null`` (same as setting `disable_delivery`_ to ``true``) -username -~~~~~~~~ +``username`` +~~~~~~~~~~~~ **type**: ``string`` The username when using ``smtp`` as the transport. -password -~~~~~~~~ +``password`` +~~~~~~~~~~~~ **type**: ``string`` The password when using ``smtp`` as the transport. -command -~~~~~~~~ +``command`` +~~~~~~~~~~~~ **type**: ``string`` **default**: ``/usr/sbin/sendmail -bs`` Command to be executed by ``sendmail`` transport. -host -~~~~ +``host`` +~~~~~~~~ **type**: ``string`` **default**: ``localhost`` The host to connect to when using ``smtp`` as the transport. -port -~~~~ +``port`` +~~~~~~~~ **type**: ``string`` **default**: 25 or 465 (depending on `encryption`_) The port when using ``smtp`` as the transport. This defaults to 465 if encryption is ``ssl`` and 25 otherwise. -timeout -~~~~~~~ +``timeout`` +~~~~~~~~~~~ **type**: ``integer`` The timeout in seconds when using ``smtp`` as the transport. -source_ip -~~~~~~~~~ +``source_ip`` +~~~~~~~~~~~~~ **type**: ``string`` The source IP address when using ``smtp`` as the transport. -local_domain -~~~~~~~~~~~~ - -**type**: ``string`` +``local_domain`` +~~~~~~~~~~~~~~~~ .. versionadded:: 2.4.0 The ``local_domain`` option was introduced in SwiftMailerBundle 2.4.0. +**type**: ``string`` + The domain name to use in ``HELO`` command. -encryption -~~~~~~~~~~ +``encryption`` +~~~~~~~~~~~~~~ **type**: ``string`` The encryption mode to use when using ``smtp`` as the transport. Valid values are ``tls``, ``ssl``, or ``null`` (indicating no encryption). -auth_mode -~~~~~~~~~ +``auth_mode`` +~~~~~~~~~~~~~ **type**: ``string`` The authentication mode to use when using ``smtp`` as the transport. Valid values are ``plain``, ``login``, ``cram-md5``, or ``null``. -spool -~~~~~ +``spool`` +~~~~~~~~~ For details on email spooling, see :doc:`/email/spool`. -type -.... +``type`` +........ **type**: ``string`` **default**: ``file`` @@ -168,16 +168,16 @@ The method used to store spooled messages. Valid values are ``memory`` and ``file``. A custom spool should be possible by creating a service called ``swiftmailer.spool.myspool`` and setting this value to ``myspool``. -path -.... +``path`` +........ **type**: ``string`` **default**: ``%kernel.cache_dir%/swiftmailer/spool`` When using the ``file`` spool, this is the path where the spooled messages will be stored. -sender_address -~~~~~~~~~~~~~~ +``sender_address`` +~~~~~~~~~~~~~~~~~~ **type**: ``string`` @@ -185,19 +185,19 @@ If set, all messages will be delivered with this address as the "return path" address, which is where bounced messages should go. This is handled internally by Swift Mailer's ``Swift_Plugins_ImpersonatePlugin`` class. -antiflood -~~~~~~~~~ +``antiflood`` +~~~~~~~~~~~~~ -threshold -......... +``threshold`` +............. **type**: ``integer`` **default**: ``99`` Used with ``Swift_Plugins_AntiFloodPlugin``. This is the number of emails to send before restarting the transport. -sleep -..... +``sleep`` +......... **type**: ``integer`` **default**: ``0`` @@ -206,8 +206,8 @@ to sleep for during a transport restart. .. _delivery-address: -delivery_addresses -~~~~~~~~~~~~~~~~~~ +``delivery_addresses`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``array`` @@ -223,8 +223,8 @@ that all emails sent during development go to one or more some specific accounts This uses ``Swift_Plugins_RedirectingPlugin``. Original recipients are available on the ``X-Swift-To``, ``X-Swift-Cc`` and ``X-Swift-Bcc`` headers. -delivery_whitelist -~~~~~~~~~~~~~~~~~~ +``delivery_whitelist`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``array`` @@ -234,16 +234,16 @@ of these patterns will be delivered like normal, as well as being sent to :ref:`How to Work with Emails during Development ` article. -disable_delivery -~~~~~~~~~~~~~~~~ +``disable_delivery`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` If true, the ``transport`` will automatically be set to ``null`` and no emails will actually be delivered. -logging -~~~~~~~ +``logging`` +~~~~~~~~~~~ **type**: ``boolean`` **default**: ``%kernel.debug%`` diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index c992686fcf6..5c18bef30c4 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -52,8 +52,8 @@ Configuration * `paths`_ * `strict_variables`_ -auto_reload -~~~~~~~~~~~ +``auto_reload`` +~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``%kernel.debug%`` @@ -61,8 +61,8 @@ If ``true``, whenever a template is rendered, Symfony checks first if its source code has changed since it was compiled. If it has changed, the template is compiled again automatically. -autoescape -~~~~~~~~~~ +``autoescape`` +~~~~~~~~~~~~~~ **type**: ``boolean`` or ``string`` **default**: ``'name'`` @@ -87,8 +87,8 @@ templates and ``js`` for ``*.js.html`` templates). See `autoescape_service`_ and `autoescape_service_method`_ to define your own escaping strategy. -autoescape_service -~~~~~~~~~~~~~~~~~~ +``autoescape_service`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` @@ -100,16 +100,16 @@ for HTML and the contents of ``*.js.twig`` are escaped for JavaScript. This option allows to define the Symfony service which will be used to determine the default escaping applied to the template. -autoescape_service_method -~~~~~~~~~~~~~~~~~~~~~~~~~ +``autoescape_service_method`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` If ``autoescape_service`` option is defined, then this option defines the method called to determine the default escaping applied to the template. -base_template_class -~~~~~~~~~~~~~~~~~~~ +``base_template_class`` +~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``'Twig\Template'`` @@ -118,8 +118,8 @@ contents. This option defines the base class from which all the template classes extend. Using a custom base template is discouraged because it will make your application harder to maintain. -cache -~~~~~ +``cache`` +~~~~~~~~~ **type**: ``string`` | ``false`` **default**: ``'%kernel.cache_dir%/twig'`` @@ -132,47 +132,47 @@ is not recommended; not even in the ``dev`` environment, because the ``auto_reload`` option ensures that cached templates which have changed get compiled again. -charset -~~~~~~~ +``charset`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``'%kernel.charset%'`` The charset used by the template files. In the Symfony Standard edition this defaults to the ``UTF-8`` charset. -date -~~~~ +``date`` +~~~~~~~~ These options define the default values used by the ``date`` filter to format date and time values. They are useful to avoid passing the same arguments on every ``date`` filter call. -format -...... +``format`` +.......... **type**: ``string`` **default**: ``F j, Y H:i`` The format used by the ``date`` filter to display values when no specific format is passed as argument. -interval_format -............... +``interval_format`` +................... **type**: ``string`` **default**: ``%d days`` The format used by the ``date`` filter to display ``DateInterval`` instances when no specific format is passed as argument. -timezone -........ +``timezone`` +............ **type**: ``string`` **default**: (the value returned by ``date_default_timezone_get()``) The timezone used when formatting date values with the ``date`` filter and no specific timezone is passed as argument. -debug -~~~~~ +``debug`` +~~~~~~~~~ **type**: ``boolean`` **default**: ``%kernel.debug%`` @@ -181,8 +181,8 @@ be used to display their nodes. .. _config-twig-exception-controller: -exception_controller -~~~~~~~~~~~~~~~~~~~~ +``exception_controller`` +~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``twig.controller.exception:showAction`` @@ -195,23 +195,23 @@ option is advanced. If you need to customize an error page you should use the previous link. If you need to perform some behavior on an exception, you should add a listener to the ``kernel.exception`` event (see :ref:`dic-tags-kernel-event-listener`). -number_format -~~~~~~~~~~~~~ +``number_format`` +~~~~~~~~~~~~~~~~~ These options define the default values used by the ``number_format`` filter to format numeric values. They are useful to avoid passing the same arguments on every ``number_format`` filter call. -decimals -........ +``decimals`` +............ **type**: ``integer`` **default**: ``0`` The number of decimals used to format numeric values when no specific number is passed as argument to the ``number_format`` filter. -decimal_point -............. +``decimal_point`` +................. **type**: ``string`` **default**: ``.`` @@ -219,16 +219,16 @@ The character used to separate the decimals from the integer part of numeric values when no specific character is passed as argument to the ``number_format`` filter. -thousands_separator -................... +``thousands_separator`` +....................... **type**: ``string`` **default**: ``,`` The character used to separate every group of thousands in numeric values when no specific character is passed as argument to the ``number_format`` filter. -optimizations -~~~~~~~~~~~~~ +``optimizations`` +~~~~~~~~~~~~~~~~~ **type**: ``int`` **default**: ``-1`` @@ -243,8 +243,8 @@ on. Set it to ``0`` to disable all the optimizations. You can even enable or disable these optimizations selectively, as explained in the Twig documentation about `the optimizer extension`_. -default_path -~~~~~~~~~~~~ +``default_path`` +~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``'%kernel.project_dir%/templates'`` @@ -256,8 +256,8 @@ The default directory where Symfony will look for Twig templates. .. _config-twig-paths: -paths -~~~~~ +``paths`` +~~~~~~~~~ **type**: ``array`` **default**: ``null`` @@ -360,8 +360,8 @@ by Symfony. Besides, it simplifies how you refer to those templates: @foo_bar/template_name.html.twig -strict_variables -~~~~~~~~~~~~~~~~ +``strict_variables`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/configuration/web_profiler.rst b/reference/configuration/web_profiler.rst index f8c8cc951d5..8772bb225bf 100644 --- a/reference/configuration/web_profiler.rst +++ b/reference/configuration/web_profiler.rst @@ -38,8 +38,8 @@ Configuration * `toolbar`_ * `verbose`_ -toolbar -~~~~~~~ +``toolbar`` +~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -47,8 +47,8 @@ It enables and disables the toolbar entirely. Usually you set this to ``true`` in the ``dev`` and ``test`` environments and to ``false`` in the ``prod`` environment. -position -~~~~~~~~ +``position`` +~~~~~~~~~~~~ .. deprecated:: 3.4 @@ -60,8 +60,8 @@ position It defines the location of the browser window where the toolbar is displayed. the only allowed values are ``bottom`` and ``top``. -intercept_redirects -~~~~~~~~~~~~~~~~~~~ +``intercept_redirects`` +~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -74,8 +74,8 @@ redirection and shows you the URL which is going to redirect to, its toolbar, and its profiler. Once you've inspected the toolbar/profiler data, you can click on the given link to perform the redirect. -excluded_ajax_paths -~~~~~~~~~~~~~~~~~~~ +``excluded_ajax_paths`` +~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``'^/(app(_[\\w]+)?\\.php/)?_wdt'`` @@ -84,8 +84,8 @@ expression. If the URL matches, the request is not displayed in the toolbar. Thi is useful when the application makes lots of AJAX requests, or if they are heavy and you want to exclude some of them. -verbose -~~~~~~~ +``verbose`` +~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/constraints/All.rst b/reference/constraints/All.rst index bdbb58add3e..418762b214c 100644 --- a/reference/constraints/All.rst +++ b/reference/constraints/All.rst @@ -102,8 +102,8 @@ be blank and to be at least 5 characters long. Options ------- -constraints -~~~~~~~~~~~ +``constraints`` +~~~~~~~~~~~~~~~ **type**: ``array`` [:ref:`default option `] diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index efc56dd965c..713d33fbb15 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -81,13 +81,13 @@ will contain a Business Identifier Code (BIC). .. include:: /reference/constraints/_empty-values-are-valid.rst.inc -Available Options ------------------ +Options +------- .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This is not a valid Business Identifier Code (BIC).`` diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 20dedfe5444..cedbf071534 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -92,8 +92,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be blank.`` diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 1331631cb26..08453614edb 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -259,8 +259,8 @@ Options .. _callback-option: -callback -~~~~~~~~ +``callback`` +~~~~~~~~~~~~ **type**: ``string``, ``array`` or ``Closure`` [:ref:`default option `] diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index b186d9245fe..dcf44a844c2 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -102,8 +102,8 @@ Available Options .. include:: /reference/constraints/_groups-option.rst.inc -schemes -~~~~~~~ +``schemes`` +~~~~~~~~~~~ **type**: ``mixed`` [:ref:`default option `] @@ -125,8 +125,8 @@ Valid values are: For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_. -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``Unsupported card type or invalid card number.`` diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 65378aec8c3..acb88f36eaa 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -285,8 +285,8 @@ you can pass the class name and the method as an array. Available Options ----------------- -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **type**: ``array`` [:ref:`default option `] @@ -294,8 +294,8 @@ A required option (unless `callback`_ is specified) - this is the array of options that should be considered in the valid set. The input value will be matched against this array. -callback -~~~~~~~~ +``callback`` +~~~~~~~~~~~~ **type**: ``string|array|Closure`` @@ -305,8 +305,8 @@ to return the choices array. See .. include:: /reference/constraints/_groups-option.rst.inc -multiple -~~~~~~~~ +``multiple`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -315,8 +315,8 @@ of a single, scalar value. The constraint will check that each value of the input array can be found in the array of valid choices. If even one of the input values cannot be found, the validation will fail. -min -~~~ +``min`` +~~~~~~~ **type**: ``integer`` @@ -325,8 +325,8 @@ to force at least XX number of values to be selected. For example, if ``min`` is 3, but the input array only contains 2 valid items, the validation will fail. -max -~~~ +``max`` +~~~~~~~ **type**: ``integer`` @@ -335,8 +335,8 @@ to force no more than XX number of values to be selected. For example, if ``max`` is 3, but the input array contains 4 valid items, the validation will fail. -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``The value you selected is not a valid choice.`` @@ -352,8 +352,8 @@ You can use the following parameters in this message: | ``{{ value }}`` | The current (invalid) value | +------------------+------------------------------------------------+ -multipleMessage -~~~~~~~~~~~~~~~ +``multipleMessage`` +~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``One or more of the given values is invalid.`` @@ -369,8 +369,8 @@ You can use the following parameters in this message: | ``{{ value }}`` | The current (invalid) value | +------------------+------------------------------------------------+ -minMessage -~~~~~~~~~~ +``minMessage`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``You must select at least {{ limit }} choices.`` @@ -385,8 +385,8 @@ You can use the following parameters in this message: | ``{{ limit }}`` | The lower limit of choices | +------------------+------------------------------------------------+ -maxMessage -~~~~~~~~~~ +``maxMessage`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``You must select at most {{ limit }} choices.`` @@ -401,8 +401,8 @@ You can use the following parameters in this message: | ``{{ limit }}`` | The upper limit of choices | +------------------+------------------------------------------------+ -strict -~~~~~~ +``strict`` +~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/constraints/Collection.rst b/reference/constraints/Collection.rst index 9984e3885e0..a296f68dc3e 100644 --- a/reference/constraints/Collection.rst +++ b/reference/constraints/Collection.rst @@ -290,27 +290,27 @@ the ``NotBlank`` constraint will still be applied (since it is wrapped in Options ------- -allowExtraFields -~~~~~~~~~~~~~~~~ +``allowExtraFields`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: false If this option is set to ``false`` and the underlying collection contains one or more elements that are not included in the `fields`_ option, a validation -error will be returned. If set to ``true``, extra fields are ok. +error will be returned. If set to ``true``, extra fields are OK. -allowMissingFields -~~~~~~~~~~~~~~~~~~ +``allowMissingFields`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: false If this option is set to ``false`` and one or more fields from the `fields`_ option are not present in the underlying collection, a validation error -will be returned. If set to ``true``, it's ok if some fields in the `fields`_ +will be returned. If set to ``true``, it's OK if some fields in the `fields`_ option are not present in the underlying collection. -extraFieldsMessage -~~~~~~~~~~~~~~~~~~ +``extraFieldsMessage`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This field was not expected.`` @@ -325,8 +325,8 @@ You can use the following parameters in this message: | ``{{ field }}`` | The key of the extra field detected | +------------------+------------------------------------------------+ -fields -~~~~~~ +``fields`` +~~~~~~~~~~ **type**: ``array`` [:ref:`default option `] @@ -336,8 +336,8 @@ be executed against that element of the collection. .. include:: /reference/constraints/_groups-option.rst.inc -missingFieldsMessage -~~~~~~~~~~~~~~~~~~~~ +``missingFieldsMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This field is missing.`` diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 3371d8cf278..cb1dc2c158c 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -106,8 +106,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -min -~~~ +``min`` +~~~~~~~ **type**: ``integer`` @@ -116,8 +116,8 @@ collection elements count is **less** than this min value. This option is required when the ``max`` option is not defined. -max -~~~ +``max`` +~~~~~~~ **type**: ``integer`` @@ -126,8 +126,8 @@ collection elements count is **greater** than this max value. This option is required when the ``min`` option is not defined. -minMessage -~~~~~~~~~~ +``minMessage`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or more.`` @@ -144,8 +144,8 @@ You can use the following parameters in this message: | ``{{ limit }}`` | The lower limit | +------------------+------------------------------------------------+ -maxMessage -~~~~~~~~~~ +``maxMessage`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain {{ limit }} elements or less.`` @@ -162,8 +162,8 @@ You can use the following parameters in this message: | ``{{ limit }}`` | The upper limit | +------------------+------------------------------------------------+ -exactMessage -~~~~~~~~~~~~ +``exactMessage`` +~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This collection should contain exactly {{ limit }} elements.`` diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index 5f33ced3ce4..7f87aa54089 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -81,8 +81,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid country.`` diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 33b635a85c9..397f8d76e54 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -84,8 +84,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid currency.`` diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index 3fb06f7944b..51744cbbc60 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -83,8 +83,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid date.`` diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index 777b7e083bb..18a0621b335 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -92,8 +92,8 @@ This option allows to validate a custom date format. See .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid datetime.`` diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 9158966f16e..b6b6fb453ef 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -96,8 +96,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -strict -~~~~~~ +``strict`` +~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -105,8 +105,8 @@ When false, the email will be validated against a simple regular expression. If true, then the `egulias/email-validator`_ library is required to perform an RFC compliant validation. -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid email address.`` @@ -120,8 +120,8 @@ You can use the following parameters in this message: | ``{{ value }}`` | The current (invalid) value | +------------------+------------------------------------------------+ -checkMX -~~~~~~~ +``checkMX`` +~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -133,8 +133,8 @@ check the validity of the MX record of the host of the given email. This option is not reliable because it depends on the network conditions and some valid servers refuse to respond to those requests. -checkHost -~~~~~~~~~ +``checkHost`` +~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index fc076f7a0cf..d68e074647b 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -114,8 +114,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be equal to {{ compared_value }}.`` diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index a02dc3f4926..b4d0b865d60 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -221,13 +221,13 @@ For more information about the expression and what variables are available to you, see the :ref:`expression ` option details below. -Available Options ------------------ +Options +------- .. _reference-constraint-expression-option: -expression -~~~~~~~~~~ +``expression`` +~~~~~~~~~~~~~~ **type**: ``string`` [:ref:`default option `] @@ -248,8 +248,8 @@ in your expression: .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not valid.`` diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index 4ee5015e7e2..87de26e80e0 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -161,8 +161,8 @@ have been specified. Options ------- -maxSize -~~~~~~~ +``maxSize`` +~~~~~~~~~~~ **type**: ``mixed`` @@ -170,38 +170,38 @@ If set, the size of the underlying file must be below this file size in order to be valid. The size of the file can be given in one of the following formats: -+--------+-----------+-----------------+------+ -| Suffix | Unit Name | value | e.g. | -+========+===========+=================+======+ -| | byte | 1 byte | 4096 | -+--------+-----------+-----------------+------+ -| k | kilobyte | 1,000 bytes | 200k | -+--------+-----------+-----------------+------+ -| M | megabyte | 1,000,000 bytes | 2M | -+--------+-----------+-----------------+------+ -| Ki | kibibyte | 1,024 bytes | 32Ki | -+--------+-----------+-----------------+------+ -| Mi | mebibyte | 1,048,576 bytes | 8Mi | -+--------+-----------+-----------------+------+ ++--------+-----------+-----------------+----------+ +| Suffix | Unit Name | value | e.g. | ++========+===========+=================+==========+ +| | byte | 1 byte | ``4096`` | ++--------+-----------+-----------------+----------+ +| k | kilobyte | 1,000 bytes | ``200k`` | ++--------+-----------+-----------------+----------+ +| M | megabyte | 1,000,000 bytes | ``2M`` | ++--------+-----------+-----------------+----------+ +| Ki | kibibyte | 1,024 bytes | ``32Ki`` | ++--------+-----------+-----------------+----------+ +| Mi | mebibyte | 1,048,576 bytes | ``8Mi`` | ++--------+-----------+-----------------+----------+ For more information about the difference between binary and SI prefixes, see `Wikipedia: Binary prefix`_. -binaryFormat -~~~~~~~~~~~~ +``binaryFormat`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``null`` When ``true``, the sizes will be displayed in messages with binary-prefixed units (KiB, MiB). When ``false``, the sizes will be displayed with SI-prefixed -units (kB, MB). When ``null``, then the binaryFormat will be guessed from +units (kB, MB). When ``null``, the ``binaryFormat`` will be guessed from the value defined in the ``maxSize`` option. For more information about the difference between binary and SI prefixes, see `Wikipedia: Binary prefix`_. -mimeTypes -~~~~~~~~~ +``mimeTypes`` +~~~~~~~~~~~~~ **type**: ``array`` or ``string`` @@ -211,8 +211,8 @@ of given mime types (if an array). You can find a list of existing mime types on the `IANA website`_. -maxSizeMessage -~~~~~~~~~~~~~~ +``maxSizeMessage`` +~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file is too large ({{ size }} {{ suffix }}). Allowed maximum size is {{ limit }} {{ suffix }}.`` @@ -232,8 +232,8 @@ You can use the following parameters in this message: | ``{{ file }}`` | Absolute file path | +------------------+------------------------------------------------+ -mimeTypesMessage -~~~~~~~~~~~~~~~~ +``mimeTypesMessage`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The mime type of the file is invalid ({{ type }}). Allowed mime types are {{ types }}.`` @@ -252,8 +252,8 @@ You can use the following parameters in this message: | ``{{ file }}`` | Absolute file path | +-----------------+----------------------------------------+ -disallowEmptyMessage -~~~~~~~~~~~~~~~~~~~~ +``disallowEmptyMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``An empty file is not allowed.`` @@ -268,8 +268,8 @@ You can use the following parameters in this message: | ``{{ file }}`` | Absolute file path | +----------------+--------------------+ -notFoundMessage -~~~~~~~~~~~~~~~ +``notFoundMessage`` +~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file could not be found.`` @@ -285,8 +285,8 @@ You can use the following parameters in this message: | ``{{ file }}`` | Absolute file path | +----------------+--------------------+ -notReadableMessage -~~~~~~~~~~~~~~~~~~ +``notReadableMessage`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file is not readable.`` @@ -301,8 +301,8 @@ You can use the following parameters in this message: | ``{{ file }}`` | Absolute file path | +----------------+--------------------+ -uploadIniSizeErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadIniSizeErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file is too large. Allowed maximum size is {{ limit }} {{ suffix }}.`` @@ -319,8 +319,8 @@ You can use the following parameters in this message: | ``{{ suffix }}`` | Suffix for the used file size unit (see above) | +------------------+------------------------------------------------+ -uploadFormSizeErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadFormSizeErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file is too large.`` @@ -329,8 +329,8 @@ by the HTML file input field. This message has no parameters. -uploadPartialErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadPartialErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file was only partially uploaded.`` @@ -338,8 +338,8 @@ The message that is displayed if the uploaded file is only partially uploaded. This message has no parameters. -uploadNoFileErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadNoFileErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``No file was uploaded.`` @@ -347,18 +347,18 @@ The message that is displayed if no file was uploaded. This message has no parameters. -uploadNoTmpDirErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadNoTmpDirErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``No temporary folder was configured in php.ini.`` -The message that is displayed if the php.ini setting ``upload_tmp_dir`` is +The message that is displayed if the ``php.ini`` setting ``upload_tmp_dir`` is missing. This message has no parameters. -uploadCantWriteErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadCantWriteErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``Cannot write temporary file to disk.`` @@ -367,8 +367,8 @@ temporary folder. This message has no parameters. -uploadExtensionErrorMessage -~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``uploadExtensionErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``A PHP extension caused the upload to fail.`` @@ -377,8 +377,8 @@ fail. This message has no parameters. -uploadErrorMessage -~~~~~~~~~~~~~~~~~~ +``uploadErrorMessage`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The file could not be uploaded.`` diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index 478c06fb1b4..faee4be69d5 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -294,8 +294,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be greater than {{ compared_value }}.`` diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index f23567771b3..2b595c40089 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -293,8 +293,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be greater than or equal to {{ compared_value }}.`` diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index cc074fb327d..d7df4d9ea9a 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -1,4 +1,4 @@ -Iban +IBAN ==== This constraint is used to ensure that a bank account number has the proper @@ -21,7 +21,7 @@ borders with a reduced risk of propagating transcription errors. Basic Usage ----------- -To use the Iban validator, apply it to a property on an object that +To use the IBAN validator, apply it to a property on an object that will contain an International Bank Account Number. .. configuration-block:: @@ -93,17 +93,17 @@ will contain an International Bank Account Number. .. include:: /reference/constraints/_empty-values-are-valid.rst.inc -Available Options ------------------ +Options +------- .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This is not a valid International Bank Account Number (IBAN).`` -The default message supplied when the value does not pass the Iban check. +The default message supplied when the value does not pass the IBAN check. You can use the following parameters in this message: diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index dd1e6bb96f7..200b4cb0632 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -117,8 +117,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be identical to {{ compared_value_type }} {{ compared_value }}.`` diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index d3f2f434a0f..75df3f83566 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -229,52 +229,52 @@ This constraint shares all of its options with the :doc:`File `] @@ -180,8 +180,8 @@ fail if the input string *does* match this pattern. .. include:: /reference/constraints/_groups-option.rst.inc -htmlPattern -~~~~~~~~~~~ +``htmlPattern`` +~~~~~~~~~~~~~~~ **type**: ``string|boolean`` **default**: null @@ -265,8 +265,8 @@ need to specify the HTML5 compatible pattern in the ``htmlPattern`` option: Setting ``htmlPattern`` to false will disable client side validation. -match -~~~~~ +``match`` +~~~~~~~~~ **type**: ``boolean`` default: ``true`` @@ -275,8 +275,8 @@ the given `pattern`_ regular expression. However, when this option is set to ``false``, the opposite will occur: validation will pass only if the given string does **not** match the `pattern`_ regular expression. -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not valid.`` diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index d044527463b..764a29c65f5 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -86,8 +86,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid time.`` diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 2e3bdb27611..fbc1e6fc6d4 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -127,8 +127,8 @@ Options .. _reference-constraint-type-type: -type -~~~~ +``type`` +~~~~~~~~ **type**: ``string`` [:ref:`default option `] @@ -172,8 +172,8 @@ using one of these. .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be of type {{ type }}.`` diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 37a7f675047..e229fb6447d 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -123,8 +123,8 @@ that the ``email`` field remains unique between all of the rows in your user tab Options ------- -fields -~~~~~~ +``fields`` +~~~~~~~~~~ **type**: ``array`` | ``string`` [:ref:`default option `] @@ -140,8 +140,8 @@ each with a single field. .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is already used.`` @@ -162,8 +162,8 @@ You can use the following parameters in this message: | ``{{ value }}`` | The current (invalid) value | +-----------------+-----------------------------+ -em -~~ +``em`` +~~~~~~ **type**: ``string`` @@ -172,8 +172,8 @@ the uniqueness. If it's left blank, the correct entity manager will be determined for this class. For that reason, this option should probably not need to be used. -repositoryMethod -~~~~~~~~~~~~~~~~ +``repositoryMethod`` +~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``findBy`` @@ -183,8 +183,8 @@ blank, ``findBy()`` will be used. The method receives as its argument a fields configured in the ``fields`` option). The method should return a `countable PHP variable`_. -entityClass -~~~~~~~~~~~ +``entityClass`` +~~~~~~~~~~~~~~~ .. versionadded:: 3.2 @@ -198,8 +198,8 @@ inheritance mapping, you need to execute the query in a different repository. Use this option to define the fully-qualified class name (FQCN) of the Doctrine entity associated with the repository you want to use. -errorPath -~~~~~~~~~ +``errorPath`` +~~~~~~~~~~~~~ **type**: ``string`` **default**: The name of the first field in `fields`_ @@ -296,8 +296,8 @@ Consider this example: Now, the message would be bound to the ``port`` field with this configuration. -ignoreNull -~~~~~~~~~~ +``ignoreNull`` +~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 7992ba93a4d..0dfaa782a7a 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -1,4 +1,4 @@ -Url +URL === Validates that a value is a valid URL string. @@ -84,8 +84,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not a valid URL.`` @@ -162,8 +162,8 @@ You can use the following parameters in this message: } } -protocols -~~~~~~~~~ +``protocols`` +~~~~~~~~~~~~~ **type**: ``array`` **default**: ``['http', 'https']`` @@ -239,8 +239,8 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing .. include:: /reference/constraints/_payload-option.rst.inc -checkDNS -~~~~~~~~ +``checkDNS`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -314,8 +314,8 @@ option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the This option uses the :phpfunction:`checkdnsrr` PHP function to check the validity of the DNS record corresponding to the host associated with the given URL. -dnsMessage -~~~~~~~~~~ +``dnsMessage`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The host could not be resolved.`` diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index 7ebdda483f3..310e46d5192 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -103,8 +103,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``message`` **default**: ``This value should be the user current password.`` diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index f961beb9ac8..a1796a33373 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -1,4 +1,4 @@ -Uuid +UUID ==== Validates that a value is a valid `Universally unique identifier (UUID)`_ per `RFC 4122`_. @@ -86,8 +86,8 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc -message -~~~~~~~ +``message`` +~~~~~~~~~~~ **type**: ``string`` **default**: ``This is not a valid UUID.`` @@ -101,8 +101,8 @@ You can use the following parameters in this message: | ``{{ value }}`` | The current (invalid) value | +-----------------+-----------------------------+ -strict -~~~~~~ +``strict`` +~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -114,8 +114,8 @@ will allow alternate input formats like: * ``{216fff40-98d9-11e3-a5e2-0800200c9a66}`` * ``216fff4098d911e3a5e20800200c9a66`` -versions -~~~~~~~~ +``versions`` +~~~~~~~~~~~~ **type**: ``int[]`` **default**: ``[1,2,3,4,5]`` diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 5ccc42bdb29..87c87faf51c 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -248,8 +248,8 @@ the validation of the ``Address`` fields failed. Options ------- -traverse -~~~~~~~~ +``traverse`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/constraints/_comparison-propertypath-option.rst.inc b/reference/constraints/_comparison-propertypath-option.rst.inc index a2acc52ef5c..f1dac752528 100644 --- a/reference/constraints/_comparison-propertypath-option.rst.inc +++ b/reference/constraints/_comparison-propertypath-option.rst.inc @@ -1,5 +1,5 @@ -propertyPath -~~~~~~~~~~~~ +``propertyPath`` +~~~~~~~~~~~~~~~~ **type**: ``string`` diff --git a/reference/constraints/_comparison-value-option.rst.inc b/reference/constraints/_comparison-value-option.rst.inc index cb7e07045a5..b587e46ffef 100644 --- a/reference/constraints/_comparison-value-option.rst.inc +++ b/reference/constraints/_comparison-value-option.rst.inc @@ -1,5 +1,5 @@ -value -~~~~~ +``value`` +~~~~~~~~~ **type**: ``mixed`` [:ref:`default option `] diff --git a/reference/constraints/_groups-option.rst.inc b/reference/constraints/_groups-option.rst.inc index f385b060477..0de5e2046b5 100644 --- a/reference/constraints/_groups-option.rst.inc +++ b/reference/constraints/_groups-option.rst.inc @@ -1,5 +1,5 @@ -groups -~~~~~~ +``groups`` +~~~~~~~~~~ **type**: ``array`` | ``string`` diff --git a/reference/constraints/_payload-option.rst.inc b/reference/constraints/_payload-option.rst.inc index 433fa39eae7..5121ba1ae51 100644 --- a/reference/constraints/_payload-option.rst.inc +++ b/reference/constraints/_payload-option.rst.inc @@ -1,5 +1,5 @@ -payload -~~~~~~~ +``payload`` +~~~~~~~~~~~ **type**: ``mixed`` **default**: ``null`` diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index 35a44883808..ab05b98a7be 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -54,13 +54,13 @@ Tag Name Usage `validator.initializer`_ Register a service that initializes objects before validation ======================================== ======================================================================== -assetic.asset -------------- +``assetic.asset`` +----------------- **Purpose**: Register an asset with the current asset manager -assetic.factory_worker ----------------------- +``assetic.factory_worker`` +-------------------------- **Purpose**: Add a factory worker @@ -116,8 +116,8 @@ And then register it as a tagged service: ->addTag('assetic.factory_worker') ; -assetic.filter --------------- +``assetic.filter`` +------------------ **Purpose**: Register a filter @@ -194,8 +194,8 @@ In order to do that, you must define your filter service in a separate xml config file and point to this file's path via the ``assetic.filters.my_filter.resource`` configuration key. -assetic.formula_loader ----------------------- +``assetic.formula_loader`` +-------------------------- **Purpose**: Add a formula loader to the current asset manager @@ -206,32 +206,32 @@ instance, twig template). Assetic ships loaders for PHP and Twig templates. An ``alias`` attribute defines the name of the loader. -assetic.formula_resource ------------------------- +``assetic.formula_resource`` +---------------------------- **Purpose**: Adds a resource to the current asset manager A resource is something formulae can be loaded from. For instance, Twig templates are resources. -assetic.templating.php ----------------------- +``assetic.templating.php`` +-------------------------- **Purpose**: Remove this service if PHP templating is disabled The tagged service will be removed from the container if the -``framework.templating.engines`` config section does not contain php. +``framework.templating.engines`` config section does not contain PHP. -assetic.templating.twig ------------------------ +``assetic.templating.twig`` +--------------------------- **Purpose**: Remove this service if Twig templating is disabled The tagged service will be removed from the container if ``framework.templating.engines`` config section does not contain ``twig``. -auto_alias ----------- +``auto_alias`` +-------------- **Purpose**: Define aliases based on the value of container parameters @@ -355,16 +355,16 @@ wrapping their names with ``%`` characters). You need to manually add the ``Symfony\Component\DependencyInjection\Compiler\AutoAliasServicePass`` compiler pass to the container for this feature to work. -console.command ---------------- +``console.command`` +------------------- **Purpose**: Add a command to the application For details on registering your own commands in the service container, read :doc:`/console/commands_as_services`. -container.hot_path ------------------- +``container.hot_path`` +---------------------- .. versionadded:: 3.4 @@ -384,8 +384,8 @@ for services and their class hierarchy. The result is as significant performance Use this tag with great caution, you have to be sure that the tagged service is always used. -controller.argument_value_resolver ----------------------------------- +``controller.argument_value_resolver`` +-------------------------------------- **Purpose**: Register a value resolver for controller arguments such as ``Request`` @@ -394,24 +394,24 @@ Value resolvers implement the and are used to resolve argument values for controllers as described here: :doc:`/controller/argument_value_resolver`. -data_collector --------------- +``data_collector`` +------------------ **Purpose**: Create a class that collects custom data for the profiler For details on creating your own custom data collection, read the :doc:`/profiler/data_collector` article. -doctrine.event_listener ------------------------ +``doctrine.event_listener`` +--------------------------- **Purpose**: Add a Doctrine event listener For details on creating Doctrine event listeners, read the :doc:`/doctrine/event_listeners_subscribers` article. -doctrine.event_subscriber -------------------------- +``doctrine.event_subscriber`` +----------------------------- **Purpose**: Add a Doctrine event subscriber @@ -420,16 +420,16 @@ For details on creating Doctrine event subscribers, read the .. _dic-tags-form-type: -form.type ---------- +``form.type`` +------------- **Purpose**: Create a custom form field type For details on creating your own custom form type, read the :doc:`/form/create_custom_field_type` article. -form.type_extension -------------------- +``form.type_extension`` +----------------------- **Purpose**: Create a custom "form extension" @@ -438,8 +438,8 @@ For details on creating Form type extensions, read the .. _reference-dic-type_guesser: -form.type_guesser ------------------ +``form.type_guesser`` +--------------------- **Purpose**: Add your own logic for "form type guessing" @@ -453,8 +453,8 @@ metadata and Doctrine metadata (if you're using Doctrine) or Propel metadata For information on how to create your own type guesser, see :doc:`/form/type_guesser`. -kernel.cache_clearer --------------------- +``kernel.cache_clearer`` +------------------------ **Purpose**: Register your service to be called during the cache clearing process @@ -515,8 +515,8 @@ can also register it manually: ->addTag('kernel.cache_clearer') ; -kernel.cache_warmer -------------------- +``kernel.cache_warmer`` +----------------------- **Purpose**: Register your service to be called during the cache warming process @@ -617,8 +617,8 @@ with the following command: .. _dic-tags-kernel-event-listener: -kernel.event_listener ---------------------- +``kernel.event_listener`` +------------------------- **Purpose**: To listen to different events/hooks in Symfony @@ -637,16 +637,16 @@ see the :doc:`Symfony Events Reference `. .. _dic-tags-kernel-event-subscriber: -kernel.event_subscriber ------------------------ +``kernel.event_subscriber`` +--------------------------- **Purpose**: To subscribe to a set of different events/hooks in Symfony This is an alternative way to create an event listener, and is the recommended way (instead of using ``kernel.event_listener``). See :ref:`events-subscriber`. -kernel.fragment_renderer ------------------------- +``kernel.fragment_renderer`` +---------------------------- **Purpose**: Add a new HTTP content rendering strategy @@ -655,8 +655,8 @@ To add a new rendering strategy - in addition to the core strategies like :class:`Symfony\\Component\\HttpKernel\\Fragment\\FragmentRendererInterface`, register it as a service, then tag it with ``kernel.fragment_renderer``. -kernel.reset ------------- +``kernel.reset`` +---------------- **Purpose**: Clean up services between requests @@ -672,8 +672,8 @@ of the profiler to delete all their information. .. _dic_tags-monolog: -monolog.logger --------------- +``monolog.logger`` +------------------ **Purpose**: To use a custom logging channel with Monolog @@ -724,8 +724,8 @@ channel when injecting the logger in a service. .. _dic_tags-monolog-processor: -monolog.processor ------------------ +``monolog.processor`` +--------------------- **Purpose**: Add a custom processor for logging @@ -854,8 +854,8 @@ You can also add a processor for a specific logging channel by using the You cannot use both the ``handler`` and ``channel`` attributes for the same tag as handlers are shared between all channels. -routing.loader --------------- +``routing.loader`` +------------------ **Purpose**: Register a custom service that loads routes @@ -896,8 +896,8 @@ of your configuration and tag it with ``routing.loader``: For more information, see :doc:`/routing/custom_route_loader`. -routing.expression_language_provider ------------------------------------- +``routing.expression_language_provider`` +---------------------------------------- **Purpose**: Register a provider for expression language functions in routing @@ -906,8 +906,8 @@ This tag is used to automatically register for the routing expression component. Using these providers, you can add custom functions to the routing expression language. -security.expression_language_provider -------------------------------------- +``security.expression_language_provider`` +----------------------------------------- **Purpose**: Register a provider for expression language functions in security @@ -916,8 +916,8 @@ This tag is used to automatically register :ref:`expression function providers component. Using these providers, you can add custom functions to the security expression language. -security.remember_me_aware --------------------------- +``security.remember_me_aware`` +------------------------------ **Purpose**: To allow remember me authentication @@ -932,8 +932,8 @@ and your custom authentication listener extends then your custom authentication listener will automatically have this tag applied and it will function automatically. -security.voter --------------- +``security.voter`` +------------------ **Purpose**: To add a custom voter to Symfony's authorization logic @@ -945,8 +945,8 @@ For more information, read the :doc:`/security/voters` article. .. _reference-dic-tags-serializer-encoder: -serializer.encoder ------------------- +``serializer.encoder`` +---------------------- **Purpose**: Register a new encoder in the ``serializer`` service @@ -957,8 +957,8 @@ For more details, see :doc:`/serializer`. .. _reference-dic-tags-serializer-normalizer: -serializer.normalizer ---------------------- +``serializer.normalizer`` +------------------------- **Purpose**: Register a new normalizer in the Serializer service @@ -971,8 +971,8 @@ The priorities of the default normalizers can be found in the :method:`Symfony\\Bundle\\FrameworkBundle\\DependencyInjection\\FrameworkExtension::registerSerializerConfiguration` method. -swiftmailer.default.plugin --------------------------- +``swiftmailer.default.plugin`` +------------------------------ **Purpose**: Register a custom SwiftMailer Plugin @@ -993,8 +993,8 @@ For more information on plugins, see `SwiftMailer's Plugin Documentation`_. Several SwiftMailer plugins are core to Symfony and can be activated via different configuration. For details, see :doc:`/reference/configuration/swiftmailer`. -templating.helper ------------------ +``templating.helper`` +--------------------- **Purpose**: Make your service available in PHP templates @@ -1037,8 +1037,8 @@ templates): .. _dic-tags-translation-loader: -translation.loader ------------------- +``translation.loader`` +---------------------- **Purpose**: To register a custom service that loads translations @@ -1103,8 +1103,8 @@ the ``load()`` method on your custom loader. .. _reference-dic-tags-translation-extractor: -translation.extractor ---------------------- +``translation.extractor`` +------------------------- **Purpose**: To register a custom service that extracts messages from a file @@ -1178,8 +1178,8 @@ required option: ``alias``, which defines the name of the extractor:: $container->register(CustomExtractor::class) ->addTag('translation.extractor', ['alias' => 'foo']); -translation.dumper ------------------- +``translation.dumper`` +---------------------- **Purpose**: To register a custom service that dumps messages to a file @@ -1242,8 +1242,8 @@ This is the name that's used to determine which dumper should be used. .. _reference-dic-tags-twig-extension: -twig.extension --------------- +``twig.extension`` +------------------ **Purpose**: To register a custom Twig Extension @@ -1288,8 +1288,8 @@ For information on how to create the actual Twig Extension class, see `Twig's documentation`_ on the topic or read the :doc:`/templating/twig_extension` article. -twig.loader ------------ +``twig.loader`` +--------------- **Purpose**: Register a custom service that loads Twig templates @@ -1340,16 +1340,16 @@ also register it manually: The ``priority`` is optional and its value is a positive or negative integer that defaults to ``0``. Loaders with higher numbers are tried first. -validator.constraint_validator ------------------------------- +``validator.constraint_validator`` +---------------------------------- **Purpose**: Create your own custom validation constraint This tag allows you to create and register your own custom validation constraint. For more information, read the :doc:`/validation/custom_constraint` article. -validator.initializer ---------------------- +``validator.initializer`` +------------------------- **Purpose**: Register a service that initializes objects before validation diff --git a/reference/forms/twig_reference.rst b/reference/forms/twig_reference.rst index 311f2c850f3..d3f31f3c8ec 100644 --- a/reference/forms/twig_reference.rst +++ b/reference/forms/twig_reference.rst @@ -28,8 +28,8 @@ errors, widgets, etc). .. _reference-forms-twig-form: -form(view, variables) ---------------------- +``form(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the HTML of a complete form. @@ -55,8 +55,8 @@ the other helpers to render individual parts of the form instead: .. _reference-forms-twig-start: -form_start(view, variables) ---------------------------- +``form_start(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the start tag of a form. This helper takes care of printing the configured method and target action of the form. It will also include the @@ -69,8 +69,8 @@ correct ``enctype`` property if the form contains upload fields. .. _reference-forms-twig-end: -form_end(view, variables) -------------------------- +``form_end(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the end tag of a form. @@ -88,8 +88,8 @@ to false: .. _reference-forms-twig-label: -form_label(view, label, variables) ----------------------------------- +``form_label(view, label, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the label for the given field. You can optionally pass the specific label you want to display as the second argument. @@ -111,8 +111,8 @@ argument. .. _reference-forms-twig-errors: -form_errors(view) ------------------ +``form_errors(view)`` +~~~~~~~~~~~~~~~~~~~~~ Renders any errors for the given field. @@ -125,8 +125,8 @@ Renders any errors for the given field. .. _reference-forms-twig-widget: -form_widget(view, variables) ----------------------------- +``form_widget(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the HTML widget of a given field. If you apply this to an entire form or collection of fields, each underlying form row will be rendered. @@ -148,8 +148,8 @@ argument. .. _reference-forms-twig-row: -form_row(view, variables) -------------------------- +``form_row(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Renders the "row" of a given field, which is the combination of the field's label, errors and widget. @@ -168,8 +168,8 @@ argument. .. _reference-forms-twig-rest: -form_rest(view, variables) --------------------------- +``form_rest(view, variables)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This renders all fields that have not yet been rendered for the given form. It's a good idea to always have this somewhere inside your form as it'll @@ -188,8 +188,8 @@ condition. Read `the Twig documentation`_ for more information. .. _form-twig-selectedchoice: -selectedchoice(selected_value) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +``selectedchoice(selected_value)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This test will check if the current choice is equal to the ``selected_value`` or if the current choice is in the array (when ``selected_value`` is an @@ -201,8 +201,8 @@ array). .. _form-twig-rootform: -rootform -~~~~~~~~ +``rootform`` +~~~~~~~~~~~~ This test will check if the current ``form`` does not have a parent form view. diff --git a/reference/forms/types/birthday.rst b/reference/forms/types/birthday.rst index 04f78c8b88b..98631be0870 100644 --- a/reference/forms/types/birthday.rst +++ b/reference/forms/types/birthday.rst @@ -5,7 +5,7 @@ BirthdayType Field ================== A :doc:`DateType ` field that specializes in handling -birthdate data. +birth date data. Can be rendered as a single text box, three text boxes (month, day and year), or three select boxes. @@ -51,8 +51,8 @@ option defaults to 120 years ago to the current year. Overridden Options ------------------ -years -~~~~~ +``years`` +~~~~~~~~~ **type**: ``array`` **default**: 120 years ago to the current year @@ -68,8 +68,8 @@ These options inherit from the :doc:`DateType `: .. include:: /reference/forms/types/options/days.rst.inc -placeholder -~~~~~~~~~~~ +``placeholder`` +~~~~~~~~~~~~~~~ **type**: ``string`` | ``array`` diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index 62e76989a80..04b6536eeaa 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -28,8 +28,8 @@ The ``BaseType`` class is the parent class for both the ``button`` type and the :doc:`FormType `, but it is not part of the form type tree (i.e. it cannot be used as a form type on its own). -attr -~~~~ +``attr`` +~~~~~~~~ **type**: ``array`` **default**: ``[]`` diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index ea20f5b9af5..a21c3312416 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -156,8 +156,8 @@ To get fancier, use the `group_by`_ option. Field Options ------------- -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -183,8 +183,8 @@ correct types will be assigned to the model. .. include:: /reference/forms/types/options/choice_label.rst.inc -choice_loader -~~~~~~~~~~~~~ +``choice_loader`` +~~~~~~~~~~~~~~~~~ **type**: :class:`Symfony\\Component\\Form\\ChoiceList\\Loader\\ChoiceLoaderInterface` @@ -220,8 +220,8 @@ the choice options would need to be resolved thus triggering the callback. .. include:: /reference/forms/types/options/choice_value.rst.inc -choices_as_values -~~~~~~~~~~~~~~~~~ +``choices_as_values`` +~~~~~~~~~~~~~~~~~~~~~ This option is deprecated and you should remove it from your 3.x projects (removing it will have *no* effect). For its purpose in 2.x, see the 2.7 documentation. @@ -239,8 +239,8 @@ it will have *no* effect). For its purpose in 2.x, see the 2.7 documentation. Overridden Options ------------------ -compound -~~~~~~~~ +``compound`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: same value as ``expanded`` option @@ -259,8 +259,8 @@ The actual default value of this option depends on other field options: .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -301,32 +301,32 @@ These options inherit from the :doc:`FormType `: Field Variables --------------- -+----------------------------+--------------+-------------------------------------------------------------------+ -| Variable | Type | Usage | -+============================+==============+===================================================================+ -| multiple | ``boolean`` | The value of the `multiple`_ option. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| expanded | ``boolean`` | The value of the `expanded`_ option. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| preferred_choices | ``array`` | A nested array containing the ``ChoiceView`` objects of | -| | | choices which should be presented to the user with priority. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| choices | ``array`` | A nested array containing the ``ChoiceView`` objects of | -| | | the remaining choices. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| separator | ``string`` | The separator to use between choice groups. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| placeholder | ``mixed`` | The empty value if not already in the list, otherwise | -| | | ``null``. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| choice_translation_domain | ``mixed`` | ``boolean``, ``null`` or ``string`` to determine if the value | -| | | should be translated. | -+----------------------------+--------------+-------------------------------------------------------------------+ -| is_selected | ``callable`` | A callable which takes a ``ChoiceView`` and the selected value(s) | -| | | and returns whether the choice is in the selected value(s). | -+----------------------------+--------------+-------------------------------------------------------------------+ -| placeholder_in_choices | ``boolean`` | Whether the empty value is in the choice list. | -+----------------------------+--------------+-------------------------------------------------------------------+ ++-------------------------------+--------------+-------------------------------------------------------------------+ +| Variable | Type | Usage | ++===============================+==============+===================================================================+ +| ``multiple`` | ``boolean`` | The value of the `multiple`_ option. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``expanded`` | ``boolean`` | The value of the `expanded`_ option. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``preferred_choices`` | ``array`` | A nested array containing the ``ChoiceView`` objects of | +| | | choices which should be presented to the user with priority. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``choices`` | ``array`` | A nested array containing the ``ChoiceView`` objects of | +| | | the remaining choices. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``separator`` | ``string`` | The separator to use between choice groups. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``placeholder`` | ``mixed`` | The empty value if not already in the list, otherwise | +| | | ``null``. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``choice_translation_domain`` | ``mixed`` | ``boolean``, ``null`` or ``string`` to determine if the value | +| | | should be translated. | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``is_selected`` | ``callable`` | A callable which takes a ``ChoiceView`` and the selected value(s) | +| | | and returns whether the choice is in the selected value(s). | ++-------------------------------+--------------+-------------------------------------------------------------------+ +| ``placeholder_in_choices`` | ``boolean`` | Whether the empty value is in the choice list. | ++-------------------------------+--------------+-------------------------------------------------------------------+ .. tip:: diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index 77378ad29ea..2a270336192 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -207,8 +207,8 @@ And update the template as follows: Field Options ------------- -allow_add -~~~~~~~~~ +``allow_add`` +~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -229,8 +229,8 @@ the client side. For more information, see the above example and these new objects is set correctly. If you're using Doctrine, this won't happen automatically. See the above link for more details. -allow_delete -~~~~~~~~~~~~ +``allow_delete`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` @@ -252,8 +252,8 @@ For more information, see :ref:`form-collections-remove`. the main object. None of this is handled automatically. For more information, see :ref:`form-collections-remove`. -delete_empty -~~~~~~~~~~~~ +``delete_empty`` +~~~~~~~~~~~~~~~~ **type**: ``Boolean`` or ``callable`` **default**: ``false`` @@ -294,8 +294,8 @@ may define complex conditions for considering them empty. Support for using a callable for the ``delete_empty`` option was introduced in Symfony 3.4. -entry_options -~~~~~~~~~~~~~ +``entry_options`` +~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -321,8 +321,8 @@ type:: ], ]); -entry_type -~~~~~~~~~~ +``entry_type`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``'Symfony\Component\Form\Extension\Core\Type\TextType'`` @@ -332,8 +332,8 @@ you'd use the :doc:`EmailType `. If you want to embed a collection of some other form, pass the form type class as this option (e.g. ``MyFormType::class``). -prototype -~~~~~~~~~ +``prototype`` +~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -365,8 +365,8 @@ rendering your form, having the entire "form row" may be easier for you. For details on how to actually use this option, see the above example as well as :ref:`form-collections-new-prototype`. -prototype_data -~~~~~~~~~~~~~~ +``prototype_data`` +~~~~~~~~~~~~~~~~~~ **type**: ``mixed`` **default**: ``null`` @@ -385,8 +385,8 @@ for all entries with the `entry_options`_ option will be used:: 'prototype_data' => 'New Tag Placeholder', ]); -prototype_name -~~~~~~~~~~~~~~ +``prototype_name`` +~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``__name__`` @@ -412,8 +412,8 @@ The default value is ``[]`` (empty array). .. include:: /reference/forms/types/options/empty_data.rst.inc :start-after: DEFAULT_PLACEHOLDER -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -434,9 +434,9 @@ error_bubbling Field Variables --------------- -============ =========== ======================================== -Variable Type Usage -============ =========== ======================================== -allow_add ``boolean`` The value of the `allow_add`_ option. -allow_delete ``boolean`` The value of the `allow_delete`_ option. -============ =========== ======================================== +================ =========== ======================================== +Variable Type Usage +================ =========== ======================================== +``allow_add`` ``boolean`` The value of the `allow_add`_ option. +``allow_delete`` ``boolean`` The value of the `allow_delete`_ option. +================ =========== ======================================== diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index 85c07cb27c7..278b22759ed 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -53,8 +53,8 @@ the option manually, but then you should just use the ``ChoiceType`` directly. Overridden Options ------------------ -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **default**: ``Symfony\Component\Intl\Intl::getRegionBundle()->getCountryNames()`` diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 249003551d6..c0b3607113c 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -45,8 +45,8 @@ manually, but then you should just use the ``ChoiceType`` directly. Overridden Options ------------------ -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **default**: ``Symfony\Component\Intl\Intl::getCurrencyBundle()->getCurrencyNames()`` diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index 54ede7b3259..2648d331127 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -62,7 +62,7 @@ field as **three different choice fields**:: 'widget' => 'choice', ]); -If your underlying date is *not* a ``DateTime`` object (e.g. it's a unix +If your underlying date is *not* a ``DateTime`` object (e.g. it's a Unix timestamp or a ``DateTimeImmutable`` object), configure the `input`_ option:: $builder->add('publishedAt', DateType::class, [ @@ -70,8 +70,8 @@ timestamp or a ``DateTimeImmutable`` object), configure the `input`_ option:: 'input' => 'datetime_immutable' ]); -Rendering a single HTML5 Textbox -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Rendering a single HTML5 Text Box +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For a better user experience, you may want to render a single text field and use some kind of "date picker" to help your user fill in the right format. To do that, @@ -139,8 +139,8 @@ Field Options .. include:: /reference/forms/types/options/days.rst.inc -placeholder -~~~~~~~~~~~ +``placeholder`` +~~~~~~~~~~~~~~~ **type**: ``string`` | ``array`` @@ -184,8 +184,8 @@ values for the year, month and day fields:: Overridden Options ------------------ -by_reference -~~~~~~~~~~~~ +``by_reference`` +~~~~~~~~~~~~~~~~ **default**: ``false`` @@ -195,8 +195,8 @@ The ``DateTime`` classes are treated as immutable objects. .. include:: /reference/forms/types/options/data_class_date.rst.inc -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **default**: ``false`` @@ -222,15 +222,15 @@ These options inherit from the :doc:`FormType `: Field Variables --------------- -+--------------+------------+----------------------------------------------------------------------+ -| Variable | Type | Usage | -+==============+============+======================================================================+ -| widget | ``mixed`` | The value of the `widget`_ option. | -+--------------+------------+----------------------------------------------------------------------+ -| type | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, | -| | | contains the input type to use (``datetime``, ``date`` or ``time``). | -+--------------+------------+----------------------------------------------------------------------+ -| date_pattern | ``string`` | A string with the date format to use. | -+--------------+------------+----------------------------------------------------------------------+ ++------------------+------------+----------------------------------------------------------------------+ +| Variable | Type | Usage | ++==================+============+======================================================================+ +| ``widget`` | ``mixed`` | The value of the `widget`_ option. | ++------------------+------------+----------------------------------------------------------------------+ +| ``type`` | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, | +| | | contains the input type to use (``datetime``, ``date`` or ``time``). | ++------------------+------------+----------------------------------------------------------------------+ +| ``date_pattern`` | ``string`` | A string with the date format to use. | ++------------------+------------+----------------------------------------------------------------------+ .. _`Bootstrap Datepicker`: https://github.com/eternicode/bootstrap-datepicker diff --git a/reference/forms/types/dateinterval.rst b/reference/forms/types/dateinterval.rst index 3e780148f8a..f031ab0352d 100644 --- a/reference/forms/types/dateinterval.rst +++ b/reference/forms/types/dateinterval.rst @@ -75,8 +75,8 @@ options to show (e.g. don't show "months", but *do* show "days"):: Field Options ------------- -days -~~~~ +``days`` +~~~~~~~~ **type**: ``array`` **default**: 0 to 31 @@ -89,8 +89,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 31 (both inclusive) 'days' => array_combine(range(1, 31), range(1, 31)), -placeholder -~~~~~~~~~~~ +``placeholder`` +~~~~~~~~~~~~~~~ **type**: ``string`` or ``array`` @@ -108,8 +108,8 @@ Alternatively, you can specify a string to be displayed for the "blank" value:: 'placeholder' => ['years' => 'Years', 'months' => 'Months', 'days' => 'Days'] ]); -hours -~~~~~ +``hours`` +~~~~~~~~~ **type**: ``array`` **default**: 0 to 24 @@ -122,8 +122,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 24 (both inclusive) 'hours' => array_combine(range(1, 24), range(1, 24)), -input -~~~~~ +``input`` +~~~~~~~~~ **type**: ``string`` **default**: ``dateinterval`` @@ -137,8 +137,8 @@ your underlying object. Valid values are: The value that comes back from the form will also be normalized back into this format. -labels -~~~~~~ +``labels`` +~~~~~~~~~~ .. versionadded:: 3.3 @@ -161,8 +161,8 @@ are ``null``, so they display the "humanized version" of the child names (``Inve 'seconds' => null, ] -minutes -~~~~~~~ +``minutes`` +~~~~~~~~~~~ **type**: ``array`` **default**: 0 to 60 @@ -175,8 +175,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 60 (both inclusive) 'minutes' => array_combine(range(1, 60), range(1, 60)), -months -~~~~~~ +``months`` +~~~~~~~~~~ **type**: ``array`` **default**: 0 to 12 @@ -189,8 +189,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 12 (both inclusive) 'months' => array_combine(range(1, 12), range(1, 12)), -seconds -~~~~~~~ +``seconds`` +~~~~~~~~~~~ **type**: ``array`` **default**: 0 to 60 @@ -203,8 +203,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 60 (both inclusive) 'seconds' => array_combine(range(1, 60), range(1, 60)), -weeks -~~~~~ +``weeks`` +~~~~~~~~~ **type**: ``array`` **default**: 0 to 52 @@ -217,8 +217,8 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 52 (both inclusive) 'weeks' => array_combine(range(1, 52), range(1, 52)), -widget -~~~~~~ +``widget`` +~~~~~~~~~~ **type**: ``string`` **default**: ``choice`` @@ -247,8 +247,8 @@ following: will be validated against the form ``PnYnMnDTnHnMnS`` (or ``PnW`` if using only weeks). -with_days -~~~~~~~~~ +``with_days`` +~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``true`` @@ -259,16 +259,16 @@ input to capture days. This can not be used when `with_weeks`_ is enabled. -with_hours -~~~~~~~~~~ +``with_hours`` +~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` Whether or not to include hours in the input. This will result in an additional input to capture hours. -with_invert -~~~~~~~~~~~ +``with_invert`` +~~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` @@ -276,32 +276,32 @@ Whether or not to include invert in the input. This will result in an additional checkbox. This can not be used when the `widget`_ option is set to ``single_text``. -with_minutes -~~~~~~~~~~~~ +``with_minutes`` +~~~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` Whether or not to include minutes in the input. This will result in an additional input to capture minutes. -with_months -~~~~~~~~~~~ +``with_months`` +~~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``true`` Whether or not to include months in the input. This will result in an additional input to capture months. -with_seconds -~~~~~~~~~~~~ +``with_seconds`` +~~~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` Whether or not to include seconds in the input. This will result in an additional input to capture seconds. -with_weeks -~~~~~~~~~~ +``with_weeks`` +~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` @@ -312,16 +312,16 @@ input to capture weeks. This can not be used when `with_days`_ is enabled. -with_years -~~~~~~~~~~ +``with_years`` +~~~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``true`` Whether or not to include years in the input. This will result in an additional input to capture years. -years -~~~~~ +``years`` +~~~~~~~~~ **type**: ``array`` **default**: 0 to 100 @@ -354,18 +354,18 @@ These options inherit from the :doc:`form ` type: Field Variables --------------- -============ =========== ======================================== -Variable Type Usage -============ =========== ======================================== -widget ``mixed`` The value of the `widget`_ option. -with_days ``Boolean`` The value of the `with_days`_ option. -with_invert ``Boolean`` The value of the `with_invert`_ option. -with_hours ``Boolean`` The value of the `with_hours`_ option. -with_minutes ``Boolean`` The value of the `with_minutes`_ option. -with_months ``Boolean`` The value of the `with_months`_ option. -with_seconds ``Boolean`` The value of the `with_seconds`_ option. -with_weeks ``Boolean`` The value of the `with_weeks`_ option. -with_years ``Boolean`` The value of the `with_years`_ option. -============ =========== ======================================== +================ =========== ======================================== +Variable Type Usage +================ =========== ======================================== +``widget`` ``mixed`` The value of the `widget`_ option. +``with_days`` ``Boolean`` The value of the `with_days`_ option. +``with_invert`` ``Boolean`` The value of the `with_invert`_ option. +``with_hours`` ``Boolean`` The value of the `with_hours`_ option. +``with_minutes`` ``Boolean`` The value of the `with_minutes`_ option. +``with_months`` ``Boolean`` The value of the `with_months`_ option. +``with_seconds`` ``Boolean`` The value of the `with_seconds`_ option. +``with_weeks`` ``Boolean`` The value of the `with_weeks`_ option. +``with_years`` ``Boolean`` The value of the `with_years`_ option. +================ =========== ======================================== .. _`ISO 8601`: https://en.wikipedia.org/wiki/ISO_8601 diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 7e81fc0b90f..3bafb96c57f 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -57,8 +57,8 @@ Field Options .. include:: /reference/forms/types/options/choice_translation_domain.rst.inc -date_format -~~~~~~~~~~~ +``date_format`` +~~~~~~~~~~~~~~~ **type**: ``integer`` or ``string`` **default**: ``IntlDateFormatter::MEDIUM`` @@ -69,8 +69,8 @@ for more details. The ``date_format`` option does not have any effect when the form is rendered as an HTML5 datetime input. -date_widget -~~~~~~~~~~~ +``date_widget`` +~~~~~~~~~~~~~~~ .. include:: /reference/forms/types/options/date_widget_description.rst.inc @@ -78,8 +78,8 @@ The ``date_widget`` option is ignored when the ``widget`` option is set to ``sin .. include:: /reference/forms/types/options/days.rst.inc -placeholder -~~~~~~~~~~~ +``placeholder`` +~~~~~~~~~~~~~~~ **type**: ``string`` | ``array`` @@ -105,8 +105,8 @@ values for the year, month, day, hour, minute and second fields:: ] ]); -format -~~~~~~ +``format`` +~~~~~~~~~~ **type**: ``string`` **default**: ``Symfony\Component\Form\Extension\Core\Type\DateTimeType::HTML5_FORMAT`` @@ -121,8 +121,8 @@ For more information on valid formats, see `Date/Time Format Syntax`_. .. include:: /reference/forms/types/options/html5.rst.inc -input -~~~~~ +``input`` +~~~~~~~~~ **type**: ``string`` **default**: ``datetime`` @@ -147,8 +147,8 @@ this format. .. include:: /reference/forms/types/options/seconds.rst.inc -time_widget -~~~~~~~~~~~ +``time_widget`` +~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``choice`` @@ -158,8 +158,8 @@ The ``time_widget`` option is ignored when the ``widget`` option is set to ``sin .. include:: /reference/forms/types/options/view_timezone.rst.inc -widget -~~~~~~ +``widget`` +~~~~~~~~~~ **type**: ``string`` **default**: ``null`` @@ -176,8 +176,8 @@ with the `date_widget`_ and `time_widget`_ options. Overridden Options ------------------ -by_reference -~~~~~~~~~~~~ +``by_reference`` +~~~~~~~~~~~~~~~~ **default**: ``false`` @@ -187,8 +187,8 @@ The ``DateTime`` classes are treated as immutable objects. .. include:: /reference/forms/types/options/data_class_date.rst.inc -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **default**: ``false`` @@ -212,14 +212,14 @@ These options inherit from the :doc:`FormType `: Field Variables --------------- -+----------+------------+----------------------------------------------------------------------+ -| Variable | Type | Usage | -+==========+============+======================================================================+ -| widget | ``mixed`` | The value of the `widget`_ option. | -+----------+------------+----------------------------------------------------------------------+ -| type | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, | -| | | contains the input type to use (``datetime``, ``date`` or ``time``). | -+----------+------------+----------------------------------------------------------------------+ ++--------------+------------+----------------------------------------------------------------------+ +| Variable | Type | Usage | ++==============+============+======================================================================+ +| ``widget`` | ``mixed`` | The value of the `widget`_ option. | ++--------------+------------+----------------------------------------------------------------------+ +| ``type`` | ``string`` | Only present when widget is ``single_text`` and HTML5 is activated, | +| | | contains the input type to use (``datetime``, ``date`` or ``time``). | ++--------------+------------+----------------------------------------------------------------------+ .. _`datetime local`: http://w3c.github.io/html-reference/datatypes.html#form.data.datetime-local .. _`Date/Time Format Syntax`: http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax diff --git a/reference/forms/types/entity.rst b/reference/forms/types/entity.rst index 165190707f8..4a731354ff9 100644 --- a/reference/forms/types/entity.rst +++ b/reference/forms/types/entity.rst @@ -131,8 +131,8 @@ then you can supply the ``choices`` option directly:: Field Options ------------- -choice_label -~~~~~~~~~~~~ +``choice_label`` +~~~~~~~~~~~~~~~~ **type**: ``string``, ``callable`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` @@ -181,8 +181,8 @@ more details, see the main :ref:`choice_label ` doc 'choice_label' => 'translations[en].name', ]); -class -~~~~~ +``class`` +~~~~~~~~~ **type**: ``string`` **required** @@ -190,16 +190,16 @@ The class of your entity (e.g. ``AppBundle:Category``). This can be a fully-qualified class name (e.g. ``AppBundle\Entity\Category``) or the short alias name (as shown prior). -em -~~ +``em`` +~~~~~~ **type**: ``string`` | ``Doctrine\Common\Persistence\ObjectManager`` **default**: the default entity manager If specified, this entity manager will be used to load the choices instead of the ``default`` entity manager. -query_builder -~~~~~~~~~~~~~ +``query_builder`` +~~~~~~~~~~~~~~~~~ **type**: ``Doctrine\ORM\QueryBuilder`` or a ``callable`` **default**: ``null`` @@ -234,8 +234,8 @@ In the ``EntityType``, this is overridden to use the ``id`` by default. When the ``id`` is used, Doctrine only queries for the objects for the ids that were actually submitted. -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **type**: ``array`` | ``\Traversable`` **default**: ``null`` @@ -243,8 +243,8 @@ Instead of allowing the `class`_ and `query_builder`_ options to fetch the entities to include for you, you can pass the ``choices`` option directly. See :ref:`reference-forms-entity-choices`. -data_class -~~~~~~~~~~ +``data_class`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` @@ -275,8 +275,8 @@ These options inherit from the :doc:`ChoiceType ` .. include:: /reference/forms/types/options/placeholder.rst.inc -preferred_choices -~~~~~~~~~~~~~~~~~ +``preferred_choices`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``array`` or ``callable`` **default**: ``[]`` diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index 85e8c20f275..99cad7786f9 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -86,8 +86,8 @@ upload associated with a Doctrine entity. Field Options ------------- -multiple -~~~~~~~~ +``multiple`` +~~~~~~~~~~~~ **type**: ``Boolean`` **default**: ``false`` @@ -98,15 +98,15 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc -data_class -~~~~~~~~~~ +``data_class`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: :class:`Symfony\\Component\\HttpFoundation\\File\\File` This option sets the appropriate file-related data mapper to be used by the type. -empty_data -~~~~~~~~~~ +``empty_data`` +~~~~~~~~~~~~~~ **type**: ``mixed`` **default**: ``null`` @@ -140,5 +140,5 @@ Form Variables ======== ========== =============================================================================== Variable Type Usage ======== ========== =============================================================================== -type ``string`` The type variable is set to ``file``, in order to render as a file input field. +``type`` ``string`` The type variable is set to ``file``, in order to render as a file input field. ======== ========== =============================================================================== diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index b03732aadc4..1aae7360751 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -53,8 +53,8 @@ Field Options .. _form-option-allow-extra-fields: -allow_extra_fields -~~~~~~~~~~~~~~~~~~ +``allow_extra_fields`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index 69d56735c90..5f63c8f5772 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -28,15 +28,15 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **default**: ``true`` Pass errors to the root form, otherwise they will not be visible. -required -~~~~~~~~ +``required`` +~~~~~~~~~~~~ **default**: ``false`` diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index db6d91bd7a5..6abac53cc1b 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -45,8 +45,8 @@ Field Options .. include:: /reference/forms/types/options/grouping.rst.inc -rounding_mode -~~~~~~~~~~~~~ +``rounding_mode`` +~~~~~~~~~~~~~~~~~ **type**: ``integer`` **default**: ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` @@ -79,8 +79,8 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc -scale -~~~~~ +``scale`` +~~~~~~~~~ **type**: ``integer`` **default**: ``0`` diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 2a60be33e9e..4b40b2b1e44 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -55,8 +55,8 @@ manually, but then you should just use the ``ChoiceType`` directly. Overridden Options ------------------ -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **default**: ``Symfony\Component\Intl\Intl::getLanguageBundle()->getLanguageNames()``. diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 99998ec4104..3933594ba72 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -56,8 +56,8 @@ manually, but then you should just use the ``ChoiceType`` directly. Overridden Options ------------------ -choices -~~~~~~~ +``choices`` +~~~~~~~~~~~ **default**: ``Symfony\Component\Intl\Intl::getLocaleBundle()->getLocaleNames()`` diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 07b68ea88d9..38471f2030f 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -43,8 +43,8 @@ how the input and output of the data is handled. Field Options ------------- -currency -~~~~~~~~ +``currency`` +~~~~~~~~~~~~ **type**: ``string`` **default**: ``EUR`` @@ -56,8 +56,8 @@ text field. This can be any `3 letter ISO 4217 code`_. You can also set this to false to hide the currency symbol. -divisor -~~~~~~~ +``divisor`` +~~~~~~~~~~~ **type**: ``integer`` **default**: ``1`` @@ -80,8 +80,8 @@ be set back on your object. .. include:: /reference/forms/types/options/grouping.rst.inc -scale -~~~~~ +``scale`` +~~~~~~~~~ **type**: ``integer`` **default**: ``2`` diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 4d648ce52d8..7943d776326 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -41,8 +41,8 @@ Field Options .. include:: /reference/forms/types/options/grouping.rst.inc -scale -~~~~~ +``scale`` +~~~~~~~~~ **type**: ``integer`` **default**: Locale-specific (usually around ``3``) @@ -51,8 +51,8 @@ the submitted value (via ``rounding_mode``). For example, if ``scale`` is set to ``2``, a submitted value of ``20.123`` will be rounded to, for example, ``20.12`` (depending on your `rounding_mode`_). -rounding_mode -~~~~~~~~~~~~~ +``rounding_mode`` +~~~~~~~~~~~~~~~~~ **type**: ``integer`` **default**: ``NumberToLocalizedStringTransformer::ROUND_HALF_UP`` diff --git a/reference/forms/types/options/action.rst.inc b/reference/forms/types/options/action.rst.inc index a878355cc38..e20fe47ccab 100644 --- a/reference/forms/types/options/action.rst.inc +++ b/reference/forms/types/options/action.rst.inc @@ -1,5 +1,5 @@ -action -~~~~~~ +``action`` +~~~~~~~~~~ **type**: ``string`` **default**: empty string diff --git a/reference/forms/types/options/attr.rst.inc b/reference/forms/types/options/attr.rst.inc index d7ecc7e46dd..c03e17cdb43 100644 --- a/reference/forms/types/options/attr.rst.inc +++ b/reference/forms/types/options/attr.rst.inc @@ -1,5 +1,5 @@ -attr -~~~~ +``attr`` +~~~~~~~~ **type**: ``array`` **default**: ``[]`` diff --git a/reference/forms/types/options/auto_initialize.rst.inc b/reference/forms/types/options/auto_initialize.rst.inc index ab42f333438..bab8ef86e01 100644 --- a/reference/forms/types/options/auto_initialize.rst.inc +++ b/reference/forms/types/options/auto_initialize.rst.inc @@ -1,5 +1,5 @@ -auto_initialize -~~~~~~~~~~~~~~~ +``auto_initialize`` +~~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/block_name.rst.inc b/reference/forms/types/options/block_name.rst.inc index f873c1014ad..903e9809626 100644 --- a/reference/forms/types/options/block_name.rst.inc +++ b/reference/forms/types/options/block_name.rst.inc @@ -1,5 +1,5 @@ -block_name -~~~~~~~~~~ +``block_name`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: the form's name (see :ref:`Knowing which block to customize `) diff --git a/reference/forms/types/options/button_disabled.rst.inc b/reference/forms/types/options/button_disabled.rst.inc index b08ebf3f35f..5dc8767e791 100644 --- a/reference/forms/types/options/button_disabled.rst.inc +++ b/reference/forms/types/options/button_disabled.rst.inc @@ -1,5 +1,5 @@ -disabled -~~~~~~~~ +``disabled`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/button_label.rst.inc b/reference/forms/types/options/button_label.rst.inc index b0f7146c7d0..623e8bf6200 100644 --- a/reference/forms/types/options/button_label.rst.inc +++ b/reference/forms/types/options/button_label.rst.inc @@ -1,5 +1,5 @@ -label -~~~~~ +``label`` +~~~~~~~~~ **type**: ``string`` **default**: The label is "guessed" from the field name diff --git a/reference/forms/types/options/button_translation_domain.rst.inc b/reference/forms/types/options/button_translation_domain.rst.inc index 56c3453f5c1..f642ea708d8 100644 --- a/reference/forms/types/options/button_translation_domain.rst.inc +++ b/reference/forms/types/options/button_translation_domain.rst.inc @@ -1,5 +1,5 @@ -translation_domain -~~~~~~~~~~~~~~~~~~ +``translation_domain`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``messages`` diff --git a/reference/forms/types/options/by_reference.rst.inc b/reference/forms/types/options/by_reference.rst.inc index 257c0c5a6e4..3065cc9d9c5 100644 --- a/reference/forms/types/options/by_reference.rst.inc +++ b/reference/forms/types/options/by_reference.rst.inc @@ -1,5 +1,5 @@ -by_reference -~~~~~~~~~~~~ +``by_reference`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/checkbox_compound.rst.inc b/reference/forms/types/options/checkbox_compound.rst.inc index e8e8a9c13ac..6ae8e9b55bf 100644 --- a/reference/forms/types/options/checkbox_compound.rst.inc +++ b/reference/forms/types/options/checkbox_compound.rst.inc @@ -1,5 +1,5 @@ -compound -~~~~~~~~ +``compound`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/checkbox_empty_data.rst.inc b/reference/forms/types/options/checkbox_empty_data.rst.inc index 0c1c62609d3..50006ae794c 100644 --- a/reference/forms/types/options/checkbox_empty_data.rst.inc +++ b/reference/forms/types/options/checkbox_empty_data.rst.inc @@ -1,5 +1,5 @@ -empty_data -~~~~~~~~~~ +``empty_data`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``mixed`` diff --git a/reference/forms/types/options/choice_attr.rst.inc b/reference/forms/types/options/choice_attr.rst.inc index c400a83a5d9..4a91d6dacc8 100644 --- a/reference/forms/types/options/choice_attr.rst.inc +++ b/reference/forms/types/options/choice_attr.rst.inc @@ -1,5 +1,5 @@ -choice_attr -~~~~~~~~~~~ +``choice_attr`` +~~~~~~~~~~~~~~~ **type**: ``array``, ``callable`` or ``string`` **default**: ``[]`` diff --git a/reference/forms/types/options/choice_label.rst.inc b/reference/forms/types/options/choice_label.rst.inc index acc909dba7e..49eb1c20dd7 100644 --- a/reference/forms/types/options/choice_label.rst.inc +++ b/reference/forms/types/options/choice_label.rst.inc @@ -1,5 +1,5 @@ -choice_label -~~~~~~~~~~~~ +``choice_label`` +~~~~~~~~~~~~~~~~ **type**: ``string``, ``callable`` or ``false`` **default**: ``null`` diff --git a/reference/forms/types/options/choice_name.rst.inc b/reference/forms/types/options/choice_name.rst.inc index b1f09f79e82..a9cd27e4f52 100644 --- a/reference/forms/types/options/choice_name.rst.inc +++ b/reference/forms/types/options/choice_name.rst.inc @@ -1,5 +1,5 @@ -choice_name -~~~~~~~~~~~ +``choice_name`` +~~~~~~~~~~~~~~~ **type**: ``callable`` or ``string`` **default**: ``null`` diff --git a/reference/forms/types/options/choice_translation_domain.rst.inc b/reference/forms/types/options/choice_translation_domain.rst.inc index ebd6329eb04..de07057bdde 100644 --- a/reference/forms/types/options/choice_translation_domain.rst.inc +++ b/reference/forms/types/options/choice_translation_domain.rst.inc @@ -1,5 +1,5 @@ -choice_translation_domain -~~~~~~~~~~~~~~~~~~~~~~~~~ +``choice_translation_domain`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string``, ``boolean`` or ``null`` diff --git a/reference/forms/types/options/choice_type_trim.rst.inc b/reference/forms/types/options/choice_type_trim.rst.inc index 999a33ef6bc..3a8b7b0ef1c 100644 --- a/reference/forms/types/options/choice_type_trim.rst.inc +++ b/reference/forms/types/options/choice_type_trim.rst.inc @@ -1,5 +1,5 @@ -trim -~~~~ +``trim`` +~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/choice_value.rst.inc b/reference/forms/types/options/choice_value.rst.inc index c2329232b09..a71ba9cdd36 100644 --- a/reference/forms/types/options/choice_value.rst.inc +++ b/reference/forms/types/options/choice_value.rst.inc @@ -1,5 +1,5 @@ -choice_value -~~~~~~~~~~~~ +``choice_value`` +~~~~~~~~~~~~~~~~ **type**: ``callable`` or ``string`` **default**: ``null`` diff --git a/reference/forms/types/options/compound.rst.inc b/reference/forms/types/options/compound.rst.inc index e73b08751c4..528c0a94da9 100644 --- a/reference/forms/types/options/compound.rst.inc +++ b/reference/forms/types/options/compound.rst.inc @@ -1,5 +1,5 @@ -compound -~~~~~~~~ +``compound`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/compound_type.rst.inc b/reference/forms/types/options/compound_type.rst.inc index 39e4abc3dfc..82097123b89 100644 --- a/reference/forms/types/options/compound_type.rst.inc +++ b/reference/forms/types/options/compound_type.rst.inc @@ -1,5 +1,5 @@ -compound -~~~~~~~~ +``compound`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/constraints.rst.inc b/reference/forms/types/options/constraints.rst.inc index fa48dfb4cf1..b06343ca990 100644 --- a/reference/forms/types/options/constraints.rst.inc +++ b/reference/forms/types/options/constraints.rst.inc @@ -1,5 +1,5 @@ -constraints -~~~~~~~~~~~ +``constraints`` +~~~~~~~~~~~~~~~ **type**: ``array`` or :class:`Symfony\\Component\\Validator\\Constraint` **default**: ``null`` diff --git a/reference/forms/types/options/data.rst.inc b/reference/forms/types/options/data.rst.inc index 507d54315ca..c3562d0a8b1 100644 --- a/reference/forms/types/options/data.rst.inc +++ b/reference/forms/types/options/data.rst.inc @@ -1,5 +1,5 @@ -data -~~~~ +``data`` +~~~~~~~~ **type**: ``mixed`` **default**: Defaults to field of the underlying structure. diff --git a/reference/forms/types/options/data_class.rst.inc b/reference/forms/types/options/data_class.rst.inc index 10d6b478210..eb8c5498e39 100644 --- a/reference/forms/types/options/data_class.rst.inc +++ b/reference/forms/types/options/data_class.rst.inc @@ -1,5 +1,5 @@ -data_class -~~~~~~~~~~ +``data_class`` +~~~~~~~~~~~~~~ **type**: ``string`` diff --git a/reference/forms/types/options/data_class_date.rst.inc b/reference/forms/types/options/data_class_date.rst.inc index d11296e263f..7c9d28a68d5 100644 --- a/reference/forms/types/options/data_class_date.rst.inc +++ b/reference/forms/types/options/data_class_date.rst.inc @@ -1,5 +1,5 @@ -data_class -~~~~~~~~~~ +``data_class`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` diff --git a/reference/forms/types/options/date_format.rst.inc b/reference/forms/types/options/date_format.rst.inc index ad1c2a9c718..c7874b505bd 100644 --- a/reference/forms/types/options/date_format.rst.inc +++ b/reference/forms/types/options/date_format.rst.inc @@ -1,5 +1,5 @@ -format -~~~~~~ +``format`` +~~~~~~~~~~ **type**: ``integer`` or ``string`` **default**: `IntlDateFormatter::MEDIUM`_ (or ``yyyy-MM-dd`` if `widget`_ is ``single_text``) diff --git a/reference/forms/types/options/date_input.rst.inc b/reference/forms/types/options/date_input.rst.inc index 4de4643677c..f979dd645e7 100644 --- a/reference/forms/types/options/date_input.rst.inc +++ b/reference/forms/types/options/date_input.rst.inc @@ -1,5 +1,5 @@ -input -~~~~~ +``input`` +~~~~~~~~~ **type**: ``string`` **default**: ``datetime`` diff --git a/reference/forms/types/options/date_widget.rst.inc b/reference/forms/types/options/date_widget.rst.inc index b5e7008b8bf..57f081e5b67 100644 --- a/reference/forms/types/options/date_widget.rst.inc +++ b/reference/forms/types/options/date_widget.rst.inc @@ -1,4 +1,4 @@ -widget -~~~~~~ +``widget`` +~~~~~~~~~~ .. include:: /reference/forms/types/options/date_widget_description.rst.inc diff --git a/reference/forms/types/options/days.rst.inc b/reference/forms/types/options/days.rst.inc index a8034510665..9e46a5709b5 100644 --- a/reference/forms/types/options/days.rst.inc +++ b/reference/forms/types/options/days.rst.inc @@ -1,5 +1,5 @@ -days -~~~~ +``days`` +~~~~~~~~ **type**: ``array`` **default**: 1 to 31 diff --git a/reference/forms/types/options/disabled.rst.inc b/reference/forms/types/options/disabled.rst.inc index 9338b1bc48c..8182bb1d38d 100644 --- a/reference/forms/types/options/disabled.rst.inc +++ b/reference/forms/types/options/disabled.rst.inc @@ -1,5 +1,5 @@ -disabled -~~~~~~~~ +``disabled`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/empty_data.rst.inc b/reference/forms/types/options/empty_data.rst.inc index e3df385a3f9..5e0a23a70b9 100644 --- a/reference/forms/types/options/empty_data.rst.inc +++ b/reference/forms/types/options/empty_data.rst.inc @@ -1,5 +1,5 @@ -empty_data -~~~~~~~~~~ +``empty_data`` +~~~~~~~~~~~~~~ **type**: ``mixed`` diff --git a/reference/forms/types/options/error_bubbling.rst.inc b/reference/forms/types/options/error_bubbling.rst.inc index bc6bc1c5e42..b07866cdf00 100644 --- a/reference/forms/types/options/error_bubbling.rst.inc +++ b/reference/forms/types/options/error_bubbling.rst.inc @@ -1,5 +1,5 @@ -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` unless the form is ``compound`` diff --git a/reference/forms/types/options/error_mapping.rst.inc b/reference/forms/types/options/error_mapping.rst.inc index 5b1122dd5ab..37b3b204483 100644 --- a/reference/forms/types/options/error_mapping.rst.inc +++ b/reference/forms/types/options/error_mapping.rst.inc @@ -1,12 +1,12 @@ -error_mapping -~~~~~~~~~~~~~ +``error_mapping`` +~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` This option allows you to modify the target of a validation error. Imagine you have a custom method named ``matchingCityAndZipCode()`` that validates -whether the city and zip code match. Unfortunately, there is no "matchingCityAndZipCode" +whether the city and zip code match. Unfortunately, there is no ``matchingCityAndZipCode`` field in your form, so all that Symfony can do is display the error on top of the form. diff --git a/reference/forms/types/options/expanded.rst.inc b/reference/forms/types/options/expanded.rst.inc index d57fc7c0892..ed9f7c4fd5e 100644 --- a/reference/forms/types/options/expanded.rst.inc +++ b/reference/forms/types/options/expanded.rst.inc @@ -1,5 +1,5 @@ -expanded -~~~~~~~~ +``expanded`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/extra_fields_message.rst.inc b/reference/forms/types/options/extra_fields_message.rst.inc index d130808191c..ca54c91ec54 100644 --- a/reference/forms/types/options/extra_fields_message.rst.inc +++ b/reference/forms/types/options/extra_fields_message.rst.inc @@ -1,5 +1,5 @@ -extra_fields_message -~~~~~~~~~~~~~~~~~~~~ +``extra_fields_message`` +~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This form should not contain extra fields.`` diff --git a/reference/forms/types/options/group_by.rst.inc b/reference/forms/types/options/group_by.rst.inc index 021d3156d6d..f8ce4aea36d 100644 --- a/reference/forms/types/options/group_by.rst.inc +++ b/reference/forms/types/options/group_by.rst.inc @@ -1,5 +1,5 @@ -group_by -~~~~~~~~ +``group_by`` +~~~~~~~~~~~~ **type**: ``string`` or ``callable`` **default**: ``null`` diff --git a/reference/forms/types/options/grouping.rst.inc b/reference/forms/types/options/grouping.rst.inc index 0ebd339b2e8..564b78be04d 100644 --- a/reference/forms/types/options/grouping.rst.inc +++ b/reference/forms/types/options/grouping.rst.inc @@ -1,5 +1,5 @@ -grouping -~~~~~~~~ +``grouping`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/hours.rst.inc b/reference/forms/types/options/hours.rst.inc index 2af89a163f6..8f71cfd4384 100644 --- a/reference/forms/types/options/hours.rst.inc +++ b/reference/forms/types/options/hours.rst.inc @@ -1,5 +1,5 @@ -hours -~~~~~ +``hours`` +~~~~~~~~~ **type**: ``array`` **default**: 0 to 23 diff --git a/reference/forms/types/options/html5.rst.inc b/reference/forms/types/options/html5.rst.inc index 7ddda4566bd..9353a879218 100644 --- a/reference/forms/types/options/html5.rst.inc +++ b/reference/forms/types/options/html5.rst.inc @@ -1,5 +1,5 @@ -html5 -~~~~~ +``html5`` +~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/inherit_data.rst.inc b/reference/forms/types/options/inherit_data.rst.inc index 8f916f55d24..1b63cc4b56f 100644 --- a/reference/forms/types/options/inherit_data.rst.inc +++ b/reference/forms/types/options/inherit_data.rst.inc @@ -1,5 +1,5 @@ -inherit_data -~~~~~~~~~~~~ +``inherit_data`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/invalid_message.rst.inc b/reference/forms/types/options/invalid_message.rst.inc index 95dd44db379..d6fcacbd036 100644 --- a/reference/forms/types/options/invalid_message.rst.inc +++ b/reference/forms/types/options/invalid_message.rst.inc @@ -1,5 +1,5 @@ -invalid_message -~~~~~~~~~~~~~~~ +``invalid_message`` +~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This value is not valid`` diff --git a/reference/forms/types/options/invalid_message_parameters.rst.inc b/reference/forms/types/options/invalid_message_parameters.rst.inc index f4527da75c0..e9a669819d8 100644 --- a/reference/forms/types/options/invalid_message_parameters.rst.inc +++ b/reference/forms/types/options/invalid_message_parameters.rst.inc @@ -1,5 +1,5 @@ -invalid_message_parameters -~~~~~~~~~~~~~~~~~~~~~~~~~~ +``invalid_message_parameters`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` diff --git a/reference/forms/types/options/label.rst.inc b/reference/forms/types/options/label.rst.inc index e3f66611b83..9797b6264cf 100644 --- a/reference/forms/types/options/label.rst.inc +++ b/reference/forms/types/options/label.rst.inc @@ -1,5 +1,5 @@ -label -~~~~~ +``label`` +~~~~~~~~~ **type**: ``string`` **default**: The label is "guessed" from the field name diff --git a/reference/forms/types/options/label_attr.rst.inc b/reference/forms/types/options/label_attr.rst.inc index 026a9a3ef68..ac18345e67a 100644 --- a/reference/forms/types/options/label_attr.rst.inc +++ b/reference/forms/types/options/label_attr.rst.inc @@ -1,5 +1,5 @@ -label_attr -~~~~~~~~~~ +``label_attr`` +~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` diff --git a/reference/forms/types/options/label_format.rst.inc b/reference/forms/types/options/label_format.rst.inc index 6636a80a825..c45061d4be7 100644 --- a/reference/forms/types/options/label_format.rst.inc +++ b/reference/forms/types/options/label_format.rst.inc @@ -1,5 +1,5 @@ -label_format -~~~~~~~~~~~~ +``label_format`` +~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``null`` diff --git a/reference/forms/types/options/mapped.rst.inc b/reference/forms/types/options/mapped.rst.inc index c2e8972b480..ee2fa328827 100644 --- a/reference/forms/types/options/mapped.rst.inc +++ b/reference/forms/types/options/mapped.rst.inc @@ -1,5 +1,5 @@ -mapped -~~~~~~ +``mapped`` +~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/method.rst.inc b/reference/forms/types/options/method.rst.inc index 0d86d1f47a0..e5f120c2858 100644 --- a/reference/forms/types/options/method.rst.inc +++ b/reference/forms/types/options/method.rst.inc @@ -1,5 +1,5 @@ -method -~~~~~~ +``method`` +~~~~~~~~~~ **type**: ``string`` **default**: ``POST`` diff --git a/reference/forms/types/options/minutes.rst.inc b/reference/forms/types/options/minutes.rst.inc index e9e552ca047..fd27b19ceac 100644 --- a/reference/forms/types/options/minutes.rst.inc +++ b/reference/forms/types/options/minutes.rst.inc @@ -1,5 +1,5 @@ -minutes -~~~~~~~ +``minutes`` +~~~~~~~~~~~ **type**: ``array`` **default**: 0 to 59 diff --git a/reference/forms/types/options/model_timezone.rst.inc b/reference/forms/types/options/model_timezone.rst.inc index e3cdce028e9..a5fd1ee59b8 100644 --- a/reference/forms/types/options/model_timezone.rst.inc +++ b/reference/forms/types/options/model_timezone.rst.inc @@ -1,5 +1,5 @@ -model_timezone -~~~~~~~~~~~~~~ +``model_timezone`` +~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: system default timezone diff --git a/reference/forms/types/options/months.rst.inc b/reference/forms/types/options/months.rst.inc index a53c00faeb4..22fc5a04cd9 100644 --- a/reference/forms/types/options/months.rst.inc +++ b/reference/forms/types/options/months.rst.inc @@ -1,5 +1,5 @@ -months -~~~~~~ +``months`` +~~~~~~~~~~ **type**: ``array`` **default**: 1 to 12 diff --git a/reference/forms/types/options/multiple.rst.inc b/reference/forms/types/options/multiple.rst.inc index 86a72432cb3..7595b0efc90 100644 --- a/reference/forms/types/options/multiple.rst.inc +++ b/reference/forms/types/options/multiple.rst.inc @@ -1,5 +1,5 @@ -multiple -~~~~~~~~ +``multiple`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/placeholder.rst.inc b/reference/forms/types/options/placeholder.rst.inc index b5b13f06844..5920cefbb52 100644 --- a/reference/forms/types/options/placeholder.rst.inc +++ b/reference/forms/types/options/placeholder.rst.inc @@ -1,5 +1,5 @@ -placeholder -~~~~~~~~~~~ +``placeholder`` +~~~~~~~~~~~~~~~ **type**: ``string`` or ``boolean`` diff --git a/reference/forms/types/options/post_max_size_message.rst.inc b/reference/forms/types/options/post_max_size_message.rst.inc index be8612e6bc1..1e895f91f72 100644 --- a/reference/forms/types/options/post_max_size_message.rst.inc +++ b/reference/forms/types/options/post_max_size_message.rst.inc @@ -1,5 +1,5 @@ -post_max_size_message -~~~~~~~~~~~~~~~~~~~~~ +``post_max_size_message`` +~~~~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``The uploaded file was too large. Please try to upload a smaller file.`` diff --git a/reference/forms/types/options/preferred_choices.rst.inc b/reference/forms/types/options/preferred_choices.rst.inc index 3d5d8567543..d1884c3456e 100644 --- a/reference/forms/types/options/preferred_choices.rst.inc +++ b/reference/forms/types/options/preferred_choices.rst.inc @@ -1,5 +1,5 @@ -preferred_choices -~~~~~~~~~~~~~~~~~ +``preferred_choices`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``array``, ``callable`` or ``string`` **default**: ``[]`` diff --git a/reference/forms/types/options/property_path.rst.inc b/reference/forms/types/options/property_path.rst.inc index 95d5f6547ca..7a41eede1af 100644 --- a/reference/forms/types/options/property_path.rst.inc +++ b/reference/forms/types/options/property_path.rst.inc @@ -1,5 +1,5 @@ -property_path -~~~~~~~~~~~~~ +``property_path`` +~~~~~~~~~~~~~~~~~ **type**: ``any`` **default**: ``the field's name`` diff --git a/reference/forms/types/options/required.rst.inc b/reference/forms/types/options/required.rst.inc index f7712114b08..41d4e347de6 100644 --- a/reference/forms/types/options/required.rst.inc +++ b/reference/forms/types/options/required.rst.inc @@ -1,5 +1,5 @@ -required -~~~~~~~~ +``required`` +~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/scale.rst.inc b/reference/forms/types/options/scale.rst.inc index 49d038bc686..0d2ec3d6dbc 100644 --- a/reference/forms/types/options/scale.rst.inc +++ b/reference/forms/types/options/scale.rst.inc @@ -1,5 +1,5 @@ -scale -~~~~~ +``scale`` +~~~~~~~~~ **type**: ``integer`` **default**: Locale-specific (usually around ``3``) diff --git a/reference/forms/types/options/seconds.rst.inc b/reference/forms/types/options/seconds.rst.inc index 7acbf39025c..d3f4dd828d1 100644 --- a/reference/forms/types/options/seconds.rst.inc +++ b/reference/forms/types/options/seconds.rst.inc @@ -1,5 +1,5 @@ -seconds -~~~~~~~ +``seconds`` +~~~~~~~~~~~ **type**: ``array`` **default**: 0 to 59 diff --git a/reference/forms/types/options/translation_domain.rst.inc b/reference/forms/types/options/translation_domain.rst.inc index a045de50214..a91b331e7a3 100644 --- a/reference/forms/types/options/translation_domain.rst.inc +++ b/reference/forms/types/options/translation_domain.rst.inc @@ -1,5 +1,5 @@ -translation_domain -~~~~~~~~~~~~~~~~~~ +``translation_domain`` +~~~~~~~~~~~~~~~~~~~~~~ **type**: ``string``, ``null`` or ``false`` **default**: ``null`` diff --git a/reference/forms/types/options/trim.rst.inc b/reference/forms/types/options/trim.rst.inc index 8d96380ee4a..a1523e95b09 100644 --- a/reference/forms/types/options/trim.rst.inc +++ b/reference/forms/types/options/trim.rst.inc @@ -1,5 +1,5 @@ -trim -~~~~ +``trim`` +~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/validation_groups.rst.inc b/reference/forms/types/options/validation_groups.rst.inc index edff4f733f1..dd9efcd8967 100644 --- a/reference/forms/types/options/validation_groups.rst.inc +++ b/reference/forms/types/options/validation_groups.rst.inc @@ -1,5 +1,5 @@ -validation_groups -~~~~~~~~~~~~~~~~~ +``validation_groups`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``array``, ``string``, ``callable``, :class:`Symfony\\Component\\Validator\\Constraints\\GroupSequence` or ``null`` **default**: ``null`` diff --git a/reference/forms/types/options/value.rst.inc b/reference/forms/types/options/value.rst.inc index 6c94904764f..ddbfff6660d 100644 --- a/reference/forms/types/options/value.rst.inc +++ b/reference/forms/types/options/value.rst.inc @@ -1,5 +1,5 @@ -value -~~~~~ +``value`` +~~~~~~~~~ **type**: ``mixed`` **default**: ``1`` diff --git a/reference/forms/types/options/view_timezone.rst.inc b/reference/forms/types/options/view_timezone.rst.inc index 9d94eac7277..917f519e8aa 100644 --- a/reference/forms/types/options/view_timezone.rst.inc +++ b/reference/forms/types/options/view_timezone.rst.inc @@ -1,5 +1,5 @@ -view_timezone -~~~~~~~~~~~~~ +``view_timezone`` +~~~~~~~~~~~~~~~~~ **type**: ``string`` **default**: system default timezone diff --git a/reference/forms/types/options/with_minutes.rst.inc b/reference/forms/types/options/with_minutes.rst.inc index 636a2c7a3c1..5749f1a32e1 100644 --- a/reference/forms/types/options/with_minutes.rst.inc +++ b/reference/forms/types/options/with_minutes.rst.inc @@ -1,5 +1,5 @@ -with_minutes -~~~~~~~~~~~~ +``with_minutes`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` diff --git a/reference/forms/types/options/with_seconds.rst.inc b/reference/forms/types/options/with_seconds.rst.inc index a5c547fa183..fef7ac1a028 100644 --- a/reference/forms/types/options/with_seconds.rst.inc +++ b/reference/forms/types/options/with_seconds.rst.inc @@ -1,5 +1,5 @@ -with_seconds -~~~~~~~~~~~~ +``with_seconds`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/options/years.rst.inc b/reference/forms/types/options/years.rst.inc index 3c4655697f6..5749c274d66 100644 --- a/reference/forms/types/options/years.rst.inc +++ b/reference/forms/types/options/years.rst.inc @@ -1,5 +1,5 @@ -years -~~~~~ +``years`` +~~~~~~~~~ **type**: ``array`` **default**: five years before to five years after the current year diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 6506f4c8605..d72a4b77728 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -32,8 +32,8 @@ The ``PasswordType`` field renders an input password text box. Field Options ------------- -always_empty -~~~~~~~~~~~~ +``always_empty`` +~~~~~~~~~~~~~~~~ **type**: ``boolean`` **default**: ``true`` @@ -47,8 +47,8 @@ entered into the box, set this to false and submit the form. Overridden Options ------------------ -trim -~~~~ +``trim`` +~~~~~~~~ **type**: ``boolean`` **default**: ``false`` diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 3c1b1576499..3bd10d2ec1f 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -41,16 +41,16 @@ This field adds a percentage sign "``%``" after the input box. Field Options ------------- -scale -~~~~~ +``scale`` +~~~~~~~~~ **type**: ``integer`` **default**: ``0`` By default, the input numbers are rounded. To allow for more decimal places, use this option. -type -~~~~ +``type`` +~~~~~~~~ **type**: ``string`` **default**: ``fractional`` diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index d1f339b8b70..f3ac4242a91 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -101,8 +101,8 @@ be displayed when the two fields do not match each other. Field Options ------------- -first_name -~~~~~~~~~~ +``first_name`` +~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``first`` @@ -112,8 +112,8 @@ will be available under the key assigned to the ``RepeatedType`` field itself (e.g. ``password``). However, if you don't specify a label, this field name is used to "guess" the label for you. -first_options -~~~~~~~~~~~~~ +``first_options`` +~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -129,8 +129,8 @@ the label:: 'second_options' => ['label' => 'Repeat Password'], ]); -options -~~~~~~~ +``options`` +~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -140,15 +140,15 @@ types. For example, if the ``type`` option is set to ``password``, this array might contain the options ``always_empty`` or ``required`` - both options that are supported by the ``PasswordType`` field. -second_name -~~~~~~~~~~~ +``second_name`` +~~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``second`` The same as ``first_name``, but for the second field. -second_options -~~~~~~~~~~~~~~ +``second_options`` +~~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -156,8 +156,8 @@ Additional options (will be merged into `options`_ above) that should be passed *only* to the second field. This is especially useful for customizing the label (see `first_options`_). -type -~~~~ +``type`` +~~~~~~~~ **type**: ``string`` **default**: ``Symfony\Component\Form\Extension\Core\Type\TextType`` @@ -167,8 +167,8 @@ The two underlying fields will be of this field type. For example, passing Overridden Options ------------------ -error_bubbling -~~~~~~~~~~~~~~ +``error_bubbling`` +~~~~~~~~~~~~~~~~~~ **default**: ``false`` diff --git a/reference/forms/types/reset.rst b/reference/forms/types/reset.rst index 4e5053957ef..2502d75c166 100644 --- a/reference/forms/types/reset.rst +++ b/reference/forms/types/reset.rst @@ -22,8 +22,8 @@ A button that resets all fields to their original values. Inherited Options ----------------- -attr -~~~~ +``attr`` +~~~~~~~~ **type**: ``array`` **default**: ``[]`` diff --git a/reference/forms/types/submit.rst b/reference/forms/types/submit.rst index 488224d2309..cd4cbe55cc7 100644 --- a/reference/forms/types/submit.rst +++ b/reference/forms/types/submit.rst @@ -33,8 +33,8 @@ useful when :doc:`a form has multiple submit buttons `:: Inherited Options ----------------- -attr -~~~~ +``attr`` +~~~~~~~~ **type**: ``array`` **default**: ``[]`` @@ -57,8 +57,8 @@ as a key. This can be useful when you need to set a custom class for the button: .. include:: /reference/forms/types/options/button_translation_domain.rst.inc -validation_groups -~~~~~~~~~~~~~~~~~ +``validation_groups`` +~~~~~~~~~~~~~~~~~~~~~ **type**: ``array`` **default**: ``null`` @@ -89,8 +89,8 @@ from the "Registration" are validated. Form Variables -------------- -======== =========== ============================================================== -Variable Type Usage -======== =========== ============================================================== -clicked ``boolean`` Whether the button is clicked or not. -======== =========== ============================================================== +============ =========== ============================================================== +Variable Type Usage +============ =========== ============================================================== +``clicked`` ``boolean`` Whether the button is clicked or not. +============ =========== ============================================================== diff --git a/reference/forms/types/textarea.rst b/reference/forms/types/textarea.rst index 7aaf959b00a..2ff0c5c1ebe 100644 --- a/reference/forms/types/textarea.rst +++ b/reference/forms/types/textarea.rst @@ -30,7 +30,7 @@ Renders a ``textarea`` HTML element. .. tip:: If you prefer to use an **advanced WYSIWYG editor** instead of a plain - textarea, consider using the FOSCKEditorBundle community bundle. Read + ``