From 90ba4de5ea2253904d6d88db69ef6cd0d455cc38 Mon Sep 17 00:00:00 2001 From: Hamza Amrouche Date: Wed, 29 May 2019 07:32:31 +0200 Subject: [PATCH 001/752] minor: update remove of loggingmiddleware --- components/messenger.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/messenger.rst b/components/messenger.rst index 3825d1571ae..9fb4dc6eec8 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -75,8 +75,7 @@ middleware stack. The component comes with a set of middleware that you can use. When using the message bus with Symfony's FrameworkBundle, the following middleware are configured for you: -#. :class:`Symfony\\Component\\Messenger\\Middleware\\LoggingMiddleware` (logs the processing of your messages) -#. :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware` (enables asynchronous processing) +#. :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware` (enables asynchronous processing, logs the processing of your messages if you pass a logger) #. :class:`Symfony\\Component\\Messenger\\Middleware\\HandleMessageMiddleware` (calls the registered handler(s)) Example:: From bcc55c55a68ab728fe56730fbc7d044bdf557fee Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 29 May 2019 12:17:56 +0200 Subject: [PATCH 002/752] Removed Symfony 4.* versionadded directives --- cache.rst | 8 --- .../cache/adapters/memcached_adapter.rst | 4 -- components/cache/adapters/redis_adapter.rst | 8 --- components/cache/psr6_psr16_adapters.rst | 8 --- components/console/helpers/progressbar.rst | 4 -- components/console/helpers/questionhelper.rst | 4 -- components/dom_crawler.rst | 16 ------ components/dotenv.rst | 4 -- components/finder.rst | 9 ---- components/http_client.rst | 4 -- components/intl.rst | 24 --------- components/lock.rst | 4 -- components/options_resolver.rst | 4 -- components/property_access.rst | 5 -- components/routing.rst | 50 ------------------- components/security/authentication.rst | 4 -- components/serializer.rst | 7 +-- configuration/environment_variables.rst | 20 -------- console/coloring.rst | 4 -- form/form_customization.rst | 4 -- form/form_themes.rst | 4 -- http_cache.rst | 5 -- logging.rst | 5 -- logging/processors.rst | 5 -- messenger.rst | 9 ---- reference/configuration/framework.rst | 22 -------- reference/configuration/security.rst | 10 ---- reference/constraints/Bic.rst | 12 ----- reference/constraints/CardScheme.rst | 4 -- reference/constraints/Choice.rst | 8 --- reference/constraints/Negative.rst | 4 -- reference/constraints/NegativeOrZero.rst | 4 -- reference/constraints/NotBlank.rst | 4 -- .../constraints/NotCompromisedPassword.rst | 4 -- reference/constraints/Positive.rst | 4 -- reference/constraints/PositiveOrZero.rst | 4 -- reference/constraints/Timezone.rst | 4 -- reference/forms/types/button.rst | 4 -- reference/forms/types/number.rst | 8 --- .../attr_translation_parameters.rst.inc | 4 -- .../forms/types/options/block_prefix.rst.inc | 4 -- .../date_input_format_description.rst.inc | 4 -- .../help_translation_parameters.rst.inc | 4 -- .../label_translation_parameters.rst.inc | 4 -- reference/forms/types/percent.rst | 4 -- reference/forms/types/time.rst | 4 -- reference/forms/types/timezone.rst | 4 -- routing.rst | 9 ---- routing/custom_route_loader.rst | 5 -- routing/debug.rst | 4 -- routing/service_container_parameters.rst | 4 -- security/csrf.rst | 4 -- security/impersonating_user.rst | 8 --- service_container/alias_private.rst | 4 -- service_container/autowiring.rst | 4 -- service_container/configurators.rst | 4 -- service_container/factories.rst | 4 -- templating/hinclude.rst | 6 --- testing.rst | 4 -- testing/functional_tests_assertions.rst | 5 -- translation.rst | 5 -- workflow.rst | 10 +--- 62 files changed, 2 insertions(+), 429 deletions(-) diff --git a/cache.rst b/cache.rst index 01542cb9b85..c397c031393 100644 --- a/cache.rst +++ b/cache.rst @@ -30,10 +30,6 @@ Basic uses of the cache looks like this:: Symfony supports the Cache Contracts, PSR-6/16 and Doctrine Cache interfaces. You can read more about these at the :doc:`component documentation `. -.. versionadded:: 4.2 - - The cache contracts were introduced in Symfony 4.2. - .. _cache-configuration-with-frameworkbundle: Configuring Cache with FrameworkBundle @@ -612,10 +608,6 @@ To see all available cache pools: $ php bin/console cache:pool:list -.. versionadded:: 4.3 - - The ``cache:pool:list`` command was introduced in Symfony 4.3. - Clear one pool: .. code-block:: terminal diff --git a/components/cache/adapters/memcached_adapter.rst b/components/cache/adapters/memcached_adapter.rst index 42ae791d2d3..b024f3f4178 100644 --- a/components/cache/adapters/memcached_adapter.rst +++ b/components/cache/adapters/memcached_adapter.rst @@ -70,10 +70,6 @@ helper method allows creating and configuring a `Memcached`_ class instance usin 'memcached:?host[localhost]&host[localhost:12345]&host[/some/memcached.sock:]=3' ); -.. versionadded:: 4.2 - - The option to define multiple servers in a single DSN was introduced in Symfony 4.2. - The `Data Source Name (DSN)`_ for this adapter must use the following format: .. code-block:: text diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index 53b28c58466..1cbccc4d749 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -102,14 +102,6 @@ name of your service group:: 'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster' ); -.. versionadded:: 4.2 - - 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 diff --git a/components/cache/psr6_psr16_adapters.rst b/components/cache/psr6_psr16_adapters.rst index 96e29a6d8ea..1bf299ca9d4 100644 --- a/components/cache/psr6_psr16_adapters.rst +++ b/components/cache/psr6_psr16_adapters.rst @@ -46,10 +46,6 @@ this use-case:: // now use this wherever you want $githubApiClient = new GitHubApiClient($psr6Cache); -.. versionadded:: 4.3 - - The ``Psr16Adapter`` class was introduced in Symfony 4.3. - Using a PSR-6 Cache Object as a PSR-16 Cache -------------------------------------------- @@ -87,8 +83,4 @@ this use-case:: // now use this wherever you want $githubApiClient = new GitHubApiClient($psr16Cache); -.. versionadded:: 4.3 - - The ``Psr16Cache`` class was introduced in Symfony 4.3. - .. _`PSR-16`: http://www.php-fig.org/psr/psr-16/ diff --git a/components/console/helpers/progressbar.rst b/components/console/helpers/progressbar.rst index bf832b3131e..04ed076d1a6 100644 --- a/components/console/helpers/progressbar.rst +++ b/components/console/helpers/progressbar.rst @@ -118,10 +118,6 @@ If ``$iterable = [1, 2]``, the previous code will output the following: 1/2 [==============>-------------] 50% 2/2 [============================] 100% -.. versionadded:: 4.3 - - The ``iterate()`` method was introduced in Symfony 4.3. - Customizing the Progress Bar ---------------------------- diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 997e56daf33..348b0f891e6 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -212,10 +212,6 @@ provide a callback function to dynamically generate suggestions:: $filePath = $helper->ask($input, $output, $question); } -.. versionadded:: 4.3 - - The ``setAutocompleterCallback()`` method was introduced in Symfony 4.3. - Hiding the User's Response ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 3f14da6c751..0681b08e764 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -77,10 +77,6 @@ tree. The DomCrawler component will use it automatically when the content has an HTML5 doctype. - .. versionadded:: 4.3 - - The automatic support of the html5-php library was introduced in Symfony 4.3. - Node Filtering ~~~~~~~~~~~~~~ @@ -216,10 +212,6 @@ Access the value of the first node of the current selection:: // avoid the exception passing an argument that text() returns when node does not exist $message = $crawler->filterXPath('//body/p')->text('Default text content'); -.. versionadded:: 4.3 - - The default argument of ``text()`` was introduced in Symfony 4.3. - Access the attribute value of the first node of the current selection:: $class = $crawler->filterXPath('//body/p')->attr('class'); @@ -236,10 +228,6 @@ Extract attribute and/or node values from the list of nodes:: Special attribute ``_text`` represents a node value, while ``_name`` represents the element name (the HTML tag name). - .. versionadded:: 4.3 - - The special attribute ``_name`` was introduced in Symfony 4.3. - Call an anonymous function on each node of the list:: use Symfony\Component\DomCrawler\Crawler; @@ -333,10 +321,6 @@ and :phpclass:`DOMNode` objects:: // avoid the exception passing an argument that html() returns when node does not exist $html = $crawler->html('Default HTML content'); - .. versionadded:: 4.3 - - The default argument of ``html()`` was introduced in Symfony 4.3. - Expression Evaluation ~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/dotenv.rst b/components/dotenv.rst index da4aa3f9cdd..b8856864be0 100644 --- a/components/dotenv.rst +++ b/components/dotenv.rst @@ -104,10 +104,6 @@ You can adjust the variable defining the environment, default environment and te environments by passing them as additional arguments to ``Dotenv::loadEnv()`` (see :method:`Symfony\\Component\\Dotenv\\Dotenv::loadEnv` for details). -.. versionadded:: 4.2 - - The ``Dotenv::loadEnv()`` method was introduced in Symfony 4.2. - You should never store a ``.env`` file in your code repository as it might contain sensitive information; create a ``.env.dist`` file (or multiple environment-specific ones as shown above) with sensible defaults instead. diff --git a/components/finder.rst b/components/finder.rst index 00c5df2bf79..c411a4e83c5 100644 --- a/components/finder.rst +++ b/components/finder.rst @@ -150,10 +150,6 @@ rules to exclude files and directories from the results with the // excludes files/directories matching the .gitignore patterns $finder->ignoreVCSIgnored(true); -.. versionadded:: 4.3 - - The ``ignoreVCSIgnored()`` method was introduced in Symfony 4.3. - File Name ~~~~~~~~~ @@ -250,11 +246,6 @@ Multiple paths can be excluded by chaining calls or passing an array:: // same as above $finder->notPath(['first/dir', 'other/dir']); -.. versionadded:: 4.2 - - Support for passing arrays to ``notPath()`` was introduced in Symfony - 4.2 - File Size ~~~~~~~~~ diff --git a/components/http_client.rst b/components/http_client.rst index 96eee00c476..7ad605f5c5c 100644 --- a/components/http_client.rst +++ b/components/http_client.rst @@ -8,10 +8,6 @@ The HttpClient Component The HttpClient component is a low-level HTTP client with support for both PHP stream wrappers and cURL. It also provides utilities to consume APIs. -.. versionadded:: 4.3 - - The HttpClient component was introduced in Symfony 4.3. - Installation ------------ diff --git a/components/intl.rst b/components/intl.rst index 3e0f8a03208..69e090628e2 100644 --- a/components/intl.rst +++ b/components/intl.rst @@ -92,10 +92,6 @@ You can also check if a given language code is valid:: $isValidLanguage = Languages::exists($languageCode); -.. versionadded:: 4.3 - - The ``Languages`` class was introduced in Symfony 4.3. - The ``Scripts`` class provides access to the optional four-letter script code that can follow the language code according to the `Unicode ISO 15924 Registry`_ (e.g. ``HANS`` in ``zh_HANS`` for simplified Chinese and ``HANT`` in ``zh_HANT`` @@ -125,10 +121,6 @@ You can also check if a given script code is valid:: $isValidScript = Scripts::exists($scriptCode); -.. versionadded:: 4.3 - - The ``Scripts`` class was introduced in Symfony 4.3. - Country Names ~~~~~~~~~~~~~ @@ -160,10 +152,6 @@ You can also check if a given country code is valid:: $isValidCountry = Countries::exists($countryCode); -.. versionadded:: 4.3 - - The ``Countries`` class was introduced in Symfony 4.3. - Locales ~~~~~~~ @@ -196,10 +184,6 @@ You can also check if a given locale code is valid:: $isValidLocale = Locales::exists($localeCode); -.. versionadded:: 4.3 - - The ``Locales`` class was introduced in Symfony 4.3. - Currencies ~~~~~~~~~~ @@ -240,10 +224,6 @@ You can also check if a given currency code is valid:: $isValidCurrency = Currencies::exists($currencyCode); -.. versionadded:: 4.3 - - The ``Currencies`` class was introduced in Symfony 4.3. - Timezones ~~~~~~~~~ @@ -273,10 +253,6 @@ You can also check if a given timezone ID is valid:: $isValidTimezone = Timezones::exists($timezoneId); -.. versionadded:: 4.3 - - The ``Timezones`` class was introduced in Symfony 4.3. - Learn more ---------- diff --git a/components/lock.rst b/components/lock.rst index 92d917b2fc3..f6e1a761208 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -223,10 +223,6 @@ support blocking, and expects a TTL to avoid stalled locks:: MongoDbStore ~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``MongoDbStore`` was introduced in Symfony 4.3. - The MongoDbStore saves locks on a MongoDB server, it requires a ``\MongoDB\Client`` connection from `mongodb/mongodb`_. This store does not support blocking and expects a TTL to avoid stalled locks:: diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 16f891ea869..17fde396792 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -439,10 +439,6 @@ This way, the ``$value`` argument will receive the previously normalized value, otherwise you can prepend the new normalizer by passing ``true`` as third argument. -.. versionadded:: 4.3 - - The ``addNormalizer()`` method was introduced in Symfony 4.3. - Default Values that Depend on another Option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/property_access.rst b/components/property_access.rst index c362da2da22..ef6394393a8 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -169,11 +169,6 @@ This will produce: ``He is an author`` Accessing a non Existing Property Path ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``disableExceptionOnInvalidPropertyPath()`` method was introduced in - Symfony 4.3. - By default a :class:`Symfony\\Component\\PropertyAccess\\Exception\\NoSuchPropertyException` is thrown if the property path passed to :method:`PropertyAccessor::getValue` does not exist. You can change this behavior using the diff --git a/components/routing.rst b/components/routing.rst index dc0600d0eb0..111ea10f9e5 100644 --- a/components/routing.rst +++ b/components/routing.rst @@ -454,56 +454,6 @@ routes with UTF-8 characters: ; }; -.. versionadded:: 4.3 - - The ``utf8`` option/method has been introduced in Symfony 4.3. - Before you had to use the ``options`` setting to define this value: - - .. configuration-block:: - - .. code-block:: php-annotations - - route1: - path: /category/{name} - controller: App\Controller\DefaultController::category - options: { utf8: true } - - .. code-block:: yaml - - route1: - path: /category/{name} - controller: App\Controller\DefaultController::category - utf8: true - - .. code-block:: xml - - - - - - - - - - .. code-block:: php - - // config/routes.php - namespace Symfony\Component\Routing\Loader\Configurator; - - use App\Controller\DefaultController; - - return function (RoutingConfigurator $routes) { - $routes->add('route1', '/category/{name}') - ->controller([DefaultController::class, 'category']) - ->options(['utf8' => true]) - ; - }; - In this route, the ``utf8`` option set to ``true`` makes Symfony consider the ``.`` requirement to match any UTF-8 characters instead of just a single byte character. This means that so the following URLs would match: diff --git a/components/security/authentication.rst b/components/security/authentication.rst index 7fd59c6c857..5b91ab2c183 100644 --- a/components/security/authentication.rst +++ b/components/security/authentication.rst @@ -318,10 +318,6 @@ the ``switch_user`` firewall listener. The ``Symfony\Component\Security\Http\Event\DeauthenticatedEvent`` event is triggered when a token has been deauthenticated because of a user change, it can help you doing some clean-up task when a logout has been triggered. -.. versionadded:: 4.3 - - The ``Symfony\Component\Security\Http\Event\DeauthenticatedEvent`` event was introduced in Symfony 4.3. - .. seealso:: For more information on switching users, see diff --git a/components/serializer.rst b/components/serializer.rst index 1c6359033bc..76819a816ed 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -223,11 +223,6 @@ normalized data, instead of the denormalizer re-creating them. Note that arrays of objects. Those will still be replaced when present in the normalized data. -.. versionadded:: 4.3 - - The ``AbstractObjectNormalizer::DEEP_OBJECT_TO_POPULATE`` option was - introduced in Symfony 4.3. - .. _component-serializer-attributes-groups: Attributes Groups @@ -664,7 +659,7 @@ When serializing, you can set a callback to format a specific object property:: 'createdAt' => $callback, ], ]; - + $normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext); $serializer = new Serializer([$normalizer], [$encoder]); diff --git a/configuration/environment_variables.rst b/configuration/environment_variables.rst index e9e258c4aa1..b59ef5de690 100644 --- a/configuration/environment_variables.rst +++ b/configuration/environment_variables.rst @@ -497,19 +497,11 @@ Symfony provides the following env var processors: 'auth' => '%env(require:AUTH_FILE)%', ]); - .. versionadded:: 4.3 - - The ``require`` processor was introduced in Symfony 4.3. - ``env(trim:FOO)`` Trims the content of ``FOO`` env var, removing whitespaces from the beginning and end of the string. This is especially useful in combination with the ``file`` processor, as it'll remove newlines at the end of a file. - .. versionadded:: 4.3 - - The ``trim`` processor was introduced in Symfony 4.3. - ``env(key:FOO:BAR)`` Retrieves the value associated with the key ``FOO`` from the array whose contents are stored in the ``BAR`` env var: @@ -591,10 +583,6 @@ Symfony provides the following env var processors: When the fallback parameter is omitted (e.g. ``env(default::API_KEY)``), the value returned is ``null``. - .. versionadded:: 4.3 - - The ``default`` processor was introduced in Symfony 4.3. - ``env(url:FOO)`` Parses an absolute URL and returns its components as an associative array. @@ -664,10 +652,6 @@ Symfony provides the following env var processors: In order to ease extraction of the resource from the URL, the leading ``/`` is trimmed from the ``path`` component. - .. versionadded:: 4.3 - - The ``url`` processor was introduced in Symfony 4.3. - ``env(query_string:FOO)`` Parses the query string part of the given URL and returns its components as an associative array. @@ -714,10 +698,6 @@ Symfony provides the following env var processors: ], ]); - .. versionadded:: 4.3 - - The ``query_string`` processor was introduced in Symfony 4.3. - It is also possible to combine any number of processors: .. code-block:: yaml diff --git a/console/coloring.rst b/console/coloring.rst index 2963fefa682..32625377aba 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -77,10 +77,6 @@ You can also set these colors and options directly inside the tag name:: Displaying Clickable Links ~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The feature to display clickable links was introduced in Symfony 4.3. - Commands can use the special ```` tag to display links similar to the ```` elements of web pages:: diff --git a/form/form_customization.rst b/form/form_customization.rst index 3094eb08f40..ef5733b3146 100644 --- a/form/form_customization.rst +++ b/form/form_customization.rst @@ -315,10 +315,6 @@ spot (since it'll render the field for you). form_parent(form_view) ...................... -.. versionadded:: 4.3 - - The ``form_parent()`` function was introduced in Symfony 4.3. - Returns the parent form view or ``null`` if the form view already is the root form. Using this function should be preferred over accessing the parent form using ``form.parent``. The latter way will produce different results diff --git a/form/form_themes.rst b/form/form_themes.rst index 32322381c08..659dfde50ee 100644 --- a/form/form_themes.rst +++ b/form/form_themes.rst @@ -294,10 +294,6 @@ field without having to :doc:`create a custom form type ` constraint uses the public API provided by `haveibeenpwned.com`_. This option allows to define a different, but compatible, API endpoint to make the password diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 5fba7fc34ad..5b00a9c5206 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -246,11 +246,6 @@ encoding algorithm. Also, each algorithm defines different config options: alternative is provided because starting from Symfony 5.0 this value will be hardcoded to ``1`` (one thread). -.. versionadded:: 4.3 - - The ``sodium`` algorithm was introduced in Symfony 4.3. In previous Symfony - versions it was called ``argon2i``. - .. tip:: You can also create your own password encoders as services and you can even @@ -263,11 +258,6 @@ encoding algorithm. Also, each algorithm defines different config options: Using the Sodium Password Encoder ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.3 - - The ``SodiumPasswordEncoder`` was introduced in Symfony 4.3. In previous - Symfony versions it was called ``Argon2iPasswordEncoder``. - It uses the `Argon2 key derivation function`_ and it's the encoder recommended by Symfony. Argon2 support was introduced in PHP 7.2, but if you use an earlier PHP version, you can install the `libsodium`_ PHP extension. diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index e12aacbaf63..c65d3223110 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -92,10 +92,6 @@ iban **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``iban`` option was introduced in Symfony 4.3. - An IBAN value to validate that the BIC is associated with it. ibanMessage @@ -103,10 +99,6 @@ ibanMessage **type**: ``string`` **default**: ``This Business Identifier Code (BIC) is not associated with IBAN {{ iban }}.`` -.. versionadded:: 4.3 - - The ``ibanMessage`` option was introduced in Symfony 4.3. - The default message supplied when the value does not pass the combined BIC/IBAN check. ibanPropertyPath @@ -114,10 +106,6 @@ ibanPropertyPath **type**: ``string`` **default**: ``null`` -.. versionadded:: 4.3 - - The ``ibanPropertyPath`` option was introduced in Symfony 4.3. - It defines the object property whose value stores the IBAN used to check the BIC with. For example, if you want to compare the ``$bic`` property of some object diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 6362d9932ee..6adfe62d893 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -138,10 +138,6 @@ Valid values are: * ``UATP`` * ``VISA`` -.. versionadded:: 4.3 - - The ``UATP`` and ``MIR`` number schemes were introduced in Symfony 4.3. - For more information about the used schemes, see `Wikipedia: Issuer identification number (IIN)`_. diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 7cc8ae3ac1f..25feac3506e 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -322,10 +322,6 @@ Parameter Description ``{{ value }}`` The current (invalid) value ================= ============================================================ -.. versionadded:: 4.3 - - The ``{{ choices }}`` parameter was introduced in Symfony 4.3. - message ~~~~~~~ @@ -370,10 +366,6 @@ Parameter Description ``{{ value }}`` The current (invalid) value ================= ============================================================ -.. versionadded:: 4.3 - - The ``{{ choices }}`` parameter was introduced in Symfony 4.3. - multiple ~~~~~~~~ diff --git a/reference/constraints/Negative.rst b/reference/constraints/Negative.rst index c90a1fb1c98..76d97a5bf98 100644 --- a/reference/constraints/Negative.rst +++ b/reference/constraints/Negative.rst @@ -1,10 +1,6 @@ Negative ======== -.. versionadded:: 4.3 - - The ``Negative`` constraint was introduced in Symfony 4.3. - Validates that a value is a negative number. Zero is neither positive nor negative, so you must use :doc:`/reference/constraints/NegativeOrZero` if you want to allow zero as value. diff --git a/reference/constraints/NegativeOrZero.rst b/reference/constraints/NegativeOrZero.rst index 15d0926bc5d..66ae33e914b 100644 --- a/reference/constraints/NegativeOrZero.rst +++ b/reference/constraints/NegativeOrZero.rst @@ -1,10 +1,6 @@ NegativeOrZero ============== -.. versionadded:: 4.3 - - The ``NegativeOrZero`` constraint was introduced in Symfony 4.3. - Validates that a value is a negative number or equal to zero. If you don't want to allow zero as value, use :doc:`/reference/constraints/Negative` instead. diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index 83b2713d225..0eed60ef9df 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -90,10 +90,6 @@ allowNull If set to ``true``, ``null`` values are considered valid and won't trigger a constraint violation. -.. versionadded:: 4.3 - - The ``allowNull`` option was introduced in Symfony 4.3. - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/constraints/NotCompromisedPassword.rst b/reference/constraints/NotCompromisedPassword.rst index ffa9fe99d8d..6d2cb52f1aa 100644 --- a/reference/constraints/NotCompromisedPassword.rst +++ b/reference/constraints/NotCompromisedPassword.rst @@ -1,10 +1,6 @@ NotCompromisedPassword ====================== -.. versionadded:: 4.3 - - The ``NotCompromisedPassword`` constraint was introduced in Symfony 4.3. - Validates that the given password has not been compromised by checking that it is not included in any of the public data breaches tracked by `haveibeenpwned.com`_. diff --git a/reference/constraints/Positive.rst b/reference/constraints/Positive.rst index b9bef408fa5..5800347ba8e 100644 --- a/reference/constraints/Positive.rst +++ b/reference/constraints/Positive.rst @@ -1,10 +1,6 @@ Positive ======== -.. versionadded:: 4.3 - - The ``Positive`` constraint was introduced in Symfony 4.3. - Validates that a value is a positive number. Zero is neither positive nor negative, so you must use :doc:`/reference/constraints/PositiveOrZero` if you want to allow zero as value. diff --git a/reference/constraints/PositiveOrZero.rst b/reference/constraints/PositiveOrZero.rst index 70196a6b9fa..4b526026fd9 100644 --- a/reference/constraints/PositiveOrZero.rst +++ b/reference/constraints/PositiveOrZero.rst @@ -1,10 +1,6 @@ PositiveOrZero ============== -.. versionadded:: 4.3 - - The ``PositiveOrZero`` constraint was introduced in Symfony 4.3. - Validates that a value is a positive number or equal to zero. If you don't want to allow zero as value, use :doc:`/reference/constraints/Positive` instead. diff --git a/reference/constraints/Timezone.rst b/reference/constraints/Timezone.rst index c195a5d46f6..032df5f07f2 100644 --- a/reference/constraints/Timezone.rst +++ b/reference/constraints/Timezone.rst @@ -1,10 +1,6 @@ Timezone ======== -.. versionadded:: 4.3 - - The ``Timezone`` constraint was introduced in Symfony 4.3. - Validates that a value is a valid timezone identifier (e.g. ``Europe/Paris``). ========== ====================================================================== diff --git a/reference/forms/types/button.rst b/reference/forms/types/button.rst index d009b80235e..9978c5fb50a 100644 --- a/reference/forms/types/button.rst +++ b/reference/forms/types/button.rst @@ -59,10 +59,6 @@ label_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``label_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `label`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index c5db2c7b092..c3306269c18 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -53,10 +53,6 @@ html5 **type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.3 - - The ``html5`` option was introduced in Symfony 4.3. - If set to ``true``, the HTML input will be rendered as a native HTML5 ``type="number"`` form. @@ -65,10 +61,6 @@ input **type**: ``string`` **default**: ``number`` -.. versionadded:: 4.3 - - The ``input`` option was introduced in Symfony 4.3. - The format of the input data - i.e. the format that the number is stored on your underlying object. Valid values are ``number`` and ``string``. Setting this option to ``string`` can be useful if the underlying data is a string diff --git a/reference/forms/types/options/attr_translation_parameters.rst.inc b/reference/forms/types/options/attr_translation_parameters.rst.inc index 98326ba4abe..71187cd75c5 100644 --- a/reference/forms/types/options/attr_translation_parameters.rst.inc +++ b/reference/forms/types/options/attr_translation_parameters.rst.inc @@ -3,10 +3,6 @@ attr_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``attr_translation_parameters`` option was introduced in Symfony 4.3. - The content of the ``title`` and ``placeholder`` values defined in the `attr`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This diff --git a/reference/forms/types/options/block_prefix.rst.inc b/reference/forms/types/options/block_prefix.rst.inc index f02feb0ce70..db012bc3c42 100644 --- a/reference/forms/types/options/block_prefix.rst.inc +++ b/reference/forms/types/options/block_prefix.rst.inc @@ -4,10 +4,6 @@ block_prefix **type**: ``string`` or ``null`` **default**: ``null`` (see :ref:`Knowing which block to customize `) -.. versionadded:: 4.3 - - The ``block_prefix`` option was introduced in Symfony 4.3. - Allows you to add a custom block prefix and override the block name used to render the form type. Useful for example if you have multiple instances of the same form and you need to personalize the rendering diff --git a/reference/forms/types/options/date_input_format_description.rst.inc b/reference/forms/types/options/date_input_format_description.rst.inc index 4cd9b353e31..e411cd12d70 100644 --- a/reference/forms/types/options/date_input_format_description.rst.inc +++ b/reference/forms/types/options/date_input_format_description.rst.inc @@ -1,7 +1,3 @@ -.. versionadded:: 4.3 - - The ``input_format`` option was introduced in Symfony 4.3. - If the ``input`` option is set to ``string``, this option specifies the format of the date. This must be a valid `PHP date format`_. diff --git a/reference/forms/types/options/help_translation_parameters.rst.inc b/reference/forms/types/options/help_translation_parameters.rst.inc index 4294fb2b185..2b69e237941 100644 --- a/reference/forms/types/options/help_translation_parameters.rst.inc +++ b/reference/forms/types/options/help_translation_parameters.rst.inc @@ -3,10 +3,6 @@ help_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``help_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `help`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/options/label_translation_parameters.rst.inc b/reference/forms/types/options/label_translation_parameters.rst.inc index 443c6706f14..815b780553e 100644 --- a/reference/forms/types/options/label_translation_parameters.rst.inc +++ b/reference/forms/types/options/label_translation_parameters.rst.inc @@ -3,10 +3,6 @@ label_translation_parameters **type**: ``array`` **default**: ``[]`` -.. versionadded:: 4.3 - - The ``label_translation_parameters`` option was introduced in Symfony 4.3. - The content of the `label`_ option is translated before displaying it, so it can contain :ref:`translation placeholders `. This option defines the values used to replace those placeholders. diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index b90d57de2b5..5bf742da1b0 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -61,10 +61,6 @@ symbol **type**: ``boolean`` or ``string`` **default**: ``true`` -.. versionadded:: 4.3 - - The ``symbol`` option was introduced in Symfony 4.3. - By default, fields are rendered with a percentage sign ``%`` after the input. Setting the value to ``false`` will not display the percentage sign. Setting the value to a ``string`` (e.g. ``‱``), will show that string instead of the default diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 0636f34fb5b..1aea97ad89d 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -137,10 +137,6 @@ input_format **type**: ``string`` **default**: ``H:i:s`` -.. versionadded:: 4.3 - - The ``input_format`` option was introduced in Symfony 4.3. - If the ``input`` option is set to ``string``, this option specifies the format of the time. This must be a valid `PHP time format`_. diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 96e61de0d34..a76c5ae2363 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -69,10 +69,6 @@ on your underlying object. Valid values are: * ``intltimezone`` (an ``\IntlTimeZone`` object) * ``string`` (e.g. ``America/New_York``) -.. versionadded:: 4.3 - - The ``intltimezone`` input type was introduced in Symfony 4.3. - regions ~~~~~~~ diff --git a/routing.rst b/routing.rst index ec05ef50071..e4a3e3b51aa 100644 --- a/routing.rst +++ b/routing.rst @@ -535,11 +535,6 @@ If you want to always include some default value in the generated URL (for example to force the generation of ``/blog/1`` instead of ``/blog`` in the previous example) add the ``!`` character before the placeholder name: ``/blog/{!page}`` -.. versionadded:: 4.3 - - The feature to force the inclusion of default values in generated URLs was - introduced in Symfony 4.3. - As it happens with requirements, default values can also be inlined in each placeholder using the syntax ``{placeholder_name?default_value}``. This feature is compatible with inlined requirements, so you can inline both in a single @@ -845,10 +840,6 @@ You can also use special attributes to configure them (except ``_fragment``): These attributes can also be used for route imports. -.. versionadded:: 4.3 - - The special attributes were introduced in Symfony 4.3. - .. _routing-trailing-slash-redirection: Redirecting URLs with Trailing Slashes diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 748558a3c78..3fac4e5af09 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -137,11 +137,6 @@ extend or implement any special class, but the called method must return a If your service is invokable, you don't need to precise the method to use. -.. versionadded:: 4.3 - - The support of the ``__invoke()`` method to create invokable route loader - services was introduced in Symfony 4.3. - Creating a custom Loader ------------------------ diff --git a/routing/debug.rst b/routing/debug.rst index f83331488cc..7de6d8bb930 100644 --- a/routing/debug.rst +++ b/routing/debug.rst @@ -65,7 +65,3 @@ which route is associated with the given URL: | | utf8: true | | Condition | context.getMethod() in ['GET', 'HEAD', 'POST'] | +--------------+---------------------------------------------------------+ - -.. versionadded:: 4.3 - - The ``Condition`` was added to the router debug output in Symfony 4.3. diff --git a/routing/service_container_parameters.rst b/routing/service_container_parameters.rst index 58c26ad7da2..ba73b35d63c 100644 --- a/routing/service_container_parameters.rst +++ b/routing/service_container_parameters.rst @@ -75,10 +75,6 @@ inside your routing configuration: ; }; -.. versionadded:: 4.3 - - Support for boolean container parameters in routes was introduced in Symfony 4.3. - You can now control and set the ``app.locales`` parameter somewhere in your container: diff --git a/security/csrf.rst b/security/csrf.rst index 620df0f887e..45520e4bf2b 100644 --- a/security/csrf.rst +++ b/security/csrf.rst @@ -113,10 +113,6 @@ You can also customize the rendering of the CSRF form field creating a custom the field (e.g. define ``{% block csrf_token_widget %} ... {% endblock %}`` to customize the entire form field contents). -.. versionadded:: 4.3 - - The ``csrf_token`` form field prefix was introduced in Symfony 4.3. - CSRF Protection in Login Forms ------------------------------ diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 1a6e47365b4..365cd86fc6b 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -98,10 +98,6 @@ to show a link to exit impersonation: Finding the Original User ------------------------- -.. versionadded:: 4.3 - - The ``SwitchUserToken`` class was introduced in Symfony 4.3. - In some cases, you may need to get the object that represents the impersonator user rather than the impersonated user. When a user is impersonated the token stored in the token storage will be a ``SwitchUserToken`` instance. Use the @@ -234,10 +230,6 @@ Create the voter class:: } } -.. versionadded:: 4.3 - - The ``getRoleNames()`` method was introduced in Symfony 4.3. - To enable the new voter in the app, register it as a service and :doc:`tag it ` with the ``security.voter`` tag. If you're using the diff --git a/service_container/alias_private.rst b/service_container/alias_private.rst index 307056e4056..828e6d71284 100644 --- a/service_container/alias_private.rst +++ b/service_container/alias_private.rst @@ -205,10 +205,6 @@ The message is actually a message template, which replaces occurrences of the ``%alias_id%`` placeholder by the service alias id. You **must** have at least one occurrence of the ``%alias_id%`` placeholder in your template. -.. versionadded:: 4.3 - - The ``deprecated`` option for service aliases was introduced in Symfony 4.3. - Anonymous Services ------------------ diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 26c8f55ed0d..c02f2ef08dc 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -480,10 +480,6 @@ If the argument is named ``$shoutyTransformer``, But, you can also manually wire any *other* service by specifying the argument under the arguments key. -.. versionadded:: 4.2 - - Named autowiring aliases have been introduced in Symfony 4.2. - Fixing Non-Autowireable Arguments --------------------------------- diff --git a/service_container/configurators.rst b/service_container/configurators.rst index def35e3fef9..7f61c671747 100644 --- a/service_container/configurators.rst +++ b/service_container/configurators.rst @@ -197,10 +197,6 @@ the service id and the method name: .. _configurators-invokable: -.. versionadded:: 4.3 - - Invokable configurators for services were introduced in Symfony 4.3. - Services can be configured via invokable configurators (replacing the ``configure()`` method with ``__invoke()``) by omitting the method name, just as routes can reference :ref:`invokable controllers `. diff --git a/service_container/factories.rst b/service_container/factories.rst index 3fc4a979336..e698b4eea95 100644 --- a/service_container/factories.rst +++ b/service_container/factories.rst @@ -175,10 +175,6 @@ factory service can be used as a callback:: } } -.. versionadded:: 4.3 - - Invokable factories for services were introduced in Symfony 4.3. - Services can be created and configured via invokable factories by omitting the method name, just as routes can reference :ref:`invokable controllers `. diff --git a/templating/hinclude.rst b/templating/hinclude.rst index ee5047cc124..7814e0130f6 100644 --- a/templating/hinclude.rst +++ b/templating/hinclude.rst @@ -97,12 +97,6 @@ in your application configuration: ], ]); -.. versionadded:: 4.3 - - The ``framework.fragments.hinclude_default_template`` option was introduced - in Symfony 4.3. In previous Symfony versions it was called - ``framework.templating.hinclude_default_template``. - You can define default templates per ``render()`` function (which will override any global default template that is defined): diff --git a/testing.rst b/testing.rst index 3163d57721a..d79871c4432 100644 --- a/testing.rst +++ b/testing.rst @@ -215,10 +215,6 @@ its existence, attributes, text, etc. The ``assertSelectorTextContains`` method is not a native PHPUnit assertion and is available thanks to the ``WebTestCase`` class. -.. versionadded:: 4.3 - - The ``WebTestCase`` assertions were introduced in Symfony 4.3 - .. seealso:: Using native PHPUnit methods, the same assertion would look like this:: diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 63482dd046b..812b35ef94f 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -4,11 +4,6 @@ Functional Test specific Assertions =================================== -.. versionadded:: 4.3 - - The shortcut methods for assertions using ``WebTestCase`` were introduced - in Symfony 4.3. - When doing functional tests, sometimes you need to make complex assertions in order to check whether the ``Request``, the ``Response`` or the ``Crawler`` contain the expected information to make your test succeed. diff --git a/translation.rst b/translation.rst index 3b1692c3755..c095793038b 100644 --- a/translation.rst +++ b/translation.rst @@ -368,11 +368,6 @@ The ``translation:update`` command looks for missing translations in: * Any PHP file/class that injects or :doc:`autowires ` the ``translator`` service and makes calls to the ``trans()`` function. -.. versionadded:: 4.3 - - The extraction of missing translation strings from PHP files was introduced - in Symfony 4.3. - .. note:: If you want to see the missing translation strings without actually updating diff --git a/workflow.rst b/workflow.rst index e2a542c8683..37017b6ba66 100644 --- a/workflow.rst +++ b/workflow.rst @@ -318,7 +318,7 @@ workflow leaves a place:: class WorkflowLogger implements EventSubscriberInterface { private $logger; - + public function __construct(LoggerInterface $logger) { $this->logger = $logger; @@ -502,10 +502,6 @@ place:: } } -.. versionadded:: 4.1 - - The transition blockers were introduced in Symfony 4.1. - Usage in Twig ------------- @@ -559,10 +555,6 @@ The following example shows these functions in action: Storing Metadata ---------------- -.. versionadded:: 4.1 - - The feature to store metadata in workflows was introduced in Symfony 4.1. - In case you need it, you can store arbitrary metadata in workflows, their places, and their transitions using the ``metadata`` option. This metadata can be as simple as the title of the workflow or as complex as your own application From 6bf9ef5d835f9e870e2ca92173aa9b8d853a5895 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 30 May 2019 12:46:10 +0200 Subject: [PATCH 003/752] Removed the deprecation message --- components/messenger.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/messenger.rst b/components/messenger.rst index 13fb4093dac..9fb4dc6eec8 100644 --- a/components/messenger.rst +++ b/components/messenger.rst @@ -78,11 +78,6 @@ are configured for you: #. :class:`Symfony\\Component\\Messenger\\Middleware\\SendMessageMiddleware` (enables asynchronous processing, logs the processing of your messages if you pass a logger) #. :class:`Symfony\\Component\\Messenger\\Middleware\\HandleMessageMiddleware` (calls the registered handler(s)) -.. deprecated:: 4.3 - - The ``LoggingMiddleware`` is deprecated since Symfony 4.3 and will be - removed in 5.0. Pass a logger to ``SendMessageMiddleware`` instead. - Example:: use App\Message\MyMessage; From ce64ac294bf9ec5479fa0b9a1976b5b24d7433b4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 29 May 2019 13:15:44 +0200 Subject: [PATCH 004/752] Removed deprecated contents --- bundles/configuration.rst | 4 - components/config/definition.rst | 4 - components/serializer.rst | 24 +- configuration/environment_variables.rst | 8 +- configuration/environments.rst | 10 +- console/commands_as_services.rst | 7 - controller/argument_value_resolver.rst | 11 - controller/upload_file.rst | 8 +- form/create_custom_field_type.rst | 6 - reference/configuration/framework.rst | 138 ------ reference/configuration/kernel.rst | 30 +- reference/configuration/security.rst | 31 +- reference/configuration/twig.rst | 7 - reference/constraints/Email.rst | 40 +- reference/constraints/Locale.rst | 20 +- reference/constraints/Url.rst | 167 +------ reference/dic_tags.rst | 48 -- reference/forms/types/date.rst | 5 - reference/forms/types/datetime.rst | 20 - reference/forms/types/integer.rst | 17 +- reference/forms/types/timezone.rst | 13 +- templating/PHP.rst | 572 +----------------------- translation.rst | 11 +- 23 files changed, 33 insertions(+), 1168 deletions(-) diff --git a/bundles/configuration.rst b/bundles/configuration.rst index 88e038e833f..256679e9bc1 100644 --- a/bundles/configuration.rst +++ b/bundles/configuration.rst @@ -197,10 +197,6 @@ The ``Configuration`` class to handle the sample configuration looks like:: } } -.. deprecated:: 4.2 - - Not passing the root node name to ``TreeBuilder`` was deprecated in Symfony 4.2. - .. seealso:: The ``Configuration`` class can be much more complicated than shown here, diff --git a/components/config/definition.rst b/components/config/definition.rst index e76b55da1a0..27f9da0688d 100644 --- a/components/config/definition.rst +++ b/components/config/definition.rst @@ -68,10 +68,6 @@ implements the :class:`Symfony\\Component\\Config\\Definition\\ConfigurationInte } } -.. deprecated:: 4.2 - - Not passing the root node name to ``TreeBuilder`` was deprecated in Symfony 4.2. - Adding Node Definitions to the Tree ----------------------------------- diff --git a/components/serializer.rst b/components/serializer.rst index 1c6359033bc..f7fe691835c 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -434,12 +434,6 @@ key in the ``context`` parameter of the desired serializer method:: $serializer = new Serializer([$normalizer], [$encoder]); $serializer->serialize($person, 'json', ['ignored_attributes' => ['age']]); // Output: {"name":"foo"} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setIgnoredAttributes` - method that was used as an alternative to the ``ignored_attributes`` option - was deprecated in Symfony 4.2. - .. _component-serializer-converting-property-names-when-serializing-and-deserializing: Converting Property Names when Serializing and Deserializing @@ -639,12 +633,6 @@ and ``remove``. Using Callbacks to Serialize Properties with Object Instances ------------------------------------------------------------- -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCallbacks` - method is deprecated since Symfony 4.2. Use the ``callbacks`` - key of the context instead. - When serializing, you can set a callback to format a specific object property:: use App\Model\Person; @@ -664,7 +652,7 @@ When serializing, you can set a callback to format a specific object property:: 'createdAt' => $callback, ], ]; - + $normalizer = new GetSetMethodNormalizer(null, null, null, null, null, $defaultContext); $serializer = new Serializer([$normalizer], [$encoder]); @@ -800,10 +788,6 @@ 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`` ~~~~~~~~~~~~~~~~~~ @@ -951,12 +935,6 @@ The ``setCircularReferenceLimit()`` method of this normalizer sets the number of times it will serialize the same object before considering it a circular reference. Its default value is ``1``. -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCircularReferenceHandler` - method is deprecated since Symfony 4.2. Use the ``circular_reference_handler`` - key of the context instead. - Instead of throwing an exception, circular references can also be handled by custom callables. This is especially useful when serializing entities having unique identifiers:: diff --git a/configuration/environment_variables.rst b/configuration/environment_variables.rst index e9e258c4aa1..a6ed20db35b 100644 --- a/configuration/environment_variables.rst +++ b/configuration/environment_variables.rst @@ -97,11 +97,11 @@ whenever the corresponding environment variable is *not* found: // config/services.php $container->setParameter('env(DATABASE_HOST)', 'localhost'); -.. deprecated:: 4.3 +.. note:: - Passing non-string values as default values for environment variables is - deprecated since Symfony 4.3. Use :ref:`environment variable processors ` - if you need to transform those string default values into other data types. + The default values of environment variables must be strings, but you can use + :ref:`environment variable processors ` to transform + them into other data types. .. _configuration-env-var-in-prod: diff --git a/configuration/environments.rst b/configuration/environments.rst index 0efac1eb899..863dc63739b 100644 --- a/configuration/environments.rst +++ b/configuration/environments.rst @@ -173,13 +173,9 @@ Selecting the Environment for Console Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, Symfony commands are executed in whatever environment is defined by -the ``APP_ENV`` environment variable (usually configured in your ``.env`` file). -In previous Symfony versions you could use the ``--env`` (and ``--no-debug``) -command line options to override this value. However, those options were -deprecated in Symfony 4.2. - -Use the ``APP_ENV`` (and ``APP_DEBUG``) environment variables to change the -environment and the debug behavior of the commands: +the ``APP_ENV`` environment variable and with the debug mode set by ``APP_DEBUG``. +It's recommended to configure these env vars in your ``.env`` file, but you can +also override them for some specific commands as follows: .. code-block:: terminal diff --git a/console/commands_as_services.rst b/console/commands_as_services.rst index 09e02c8c9a7..c2bed37d404 100644 --- a/console/commands_as_services.rst +++ b/console/commands_as_services.rst @@ -60,13 +60,6 @@ works! You can call the ``app:sunshine`` command and start logging. work (e.g. making database queries), as that code will be run, even if you're using the console to execute a different command. -.. note:: - - In previous Symfony versions, you could make the command class extend from - :class:`Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand` to - get services via ``$this->getContainer()->get('SERVICE_ID')``. This is - deprecated in Symfony 4.2 and it won't work in future Symfony versions. - .. _console-command-service-lazy-loading: Lazy Loading diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index 0ac95a12ad6..669fa6e7282 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -53,17 +53,6 @@ In addition, some components and official bundles provide other value resolvers: the controller can be accessed by anonymous users. It requires installing the :doc:`Security component `. -:class:`Symfony\\Bundle\\SecurityBundle\\SecurityUserValueResolver` - Injects the object that represents the current logged in user if type-hinted - with ``UserInterface``. Default value can be set to ``null`` in case - the controller can be accessed by anonymous users. It requires installing - the `SecurityBundle`_. - -.. deprecated:: 4.1 - - The ``SecurityUserValueResolver`` was deprecated in Symfony 4.1 in favor of - :class:`Symfony\\Component\\Security\\Http\\Controller\\UserValueResolver`. - ``Psr7ServerRequestResolver`` Injects a `PSR-7`_ compliant version of the current request if type-hinted with ``RequestInterface``, ``MessageInterface`` or ``ServerRequestInterface``. diff --git a/controller/upload_file.rst b/controller/upload_file.rst index ab38a3025ec..982669dadce 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -182,19 +182,13 @@ There are some important things to consider in the code of the above controller: users. This also applies to the files uploaded by your visitors. The ``UploadedFile`` class provides methods to get the original file extension (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getExtension`), - the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientSize`) + the original file size (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getSize`) and the original file name (:method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientOriginalName`). However, they are considered *not safe* because a malicious user could tamper that information. That's why it's always better to generate a unique name and use the :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::guessExtension` method to let Symfony guess the right extension according to the file MIME type; -.. deprecated:: 4.1 - - The :method:`Symfony\\Component\\HttpFoundation\\File\\UploadedFile::getClientSize` - method was deprecated in Symfony 4.1 and will be removed in Symfony 5.0. - Use ``getSize()`` instead. - You can use the following code to link to the PDF brochure of a product: .. code-block:: html+twig diff --git a/form/create_custom_field_type.rst b/form/create_custom_field_type.rst index 2f0d59e3446..b6dce419fc9 100644 --- a/form/create_custom_field_type.rst +++ b/form/create_custom_field_type.rst @@ -164,12 +164,6 @@ link for details), create a ``shipping_widget`` block to handle this: {% endspaceless %} {% endblock %} -.. note:: - - Symfony 4.2 deprecated calling ``FormRenderer::searchAndRenderBlock`` for - fields that have already been rendered. That's why the previous example - includes the ``... if not child.rendered`` statement. - .. tip:: You can further customize the template used to render each children of the diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index d0e76c61b00..b9918d3f649 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -187,16 +187,6 @@ Configuration * `storage_id`_ * `use_cookies`_ -* `templating`_ - - * :ref:`cache ` - * `engines`_ - * :ref:`form ` - - * `resources`_ - - * `loaders`_ - * `test`_ * `translator`_ @@ -224,7 +214,6 @@ Configuration * `endpoint`_ * `static_method`_ - * `strict_email`_ * `translation_domain`_ * `workflows`_ @@ -1847,119 +1836,6 @@ package: If you request an asset that is *not found* in the ``manifest.json`` file, the original - *unmodified* - asset path will be returned. -templating -~~~~~~~~~~ - -.. _reference-templating-form: - -form -.... - -resources -""""""""" - -**type**: ``string[]`` **default**: ``['FrameworkBundle:Form']`` - -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. Form theming with - PHP templates will no longer be supported and you'll need to use Twig instead. - -A list of all resources for form theming in PHP. This setting is not required -if you're :ref:`using the Twig format for your themes `. - -Assume you have custom global form themes in ``templates/form_themes/``, you can -configure this like: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'form_themes' - - .. code-block:: xml - - - - - - - - - form_themes - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'form_themes', - ], - ], - ], - ]); - -.. note:: - - The default form templates from ``FrameworkBundle:Form`` will always - be included in the form resources. - -.. seealso:: - - See :ref:`forms-theming-global` for more information. - -.. _reference-templating-cache: - -cache -..... - -**type**: ``string`` - -The path to the cache directory for templates. When this is not set, caching -is disabled. - -.. note:: - - When using Twig templating, the caching is already handled by the - TwigBundle and doesn't need to be enabled for the FrameworkBundle. - -engines -....... - -**type**: ``string[]`` / ``string`` **required** - -The Templating Engine to use. This can either be a string (when only one -engine is configured) or an array of engines. - -At least one engine is required. - -loaders -....... - -**type**: ``string[]`` - -An array (or a string when configuring just one loader) of service ids for -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 ~~~~~~~~~~ @@ -2155,20 +2031,6 @@ 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 -............ - -**type**: ``Boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - The ``strict_email`` option was deprecated in Symfony 4.1. Use the new - ``email_validation_mode`` option instead. - -If this option is enabled, the `egulias/email-validator`_ library will be -used by the :doc:`/reference/constraints/Email` constraint validator. Otherwise, -the validator uses a simple regular expression to validate email addresses. - email_validation_mode ..................... diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 2081ba5ffad..35006dd4591 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -12,12 +12,17 @@ Configuration ------------- * `Charset`_ -* `Kernel Name`_ * `Project Directory`_ * `Cache Directory`_ * `Log Directory`_ * `Container Build Time`_ +In previous Symfony versions there was another configuration option to define +the "kernel name", which is only important when +:doc:`using applications with multiple kernels `. +If you need a unique ID for your kernels use the ``kernel.container_class`` +parameter or the ``Kernel::getContainerClass()`` method. + .. _configuration-kernel-charset: Charset @@ -44,29 +49,6 @@ charset:: } } -Kernel Name -~~~~~~~~~~~ - -**type**: ``string`` **default**: ``src`` (i.e. the directory name holding -the kernel class) - -.. deprecated:: 4.2 - - The ``kernel.name`` parameter and the ``Kernel::getName()`` method were - deprecated in Symfony 4.2. If you need a unique ID for your kernels use the - ``kernel.container_class`` parameter or the ``Kernel::getContainerClass()`` method. - -The name of the kernel isn't usually directly important - it's used in the -generation of cache files - and you probably will only change it when -:doc:`using applications with multiple kernels `. - -This value is exposed via the ``kernel.name`` configuration parameter and the -:method:`Symfony\\Component\\HttpKernel\\Kernel::getName` method. - -To change this setting, override the ``getName()`` method. Alternatively, move -your kernel into a different directory. For example, if you moved the kernel -into a ``foo/`` directory (instead of ``src/``), the kernel name will be ``foo``. - .. _configuration-kernel-project-directory: Project Directory diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 5fba7fc34ad..266d5cf7a66 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -145,7 +145,6 @@ encoding algorithm. Also, each algorithm defines different config options: algorithm: 'sodium' memory_cost: 16384 # Amount in KiB. (16384 = 16 MiB) time_cost: 2 # Number of iterations - threads: 4 # Number of parallel threads # PBKDF2 encoder using SHA512 hashing with default options App\Entity\User: 'sha512' @@ -183,14 +182,12 @@ encoding algorithm. Also, each algorithm defines different config options: + time_cost: number of iterations --> @@ -230,7 +227,6 @@ encoding algorithm. Also, each algorithm defines different config options: 'algorithm' => 'sodium', 'memory_cost' => 16384, // Amount in KiB. (16384 = 16 MiB) 'time_cost' => 2, // Number of iterations - 'threads' => 4, // Number of parallel threads ], // PBKDF2 encoder using SHA512 hashing with default options @@ -240,12 +236,6 @@ encoding algorithm. Also, each algorithm defines different config options: ], ]); -.. deprecated:: 4.3 - - The ``threads`` configuration option was deprecated in Symfony 4.3. No - alternative is provided because starting from Symfony 5.0 this value will be - hardcoded to ``1`` (one thread). - .. versionadded:: 4.3 The ``sodium`` algorithm was introduced in Symfony 4.3. In previous Symfony @@ -540,25 +530,6 @@ 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 -~~~~~~~~~~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``true`` - -.. deprecated:: 4.1 - - The ``logout_on_user_change`` option was deprecated in Symfony 4.1. - -If ``false`` this option makes Symfony to not trigger a logout when the user has -changed. Doing that is deprecated, so this option should set to ``true`` or -unset to avoid getting deprecation messages. - -The user is considered to have changed when the user class implements -:class:`Symfony\\Component\\Security\\Core\\User\\EquatableInterface` and the -``isEqualTo()`` method returns ``false``. Also, when any of the properties -required by the :class:`Symfony\\Component\\Security\\Core\\User\\UserInterface` -(like the username, password or salt) changes. - success_handler ~~~~~~~~~~~~~~~ diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 1e801569f28..f8c6fe08597 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -317,19 +317,12 @@ paths **type**: ``array`` **default**: ``null`` -.. deprecated:: 4.2 - - Using the ``src/Resources/views/`` directory to store templates was - deprecated in Symfony 4.2. Use instead the directory defined in the - ``default_path`` option (which is ``templates/`` by default). - This option defines the directories where Symfony will look for Twig templates in addition to the default locations. Symfony looks for the templates in the following order: #. The directories defined in this option; #. The ``Resources/views/`` directories of the bundles used in the application; -#. The ``src/Resources/views/`` directory of the application; #. The directory defined in the ``default_path`` option. The values of the ``paths`` option are defined as ``key: value`` pairs where the diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 8b68f59bea2..7621a379f72 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -6,9 +6,7 @@ cast to a string before being validated. ========== =================================================================== Applies to :ref:`property or method ` -Options - `checkHost`_ - - `checkMX`_ - - `groups`_ +Options - `groups`_ - `message`_ - `mode`_ - `normalizer`_ @@ -33,8 +31,7 @@ Basic Usage { /** * @Assert\Email( - * message = "The email '{{ value }}' is not a valid email.", - * checkMX = true + * message = "The email '{{ value }}' is not a valid email." * ) */ protected $email; @@ -48,7 +45,6 @@ Basic Usage email: - Email: message: The email "{{ value }}" is not a valid email. - checkMX: true .. code-block:: xml @@ -62,7 +58,6 @@ Basic Usage - @@ -82,7 +77,6 @@ Basic Usage { $metadata->addPropertyConstraint('email', new Assert\Email([ 'message' => 'The email "{{ value }}" is not a valid email.', - 'checkMX' => true, ])); } } @@ -92,36 +86,6 @@ Basic Usage Options ------- -checkHost -~~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX *or* the A *or* the AAAA record of the host -of the given email. - -checkMX -~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -If true, then the :phpfunction:`checkdnsrr` PHP function will be used to -check the validity of the MX record of the host of the given email. - -.. caution:: - - This option is not reliable because it depends on the network conditions - and some valid servers refuse to respond to those requests. - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index 8887124a153..04edab5a197 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -8,10 +8,13 @@ the two letter `ISO 639-1`_ *language* code (e.g. ``fr``), or the language code followed by an underscore (``_``) and the `ISO 3166-1 alpha-2`_ *country* code (e.g. ``fr_FR`` for French/France). +The given locale values are *canonicalized* before validating them to avoid +issues with wrong uppercase/lowercase values and to remove unneeded elements +(e.g. ``FR-fr.utf8`` will be validated as ``fr_FR``). + ========== =================================================================== Applies to :ref:`property or method ` -Options - `canonicalize`_ - - `groups`_ +Options - `groups`_ - `message`_ - `payload`_ Class :class:`Symfony\\Component\\Validator\\Constraints\\Locale` @@ -89,19 +92,6 @@ Basic Usage Options ------- -canonicalize -~~~~~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - Using this option with value ``false`` was deprecated in Symfony 4.1 and it - will throw an exception in Symfony 5.0. Use ``true`` instead. - -If ``true``, the :phpmethod:`Locale::canonicalize` method will be applied before checking -the validity of the given locale (e.g. ``FR-fr.utf8`` is transformed into ``fr_FR``). - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 4c9885d0147..fdc58880797 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -5,9 +5,7 @@ Validates that a value is a valid URL string. ========== =================================================================== Applies to :ref:`property or method ` -Options - `checkDNS`_ - - `dnsMessage`_ - - `groups`_ +Options - `groups`_ - `message`_ - `normalizer`_ - `payload`_ @@ -76,170 +74,15 @@ Basic Usage } } +This constraint doesn't check that the host of the given URL really exists, +because the information of the DNS records is not reliable. Use the +:phpfunction:`checkdnsrr` PHP function if you still want to check that. + .. include:: /reference/constraints/_empty-values-are-valid.rst.inc Options ------- -checkDNS -~~~~~~~~ - -**type**: ``boolean`` **default**: ``false`` - -.. deprecated:: 4.1 - - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. - -By default, this constraint just validates the syntax of the given URL. If you -also need to check whether the associated host exists, set the ``checkDNS`` -option to the value of any of the ``CHECK_DNS_TYPE_*`` constants in the -:class:`Symfony\\Component\\Validator\\Constraints\\Url` class: - -.. configuration-block:: - - .. code-block:: php-annotations - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - - class Author - { - /** - * @Assert\Url( - * checkDNS = "ANY" - * ) - */ - protected $bioUrl; - } - - .. code-block:: yaml - - # config/validator/validation.yaml - App\Entity\Author: - properties: - bioUrl: - - Url: { checkDNS: 'ANY' } - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - use Symfony\Component\Validator\Mapping\ClassMetadata; - - class Author - { - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'checkDNS' => Assert\Url::CHECK_DNS_TYPE_ANY, - ])); - } - } - -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 -~~~~~~~~~~ - -**type**: ``string`` **default**: ``The host could not be resolved.`` - -.. deprecated:: 4.1 - - This option was deprecated in Symfony 4.1 and will be removed in Symfony 5.0, - because checking the DNS records is not reliable enough to validate the - existence of the host. Use the :phpfunction:`checkdnsrr` PHP function if you - still want to use this kind of validation. - -This message is shown when the ``checkDNS`` option is set to ``true`` and the -DNS check failed. - -.. configuration-block:: - - .. code-block:: php-annotations - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - - class Author - { - /** - * @Assert\Url( - * dnsMessage = "The host '{{ value }}' could not be resolved." - * ) - */ - protected $bioUrl; - } - - .. code-block:: yaml - - # config/validator/validation.yaml - App\Entity\Author: - properties: - bioUrl: - - Url: { dnsMessage: 'The host "{{ value }}" could not be resolved.' } - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // src/Entity/Author.php - namespace App\Entity; - - use Symfony\Component\Validator\Constraints as Assert; - use Symfony\Component\Validator\Mapping\ClassMetadata; - - class Author - { - public static function loadValidatorMetadata(ClassMetadata $metadata) - { - $metadata->addPropertyConstraint('bioUrl', new Assert\Url([ - 'dnsMessage' => 'The host "{{ value }}" could not be resolved.', - ])); - } - } - .. include:: /reference/constraints/_groups-option.rst.inc message diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index eec54e6d680..f894070aa18 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -36,7 +36,6 @@ Tag Name Usage `serializer.encoder`_ Register a new encoder in the ``serializer`` service `serializer.normalizer`_ Register a new normalizer in the ``serializer`` service `swiftmailer.default.plugin`_ Register a custom SwiftMailer Plugin -`templating.helper`_ Make your service available in PHP templates `translation.loader`_ Register a custom service that loads translations `translation.extractor`_ Register a custom service that extracts translation messages from a file `translation.dumper`_ Register a custom service that dumps translation messages @@ -789,53 +788,6 @@ 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 ------------------ - -**Purpose**: Make your service available in PHP templates - -.. deprecated:: 4.3 - - The ``templating.helper`` tag is deprecated since version 4.3 and will be - removed in 5.0; use Twig instead. - -To enable a custom template helper, add it as a regular service in one -of your configuration, tag it with ``templating.helper`` and define an -``alias`` attribute (the helper will be accessible via this alias in the -templates): - -.. configuration-block:: - - .. code-block:: yaml - - services: - App\Templating\AppHelper: - tags: - - { name: templating.helper, alias: alias_name } - - .. code-block:: xml - - - - - - - - - - - - .. code-block:: php - - use App\Templating\AppHelper; - - $container->register(AppHelper::class) - ->addTag('templating.helper', ['alias' => 'alias_name']) - ; - .. _dic-tags-translation-loader: translation.loader diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index 6e2be4140e3..30f9cb3d2ec 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -171,11 +171,6 @@ values for the year, month and day fields:: .. include:: /reference/forms/types/options/date_format.rst.inc -.. deprecated:: 4.3 - - Using the ``format`` option when the ``html5`` option is enabled is deprecated - since Symfony 4.3. - .. include:: /reference/forms/types/options/html5.rst.inc .. _form-reference-date-input: diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index 99fb9aa1722..18290532afa 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -74,11 +74,6 @@ Defines the ``format`` option that will be passed down to the date field. See the :ref:`DateType's format option ` for more details. -.. deprecated:: 4.3 - - Using the ``date_format`` option when the form is rendered as an HTML 5 - datetime input is deprecated since Symfony 4.3. - date_label ~~~~~~~~~~ @@ -98,11 +93,6 @@ date_widget .. include:: /reference/forms/types/options/date_widget_description.rst.inc -.. deprecated:: 4.3 - - Using the ``date_widget`` option when the ``widget`` option is set to - ``single_text`` is deprecated since Symfony 4.3. - .. include:: /reference/forms/types/options/days.rst.inc placeholder @@ -144,11 +134,6 @@ used by the HTML5 ``datetime-local`` field. Keeping the default value will cause the field to be rendered as an ``input`` field with ``type="datetime-local"``. For more information on valid formats, see `Date/Time Format Syntax`_. -.. deprecated:: 4.3 - - Using the ``format`` option when the ``html5`` option is enabled is deprecated - since Symfony 4.3. - .. include:: /reference/forms/types/options/hours.rst.inc .. include:: /reference/forms/types/options/html5.rst.inc @@ -208,11 +193,6 @@ time_widget Defines the ``widget`` option for the :doc:`TimeType `. -.. deprecated:: 4.3 - - Using the ``time_widget`` option when the ``widget`` option is set to - ``single_text`` is deprecated since Symfony 4.3. - .. include:: /reference/forms/types/options/view_timezone.rst.inc widget diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 0ce32ddbadc..18ef5a0d0da 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -20,7 +20,7 @@ integers. By default, all non-integer values (e.g. 6.78) will round down | | - `rounding_mode`_ | +-------------+-----------------------------------------------------------------------+ | Overridden | - `compound`_ | -| options | - `scale`_ | +| options | | +-------------+-----------------------------------------------------------------------+ | Inherited | - `data`_ | | options | - `disabled`_ | @@ -84,21 +84,6 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc -scale -~~~~~ - -**type**: ``integer`` **default**: ``0`` - -.. deprecated:: 4.2 - - The ``scale`` option is deprecated since Symfony 4.2 and will be removed - in 5.0. - -This specifies how many decimals will be allowed until the field rounds the -submitted value (via ``rounding_mode``). This option inherits from -:doc:`number ` type and is overriden to ``0`` for -``IntegerType``. - Inherited Options ----------------- diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 96e61de0d34..0e8694db324 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -18,7 +18,7 @@ manually, but then you should just use the ``ChoiceType`` directly. | Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | +-------------+------------------------------------------------------------------------+ | Options | - `input`_ | -| | - `regions`_ | +| | | +-------------+------------------------------------------------------------------------+ | Overridden | - `choices`_ | | options | | @@ -73,17 +73,6 @@ on your underlying object. Valid values are: The ``intltimezone`` input type was introduced in Symfony 4.3. -regions -~~~~~~~ - -**type**: ``int`` **default**: ``\DateTimeZone::ALL`` - -.. deprecated:: 4.2 - - This option was deprecated in Symfony 4.2. - -The available regions in the timezone choice list. For example: ``DateTimeZone::AMERICA | DateTimeZone::EUROPE`` - Overridden Options ------------------ diff --git a/templating/PHP.rst b/templating/PHP.rst index 1ea3196c4cb..15d4354bf07 100644 --- a/templating/PHP.rst +++ b/templating/PHP.rst @@ -4,575 +4,7 @@ How to Use PHP instead of Twig for Templates ============================================ -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. PHP templates will - no longer be supported and you'll need to use Twig instead. - -Symfony defaults to Twig for its template engine, but you can still use -plain PHP code if you want. Both templating engines are supported equally in -Symfony. Symfony adds some nice features on top of PHP to make writing -templates with PHP more powerful. - -.. tip:: - - If you choose *not* use Twig and you disable it, you'll need to implement - your own exception handler via the ``kernel.exception`` event. - -Rendering PHP Templates ------------------------ - -.. deprecated:: 4.3 - - The integration of the Templating component in FrameworkBundle has been - deprecated since version 4.3 and will be removed in 5.0. PHP templates will - no longer be supported and you'll need to use Twig instead. - -If you want to use the PHP templating engine, first install the templating component: - -.. code-block:: terminal - - $ composer require symfony/templating - -Next, enable the php engine: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - # ... - templating: - engines: ['twig', 'php'] - - .. code-block:: xml - - - - - - - - - - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - // ... - 'templating' => [ - 'engines' => ['twig', 'php'], - ], - ]); - -You can now render a PHP template instead of a Twig one by using the ``.php`` -extension in the template name instead of ``.twig``. The controller below -renders the ``index.html.php`` template:: - - // src/Controller/HelloController.php - - // ... - public function index($name) - { - // template is stored in src/Resources/views/hello/index.html.php - return $this->render('hello/index.html.php', [ - 'name' => $name - ]); - } - .. caution:: - Enabling the ``php`` and ``twig`` template engines simultaneously is - allowed, but it will produce an undesirable side effect in your application: - the ``@`` notation for Twig namespaces will no longer be supported for the - ``render()`` method:: - - public function index() - { - // ... - - // namespaced templates will no longer work in controllers - $this->render('@SomeNamespace/hello/index.html.twig'); - - // you must use the traditional template notation - $this->render('hello/index.html.twig'); - } - - .. code-block:: twig - - {# inside a Twig template, namespaced templates work as expected #} - {{ include('@SomeNamespace/hello/index.html.twig') }} - - {# traditional template notation will also work #} - {{ include('hello/index.html.twig') }} - -.. index:: - single: Templating; Layout - single: Layout - -Decorating Templates --------------------- - -More often than not, templates in a project share common elements, like the -well-known header and footer. In Symfony, this problem is thought about -differently: a template can be decorated by another one. - -The ``index.html.php`` template is decorated by ``layout.html.php``, thanks to -the ``extend()`` call: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - Hello ! - -Now, have a look at the ``layout.html.php`` file: - -.. code-block:: html+php - - - extend('base.html.php') ?> - -

Hello Application

- - output('_content') ?> - -The layout is itself decorated by another one (``base.html.php``). Symfony -supports multiple decoration levels: a layout can itself be decorated by -another one: - -.. code-block:: html+php - - - - - - - <?php $view['slots']->output('title', 'Hello Application') ?> - - - output('_content') ?> - - - -For both layouts, the ``$view['slots']->output('_content')`` expression is -replaced by the content of the child template, ``index.html.php`` and -``layout.html.php`` respectively (more on slots in the next section). - -As you can see, Symfony provides methods on a mysterious ``$view`` object. In -a template, the ``$view`` variable is always available and refers to a special -object that provides a bunch of methods that makes the template engine tick. - -.. index:: - single: Templating; Slot - single: Slot - -Working with Slots ------------------- - -A slot is a snippet of code, defined in a template, and reusable in any layout -decorating the template. In the ``index.html.php`` template, define a -``title`` slot: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - set('title', 'Hello World Application') ?> - - Hello ! - -The base layout already has the code to output the title in the header: - -.. code-block:: html+php - - - - - <?php $view['slots']->output('title', 'Hello Application') ?> - - -The ``output()`` method inserts the content of a slot and optionally takes a -default value if the slot is not defined. And ``_content`` is just a special -slot that contains the rendered child template. - -For large slots, there is also an extended syntax: - -.. code-block:: html+php - - start('title') ?> - Some large amount of HTML - stop() ?> - -.. index:: - single: Templating; Include - -Including other Templates -------------------------- - -The best way to share a snippet of template code is to define a template that -can then be included into other templates. - -Create a ``hello.html.php`` template: - -.. code-block:: html+php - - - Hello ! - -And change the ``index.html.php`` template to include it: - -.. code-block:: html+php - - - extend('layout.html.php') ?> - - render('hello/hello.html.php', ['name' => $name]) ?> - -The ``render()`` method evaluates and returns the content of another template -(this is the exact same method as the one used in the controller). - -.. index:: - single: Templating; Embedding pages - -Embedding other Controllers ---------------------------- - -And what if you want to embed the result of another controller in a template? -That's very useful when working with Ajax, or when the embedded template needs -some variable not available in the main template. - -If you create a ``fancy`` action, and want to include it into the -``index.html.php`` template, use the following code: - -.. code-block:: html+php - - - render( - new \Symfony\Component\HttpKernel\Controller\ControllerReference( - 'App\Controller\HelloController::fancy', - [ - 'name' => $name, - 'color' => 'green', - ] - ) - ) ?> - -But where is the ``$view['actions']`` array element defined? Like -``$view['slots']``, it's called a template helper, and the next section tells -you more about those. - -.. index:: - single: Templating; Helpers - -Using Template Helpers ----------------------- - -The Symfony templating system can be extended via helpers. Helpers are -PHP objects that provide features useful in a template context. ``actions`` and -``slots`` are two of the built-in Symfony helpers. - -Creating Links between Pages -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Speaking of web applications, creating links between pages is a must. Instead -of hardcoding URLs in templates, the ``router`` helper knows how to generate -URLs based on the routing configuration. That way, all your URLs can be -updated by changing the configuration: - -.. code-block:: html+php - -
- Greet Thomas! - - -The ``path()`` method takes the route name and an array of parameters as -arguments. The route name is the main key under which routes are referenced -and the parameters are the values of the placeholders defined in the route -pattern: - -.. code-block:: yaml - - # config/routes.yaml - hello: - path: /hello/{name} - controller: App\Controller\HelloController::index - -Using Assets: Images, JavaScripts and Stylesheets -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -What would the Internet be without images, JavaScripts, and stylesheets? -Symfony provides the ``assets`` tag to deal with them: - -.. code-block:: html+php - - - - - -The ``assets`` helper's main purpose is to make your application more -portable. Thanks to this helper, you can move the application root directory -anywhere under your web root directory without changing anything in your -template's code. - -Profiling Templates -~~~~~~~~~~~~~~~~~~~ - -By using the ``stopwatch`` helper, you are able to time parts of your template -and display it on the timeline of the WebProfilerBundle:: - - start('foo') ?> - ... things that get timed - stop('foo') ?> - -.. tip:: - - If you use the same name more than once in your template, the times are - grouped on the same line in the timeline. - -Output Escaping ---------------- - -When using PHP templates, escape variables whenever they are displayed to the -user:: - - escape($var) ?> - -By default, the ``escape()`` method assumes that the variable is outputted -within an HTML context. The second argument lets you change the context. For -instance, to output something in a JavaScript script, use the ``js`` context:: - - escape($var, 'js') ?> - -Form Theming in PHP -------------------- - -When using PHP as a templating engine, the only method to customize a fragment -is to create a new template file - this is similar to the second method used by -Twig. - -The template file must be named after the fragment. You must create a ``integer_widget.html.php`` -file in order to customize the ``integer_widget`` fragment. - -.. code-block:: html+php - - -
- block( - $form, - 'form_widget_simple', - ['type' => isset($type) ? $type : "number"] - ) ?> -
- -Now that you've created the customized form template, you need to tell Symfony -to use it. Inside the template where you're actually rendering your form, -tell Symfony to use the theme via the ``setTheme()`` helper method:: - - setTheme($form, [':form']) ?> - - widget($form['age']) ?> - -When the ``form.age`` widget is rendered, Symfony will use the customized -``integer_widget.html.php`` template and the ``input`` tag will be wrapped in -the ``div`` element. - -If you want to apply a theme to a specific child form, pass it to the ``setTheme()`` -method:: - - setTheme($form['child'], ':form') ?> - -.. note:: - - The ``:form`` syntax is based on the functional names for templates: - ``Bundle:Directory``. As the form directory lives in the - ``templates/`` directory, the ``Bundle`` part is empty, resulting - in ``:form``. - -Making Application-wide Customizations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you'd like a certain form customization to be global to your application, -you can accomplish this by making the form customizations in an external -template and then importing it inside your application configuration. - -By using the following configuration, any customized form fragments inside the -``templates/form`` folder will be used globally when a -form is rendered. - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'App:Form' - # ... - - .. code-block:: xml - - - - - - - - - App:Form - - - - - - - .. code-block:: php - - // config/packages/framework.php - // PHP - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'App:Form', - ], - ], - ], - - // ... - ]); - -By default, the PHP engine uses a *div* layout when rendering forms. Some people, -however, may prefer to render forms in a *table* layout. Use the ``FrameworkBundle:FormTable`` -resource to use such a layout: - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/framework.yaml - framework: - templating: - form: - resources: - - 'FrameworkBundle:FormTable' - - .. code-block:: xml - - - - - - - - - FrameworkBundle:FormTable - - - - - - - .. code-block:: php - - // config/packages/framework.php - $container->loadFromExtension('framework', [ - 'templating' => [ - 'form' => [ - 'resources' => [ - 'FrameworkBundle:FormTable', - ], - ], - ], - - // ... - ]); - -If you only want to make the change in one template, add the following line to -your template file rather than adding the template as a resource: - -.. code-block:: html+php - - setTheme($form, ['FrameworkBundle:FormTable']) ?> - -Note that the ``$form`` variable in the above code is the form view variable -that you passed to your template. - -Adding a "Required" Asterisk to Field Labels -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -If you want to denote all of your required fields with a required asterisk -(``*``), you can do this by customizing the ``form_label`` fragment. - -When using PHP as a templating engine you have to copy the content from the -original template: - -.. code-block:: html+php - - - - - - - humanize($name); } ?> - - - - - * - - -Adding "help" Messages -~~~~~~~~~~~~~~~~~~~~~~ - -You can also customize your form widgets to have an optional "help" message. - -When using PHP as a templating engine you have to copy the content from the -original template: - -.. code-block:: html+php - - - - - value="escape($value) ?>" - block($form, 'widget_attributes') ?> - /> - - - - escape($help) ?> - - -.. _`@Template`: https://symfony.com/doc/current/bundles/SensioFrameworkExtraBundle/annotations/view + Starting from Symfony 5.0, PHP templates are no longer supported. Use + :doc:`Twig ` instead to create your templates. diff --git a/translation.rst b/translation.rst index 3b1692c3755..c33ae20d8ca 100644 --- a/translation.rst +++ b/translation.rst @@ -386,19 +386,10 @@ Translation Resource/File Names and Locations Symfony looks for message files (i.e. translations) in the following default locations: * the ``translations/`` directory (at the root of the project); - -* the ``src/Resources//translations/`` directory; - * the ``Resources/translations/`` directory inside of any bundle. -.. deprecated:: 4.2 - - Using the ``src/Resources//translations/`` directory to store - translations was deprecated in Symfony 4.2. Use instead the directory - defined in the ``default_path`` option (which is ``translations/`` by default). - The locations are listed here with the highest priority first. That is, you can -override the translation messages of a bundle in any of the top two directories. +override the translation messages of a bundle in the first directory. The override mechanism works at a key level: only the overridden keys need to be listed in a higher priority message file. When a key is not found From f990c8188b523233063c96a8040ea39de1854a5c Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 6 Jun 2019 09:54:01 +0200 Subject: [PATCH 005/752] Remove old versionadded directives --- components/http_client.rst | 4 ---- components/phpunit_bridge.rst | 4 ---- doctrine.rst | 4 ---- mailer.rst | 5 ----- translation.rst | 6 ------ 5 files changed, 23 deletions(-) diff --git a/components/http_client.rst b/components/http_client.rst index f2312c38cb2..040512fafdf 100644 --- a/components/http_client.rst +++ b/components/http_client.rst @@ -389,10 +389,6 @@ Responses can be canceled at any moment before they are completed using the $response->cancel(); } -.. versionadded:: 4.4 - - The ``cancel()`` method was introduced in Symfony 4.4. - Dealing with Network Timeouts ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index a27914a300a..77c5b4fd165 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -295,10 +295,6 @@ class autoloading time. This can be disabled with the ``debug-class-loader`` opt -.. versionadded:: 4.2 - - The ``DebugClassLoader`` integration was introduced in Symfony 4.2. - Write Assertions about Deprecations ----------------------------------- diff --git a/doctrine.rst b/doctrine.rst index 01b7682d7fe..c2368f39a1a 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -484,10 +484,6 @@ doesn't replace the validation configuration entirely. You still need to add some :doc:`validation constraints ` to ensure that data provided by the user is correct. -.. versionadded:: 4.3 - - The automatic validation has been added in Symfony 4.3. - Fetching Objects from the Database ---------------------------------- diff --git a/mailer.rst b/mailer.rst index 3b83c5454ec..857b813aa2d 100644 --- a/mailer.rst +++ b/mailer.rst @@ -1,11 +1,6 @@ Sending Emails with Mailer ========================== -.. versionadded:: 4.3 - - The Mailer component was added in Symfony 4.3 and is currently experimental. - The previous solution - Swift Mailer - is still valid: :doc:`Swift Mailer`. - Installation ------------ diff --git a/translation.rst b/translation.rst index d3a33ffc5c9..7efa0320b86 100644 --- a/translation.rst +++ b/translation.rst @@ -216,12 +216,6 @@ To manage these situations, Symfony follows the `ICU MessageFormat`_ syntax by using PHP's :phpclass:`MessageFormatter` class. Read more about this in :doc:`/translation/message_format`. -.. versionadded:: 4.2 - - Support for ICU MessageFormat was introduced in Symfony 4.2. Prior to this, - pluralization was managed by the - :method:`Symfony\\Component\\Translation\\Translator::transChoice` method. - Translations in Templates ------------------------- From ae30492e78826033642ab0c6d207ed4682b4ccc3 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 11 Jun 2019 09:41:19 +0200 Subject: [PATCH 006/752] Remove old deprecated directive --- service_container/tags.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/service_container/tags.rst b/service_container/tags.rst index de83480727d..bca6c8a902b 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -456,10 +456,6 @@ compiler pass just for that. In the following example, all services tagged with ``app.handler`` are passed as first constructor argument to the ``App\HandlerCollection`` service: -.. deprecated:: 4.4 - - ``tagged`` has been deprecated since version 4.4 and will be removed in 5.0. Use ``tagged_iterator`` instead. - .. configuration-block:: .. code-block:: yaml From b270e2d12102ae4be90b438f8fb37e57827aabc3 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 11 Jun 2019 10:05:58 +0200 Subject: [PATCH 007/752] Remove old versionadded directives --- reference/constraints/_comparison-propertypath-option.rst.inc | 4 ---- translation/message_format.rst | 4 ---- 2 files changed, 8 deletions(-) diff --git a/reference/constraints/_comparison-propertypath-option.rst.inc b/reference/constraints/_comparison-propertypath-option.rst.inc index 66932a0e983..9512d59310a 100644 --- a/reference/constraints/_comparison-propertypath-option.rst.inc +++ b/reference/constraints/_comparison-propertypath-option.rst.inc @@ -15,7 +15,3 @@ with regard to the ``$startDate`` property of the same object, use ``{{ compared_value_path }}`` placeholder. Although it's not intended to include it in the error messages displayed to end users, it's useful when using APIs for doing any mapping logic on client-side. - - .. versionadded:: 4.4 - - The ``{{ compared_value_path }}`` placeholder was introduced in Symfony 4.4. diff --git a/translation/message_format.rst b/translation/message_format.rst index a0761ec75f6..b4f1f2769cc 100644 --- a/translation/message_format.rst +++ b/translation/message_format.rst @@ -4,10 +4,6 @@ How to Translate Messages using the ICU MessageFormat ===================================================== -.. versionadded:: 4.2 - - Support for ICU MessageFormat was introduced in Symfony 4.2. - Messages (i.e. strings) in applications are almost never completely static. They contain variables or other complex logic like pluralization. In order to handle this, the Translator component supports the `ICU MessageFormat`_ syntax. From 8c33fce7e9453c7b51871ca404bbad1e83daaebe Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 17 Jun 2019 08:35:03 +0200 Subject: [PATCH 008/752] Remove old versionadded directives --- reference/constraints/Type.rst | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 319387416ec..81eed39be6c 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -126,11 +126,6 @@ function) and ``accessCode`` contains either only letters or only digits (using } } -.. versionadded:: 4.4 - - The feature to define multiple types in the ``type`` option was introduced - in Symfony 4.4. - Options ------- @@ -161,11 +156,6 @@ type **type**: ``string`` or ``array`` [:ref:`default option `] -.. versionadded:: 4.4 - - The feature to define multiple types in the ``type`` option was introduced - in Symfony 4.4. - This required option defines the type or collection of types allowed for the given value. Each type is defined as the fully qualified class name or one of the PHP datatypes as determined by PHP's ``is_*()`` functions. From 25b70a3f54ef6b7c1970e1d82e7392b3e21c7848 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 18 Jun 2019 11:07:43 +0200 Subject: [PATCH 009/752] Removed old deprecated directives. --- components/serializer.rst | 17 ------ configuration.rst | 5 -- .../front_controllers_and_kernel.rst | 5 -- reference/twig_reference.rst | 52 ------------------- translation/templates.rst | 40 ++------------ 5 files changed, 3 insertions(+), 116 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index b000fd6ede9..b5604d8996c 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -660,11 +660,6 @@ When serializing, you can set a callback to format a specific object property:: $serializer->serialize($person, 'json'); // Output: {"name":"cordoval", "age": 34, "createdAt": "2014-03-22T09:43:12-0500"} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCallbacks` is deprecated since - Symfony 4.2, use the "callbacks" key of the context instead. - .. _component-serializer-normalizers: Normalizers @@ -951,12 +946,6 @@ having unique identifiers:: var_dump($serializer->serialize($org, 'json')); // {"name":"Les-Tilleuls.coop","members":[{"name":"K\u00e9vin", organization: "Les-Tilleuls.coop"}]} -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setCircularReferenceHandler` - method is deprecated since Symfony 4.2. Use the ``circular_reference_handler`` - key of the context instead. - Handling Serialization Depth ---------------------------- @@ -1108,12 +1097,6 @@ having unique identifiers:: ]; */ -.. deprecated:: 4.2 - - The :method:`Symfony\\Component\\Serializer\\Normalizer\\AbstractNormalizer::setMaxDepthHandler` - method is deprecated since Symfony 4.2. Use the ``max_depth_handler`` - key of the context instead. - Handling Arrays --------------- diff --git a/configuration.rst b/configuration.rst index 39369c0cab2..2bda9d4e394 100644 --- a/configuration.rst +++ b/configuration.rst @@ -325,11 +325,6 @@ can override it for commands by setting the ``APP_ENV`` value before running the # Ignore the .env file and run this command in production $ APP_ENV=prod php bin/console command_name -.. deprecated:: 4.2 - - In previous Symfony versions you could configure the environment with the - ``--env`` command option, which was deprecated in Symfony 4.2. - Creating a New Environment ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/configuration/front_controllers_and_kernel.rst b/configuration/front_controllers_and_kernel.rst index 865a4077157..d986d7471b7 100644 --- a/configuration/front_controllers_and_kernel.rst +++ b/configuration/front_controllers_and_kernel.rst @@ -156,11 +156,6 @@ before running them: # Ignore the .env file and enable the debug mode for this command $ APP_DEBUG=1 php bin/console command_name -.. deprecated:: 4.2 - - In previous Symfony versions you could configure the debug mode with the - ``--no-debug`` command option, which was deprecated in Symfony 4.2. - Internally, the value of the debug mode becomes the ``kernel.debug`` parameter used inside the :doc:`service container `. If you look inside the application configuration file, you'll see the diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 083583727e7..6642d775911 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -356,33 +356,6 @@ trans Translates the text into the current language. More information in :ref:`Translation Filters `. -transchoice -~~~~~~~~~~~ - -.. deprecated:: 4.2 - - The ``transchoice`` filter is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` filter instead. - -.. code-block:: twig - - {{ message|transchoice(count, arguments = [], domain = null, locale = null) }} - -``message`` - **type**: ``string`` -``count`` - **type**: ``integer`` -``arguments`` *(optional)* - **type**: ``array`` **default**: ``[]`` -``domain`` *(optional)* - **type**: ``string`` **default**: ``null`` -``locale`` *(optional)* - **type**: ``string`` **default**: ``null`` - -Translates the text with pluralization support. More information in -:ref:`Translation Filters `. - yaml_encode ~~~~~~~~~~~ @@ -591,31 +564,6 @@ trans Renders the translation of the content. More information in :ref:`translation-tags`. -transchoice -~~~~~~~~~~~ - -.. deprecated:: 4.2 - - The ``transchoice`` tag is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` tag instead. - -.. code-block:: twig - - {% transchoice count with vars from domain into locale %}{% endtranschoice %} - -``count`` - **type**: ``integer`` -``vars`` *(optional)* - **type**: ``array`` **default**: ``[]`` -``domain`` *(optional)* - **type**: ``string`` **default**: ``null`` -``locale`` *(optional)* - **type**: ``string`` **default**: ``null`` - -Renders the translation of the content with pluralization support, more -information in :ref:`translation-tags`. - trans_default_domain ~~~~~~~~~~~~~~~~~~~~ diff --git a/translation/templates.rst b/translation/templates.rst index 903f1934d92..b820bfb0fba 100644 --- a/translation/templates.rst +++ b/translation/templates.rst @@ -9,27 +9,13 @@ Twig Templates Using Twig Tags ~~~~~~~~~~~~~~~ -Symfony provides specialized Twig tags (``trans`` and ``transchoice``) to -help with message translation of *static blocks of text*: +Symfony provides a specialized Twig tag ``trans`` to help with message +translation of *static blocks of text*: .. code-block:: twig {% trans %}Hello %name%{% endtrans %} - {% transchoice count %} - {0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples - {% endtranschoice %} - -The ``transchoice`` tag automatically gets the ``%count%`` variable from -the current context and passes it to the translator. This mechanism only -works when you use a placeholder following the ``%var%`` pattern. - -.. deprecated:: 4.2 - - The ``transchoice`` tag is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` tag instead. - .. caution:: The ``%var%`` notation of placeholders is required when translating in @@ -48,34 +34,19 @@ You can also specify the message domain and pass some additional variables: {% trans with {'%name%': 'Fabien'} from 'app' into 'fr' %}Hello %name%{% endtrans %} - {% transchoice count with {'%name%': 'Fabien'} from 'app' %} - {0} %name%, there are no apples|{1} %name%, there is one apple|]1,Inf[ %name%, there are %count% apples - {% endtranschoice %} - .. _translation-filters: Using Twig Filters ~~~~~~~~~~~~~~~~~~ -The ``trans`` and ``transchoice`` filters can be used to translate *variable -texts* and complex expressions: +The ``trans`` filter can be used to translate *variable texts* and complex expressions: .. code-block:: twig {{ message|trans }} - {{ message|transchoice(5) }} - {{ message|trans({'%name%': 'Fabien'}, 'app') }} - {{ message|transchoice(5, {'%name%': 'Fabien'}, 'app') }} - -.. deprecated:: 4.2 - - The ``transchoice`` filter is deprecated since Symfony 4.2 and will be - removed in 5.0. Use the :doc:`ICU MessageFormat ` with - the ``trans`` filter instead. - .. tip:: Using the translation tags or filters have the same effect, but with @@ -116,8 +87,3 @@ The translator service is accessible in PHP templates through the trans('Symfony is great') ?> - transChoice( - '{0} There are no apples|{1} There is one apple|]1,Inf[ There are %count% apples', - 10, - ['%count%' => 10] - ) ?> From 426432a287d4ed5d683306a51d706982c1350253 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 3 Jul 2019 10:27:00 +0200 Subject: [PATCH 010/752] Removed versionadded directive --- mailer.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mailer.rst b/mailer.rst index 8e7563c8808..f40c1a44fc2 100644 --- a/mailer.rst +++ b/mailer.rst @@ -539,10 +539,6 @@ directly from GitHub and save it in ``assets/css``. Signing and Encrypting Messages ------------------------------- -.. versionadded:: 4.4 - - The option to sign and/or encrypt messages was introduced in Symfony 4.4. - It's possible to sign and/or encrypt email messages applying the `S/MIME`_ standard to increase their integrity/security. Both options can be combined (to encrypt a signed message and to sign an encrypted message) and they require to From bb315b24dd966e73775f21b1e53a3c0006f347e1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 3 Jul 2019 11:16:43 +0200 Subject: [PATCH 011/752] Removed a versionadded directive --- configuration.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configuration.rst b/configuration.rst index b2d9decda7d..4b54274b955 100644 --- a/configuration.rst +++ b/configuration.rst @@ -467,10 +467,6 @@ are defined and have the expected values: # run this command to show all the details for a specific env var: $ php bin/console debug:container --env-var=FOO -.. versionadded:: 4.3 - - The option to debug environment variables was introduced in Symfony 4.3. - .. _configuration-env-var-in-dev: .. _config-dot-env: From f6e79a3bd9d3a09bf2ea743e208ac074a446c193 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 4 Jul 2019 16:52:04 +0200 Subject: [PATCH 012/752] Reword --- reference/constraints/Length.rst | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index fb56d8070d2..b1529efb1e0 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -113,16 +113,11 @@ Options allowEmptyString ~~~~~~~~~~~~~~~~ -**type**: ``boolean`` **default**: ``true`` +**type**: ``boolean`` **default**: ``false`` -.. versionadded:: 4.4 - - The ``allowEmptyString`` option was introduced in Symfony 4.4. - -When using the ``min`` option, it's mandatory to also define this option. If -set to ``true``, empty strings are considered valid (which is the same behavior -as previous Symfony versions). Set it to ``false`` to consider empty strings not -valid. +If set to ``true``, empty strings are considered valid (which is the same +behavior as previous Symfony versions). The default ``false`` value considers +empty strings not valid. charset ~~~~~~~ From 1c21c45c5ace28e4fe38f06c7585954f0bd6bda4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 10 Jul 2019 12:33:16 +0200 Subject: [PATCH 013/752] Removed the deprecatedWebServerBundle --- _build/redirection_map | 1 + setup/built_in_web_server.rst | 127 ---------------------------------- 2 files changed, 1 insertion(+), 127 deletions(-) delete mode 100644 setup/built_in_web_server.rst diff --git a/_build/redirection_map b/_build/redirection_map index 7c4a5188b46..ef7effc1705 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -428,3 +428,4 @@ /profiler/storage /profiler /setup/composer /setup /security/security_checker /setup +/setup/built_in_web_server /setup/symfony_server diff --git a/setup/built_in_web_server.rst b/setup/built_in_web_server.rst deleted file mode 100644 index bb0f563f0ee..00000000000 --- a/setup/built_in_web_server.rst +++ /dev/null @@ -1,127 +0,0 @@ -.. index:: - single: Web Server; Built-in Web Server - -How to Use PHP's built-in Web Server -==================================== - -.. deprecated:: 4.4 - - This article explains how to use the WebServerBundle to run Symfony - applications on your local computer. However, that bundle is deprecated - since Symfony 4.4 and will be removed in Symfony 5.0. - - Instead of using WebServerBundle, the preferred way to run your Symfony - applications locally is to use the :doc:`Symfony Local Web Server `. - -The PHP CLI SAPI comes with a `built-in web server`_. It can be used to run your -PHP applications locally during development, for testing or for application -demonstrations. This way, you don't have to bother configuring a full-featured -web server such as :doc:`Apache or Nginx `. - -.. caution:: - - The built-in web server is meant to be run in a controlled environment. - It is not designed to be used on public networks. - -Symfony provides a web server built on top of this PHP server to simplify your -local setup. This server is distributed as a bundle, so you must first install -and enable the server bundle. - -Installing the Web Server Bundle --------------------------------- - -Move into your project directory and run this command: - -.. code-block:: terminal - - $ cd your-project/ - $ composer require --dev symfony/web-server-bundle - -Starting the Web Server ------------------------ - -To run a Symfony application using PHP's built-in web server, execute the -``server:start`` command: - -.. code-block:: terminal - - $ php bin/console server:start - -This starts the web server at ``localhost:8000`` in the background that serves -your Symfony application. - -By default, the web server listens on port 8000 on the loopback device. You -can change the socket passing an IP address and a port as a command-line argument: - -.. code-block:: terminal - - # passing a specific IP and port - $ php bin/console server:start 192.168.0.1:8080 - - # passing '*' as the IP means to use 0.0.0.0 (i.e. any local IP address) - $ php bin/console server:start *:8080 - -.. note:: - - You can use the ``server:status`` command to check if a web server is - listening: - - .. code-block:: terminal - - $ php bin/console server:status - -.. tip:: - - Some systems do not support the ``server:start`` command, in these cases - you can execute the ``server:run`` command. This command behaves slightly - different. Instead of starting the server in the background, it will block - the current terminal until you terminate it (this is usually done by - pressing Ctrl and C). - -.. sidebar:: Using the built-in Web Server from inside a Virtual Machine - - If you want to use the built-in web server from inside a virtual machine - and then load the site from a browser on your host machine, you'll need - to listen on the ``0.0.0.0:8000`` address (i.e. on all IP addresses that - are assigned to the virtual machine): - - .. code-block:: terminal - - $ php bin/console server:start 0.0.0.0:8000 - - .. caution:: - - You should **NEVER** listen to all interfaces on a computer that is - directly accessible from the Internet. The built-in web server is - not designed to be used on public networks. - -Command Options -~~~~~~~~~~~~~~~ - -The built-in web server expects a "router" script (read about the "router" -script on `php.net`_) as an argument. Symfony already passes such a router -script when the command is executed in the ``prod`` or ``dev`` environment. -Use the ``--router`` option to use your own router script: - -.. code-block:: terminal - - $ php bin/console server:start --router=config/my_router.php - -If your application's document root differs from the standard directory layout, -you have to pass the correct location using the ``--docroot`` option: - -.. code-block:: terminal - - $ php bin/console server:start --docroot=public_html - -Stopping the Server -------------------- - -When you finish your work, you can stop the web server with the following command: - -.. code-block:: terminal - - $ php bin/console server:stop - -.. _`built-in web server`: https://php.net/manual/en/features.commandline.webserver.php -.. _`php.net`: https://php.net/manual/en/features.commandline.webserver.php#example-411 From 28140816fd459739d85ad30f68b4bd7477092932 Mon Sep 17 00:00:00 2001 From: MarvinBlstrli <45764446+MarvinBlstrli@users.noreply.github.com> Date: Wed, 10 Jul 2019 13:55:02 +0200 Subject: [PATCH 014/752] fix data-widget-counter --- reference/forms/types/collection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index ba61e8ca3c3..65e89202c94 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -182,7 +182,7 @@ And update the template as follows:

+

+ to_review Priority +

    +
  • + to_review: + {{ workflow_metadata(blog_post, 'priority', workflow_transition(blog_post, 'to_review')) }} +
  • +
+

Learn more ---------- From 44ca44fad09c1bc61f46c17541ade902897db14f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 26 Jun 2020 16:52:29 +0200 Subject: [PATCH 352/752] Don't use Twig as a public service --- templates.rst | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/templates.rst b/templates.rst index 540e8e493fb..a3d3702f82c 100644 --- a/templates.rst +++ b/templates.rst @@ -565,12 +565,9 @@ Checking if a Template Exists Templates are loaded in the application using a `Twig template loader`_, which also provides a method to check for template existence. First, get the loader:: - // in a controller extending from AbstractController - $loader = $this->get('twig')->getLoader(); - - // in a service using autowiring use Twig\Environment; + // this code assumes that your service uses autowiring to inject dependencies public function __construct(Environment $twig) { $loader = $twig->getLoader(); From f20f59b8ca9cb235c7b9c987e6c775eff897d750 Mon Sep 17 00:00:00 2001 From: Fabien Salathe Date: Thu, 25 Jun 2020 22:02:39 +0200 Subject: [PATCH 353/752] Fix wrong RoutingConfigurator#import usage --- configuration/micro_kernel_trait.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 00f19d6a951..116c79502c1 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -174,12 +174,12 @@ hold the kernel. Now it looks like this:: { // import the WebProfilerRoutes, only if the bundle is enabled if (isset($this->bundles['WebProfilerBundle'])) { - $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml', '/_wdt'); - $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml', '/_profiler'); + $routes->import('@WebProfilerBundle/Resources/config/routing/wdt.xml')->prefix('/_wdt'); + $routes->import('@WebProfilerBundle/Resources/config/routing/profiler.xml')->prefix('/_profiler'); } // load the annotation routes - $routes->import(__DIR__.'/../src/Controller/', '/', 'annotation'); + $routes->import(__DIR__.'/../src/Controller/', 'annotation'); } // optional, to use the standard Symfony cache directory From 54ddd621d07289de7301011c920ebefa61d2966a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 27 Jun 2020 10:10:24 +0200 Subject: [PATCH 354/752] Tweak --- templates.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/templates.rst b/templates.rst index a3d3702f82c..40880d76f63 100644 --- a/templates.rst +++ b/templates.rst @@ -568,6 +568,7 @@ also provides a method to check for template existence. First, get the loader:: use Twig\Environment; // this code assumes that your service uses autowiring to inject dependencies + // otherwise, inject the service called 'twig' manually public function __construct(Environment $twig) { $loader = $twig->getLoader(); From bb10e94dc9bb494a938b150fa492e117b1b8204a Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 28 Jun 2020 10:52:11 +0200 Subject: [PATCH 355/752] Fixed build error --- notifier.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index c90df3fa1a9..5e0b971827c 100644 --- a/notifier.rst +++ b/notifier.rst @@ -281,9 +281,9 @@ transport: - + + ]]> From a4f4c4f4c72a7940a427e0bf177ce6f849c8dff6 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 29 Jun 2020 09:42:12 +0200 Subject: [PATCH 356/752] Readded a content removed by error --- messenger.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/messenger.rst b/messenger.rst index f0c3a93b12d..6033442a725 100644 --- a/messenger.rst +++ b/messenger.rst @@ -911,6 +911,9 @@ a table named ``messenger_messages``. The ability to automatically generate a migration for the ``messenger_messages`` table was introduced in Symfony 5.1 and DoctrineBundle 2.1. +Or, to create the table yourself, set the ``auto_setup`` option to ``false`` and +:ref:`generate a migration `. + The transport has a number of options: .. configuration-block:: From 55a1815f9fb88dc887b47e00b131f3862fc09e0e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Jun 2020 09:48:21 +0200 Subject: [PATCH 357/752] Updated the version numbers --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index e16d5b4def1..60bee1afed4 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --version=4.4 --full + $ symfony new my_project_name --version=5.0 --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name --version=4.4 + $ symfony new my_project_name --version=5.0 The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton:"^4.4" my_project_name + $ composer create-project symfony/website-skeleton:"^5.0" my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton:"^4.4" my_project_name + $ composer create-project symfony/skeleton:"^5.0" my_project_name 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 63fd4fbbe98b66c77f8ef0945d8cddae028e9c53 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Jun 2020 09:49:05 +0200 Subject: [PATCH 358/752] Updated the version numbers --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index 60bee1afed4..f18ac19e9dc 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --version=5.0 --full + $ symfony new my_project_name --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name --version=5.0 + $ symfony new my_project_name The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton:"^5.0" my_project_name + $ composer create-project symfony/website-skeleton my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton:"^5.0" my_project_name + $ composer create-project symfony/skeleton my_project_name 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 bd6cbc830c650b36a59a7ccd8b5ab7c94c9c9819 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Jun 2020 09:50:53 +0200 Subject: [PATCH 359/752] Updated version numbers --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index f18ac19e9dc..08ad45fe407 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --full + $ symfony new my_project_name --version=next --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name + $ symfony new my_project_name --version=next The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton my_project_name + $ composer create-project symfony/website-skeleton:"5.2.x@dev" my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton my_project_name + $ composer create-project symfony/skeleton:"5.2.x@dev" my_project_name 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 66b8ee2ceeef32cb37fea317710641339162a798 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Jun 2020 10:43:02 +0200 Subject: [PATCH 360/752] Removed a merge leftover --- http_client.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/http_client.rst b/http_client.rst index 8e43d8f4e3d..ca273b873f6 100644 --- a/http_client.rst +++ b/http_client.rst @@ -319,7 +319,6 @@ autoconfigure the HTTP client based on the requested URL: ], ], ]); ->>>>>>> 5.0:http_client.rst .. code-block:: php-standalone From ac7ecfc22159139793d91fd1abe111923808b9fd Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 30 Jun 2020 10:46:33 +0200 Subject: [PATCH 361/752] Updated a wrong reference --- components/asset.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/asset.rst b/components/asset.rst index fee6acd6aa5..20b5ce20b2d 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -167,7 +167,7 @@ In those cases, use the If your JSON file is not on your local filesystem but is accessible over HTTP, use the :class:`Symfony\\Component\\Asset\\VersionStrategy\\RemoteJsonManifestVersionStrategy` -with the :doc:`HttpClient component `:: +with the :doc:`HttpClient component `:: use Symfony\Component\Asset\Package; use Symfony\Component\Asset\VersionStrategy\RemoteJsonManifestVersionStrategy; From 105ff11c5aebe8d3c742f397d9ea7a0bb5a81938 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 30 Jun 2020 15:19:53 +0200 Subject: [PATCH 362/752] Test redirecting to a specific section from redirection_map --- _build/redirection_map | 1 + 1 file changed, 1 insertion(+) diff --git a/_build/redirection_map b/_build/redirection_map index 28b3aad29e5..ebc50553de8 100644 --- a/_build/redirection_map +++ b/_build/redirection_map @@ -507,3 +507,4 @@ /components/class_loader https://github.com/symfony/class-loader /frontend/encore/versus-assetic /frontend /components/http_client /http_client +/redirection_test /session/database.html#store-sessions-in-a-nosql-database-mongodb From 8574f41d17f59d24104a2cb5b16485275a100a37 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Wed, 1 Jul 2020 13:39:50 +0200 Subject: [PATCH 363/752] Update serializer.rst --- components/serializer.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 3191276ae8b..4fe9e67c1ad 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -830,8 +830,7 @@ always as a collection. .. tip:: XML comments are ignored by default when decoding contents, but this - behavior can be changed with the optional ``$decoderIgnoredNodeTypes`` argument of - the ``XmlEncoder`` class constructor. + behavior can be changed with the optional context key ``XmlEncoder::DECODER_IGNORED_NODE_TYPES``. Data with ``#comment`` keys are encoded to XML comments by default. This can be changed with the optional ``$encoderIgnoredNodeTypes`` argument of the From abcb1839877fa2b08cd740af659a219815a3a26b Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 1 Jul 2020 14:41:13 +0200 Subject: [PATCH 364/752] Update docs regarding 2nd argument of DomCrawler text() The 2nd Argument is true by default, therefore whitespace is trimmed by default. Passing false will alter the default behaviour. Previous documentation suggested the other way around. --- components/dom_crawler.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 8bc6a093fc8..cda18b47662 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -220,9 +220,9 @@ Access the value of the first node of the current selection:: // avoid the exception passing an argument that text() returns when node does not exist $message = $crawler->filterXPath('//body/p')->text('Default text content'); - // pass TRUE as the second argument of text() to remove all extra white spaces, including + // pass false as the second argument of text() to not remove all extra white spaces, including // the internal ones (e.g. " foo\n bar baz \n " is returned as "foo bar baz") - $crawler->filterXPath('//body/p')->text('Default text content', true); + $crawler->filterXPath('//body/p')->text('Default text content', false); Access the attribute value of the first node of the current selection:: From d182a48bad37b8e35b094402ba57703b5028586c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 1 Jul 2020 17:24:04 +0200 Subject: [PATCH 365/752] Reword --- components/dom_crawler.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index cda18b47662..eb0e6850ccd 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -220,8 +220,9 @@ Access the value of the first node of the current selection:: // avoid the exception passing an argument that text() returns when node does not exist $message = $crawler->filterXPath('//body/p')->text('Default text content'); - // pass false as the second argument of text() to not remove all extra white spaces, including - // the internal ones (e.g. " foo\n bar baz \n " is returned as "foo bar baz") + // by default, text() trims white spaces, including the internal ones + // (e.g. " foo\n bar baz \n " is returned as "foo bar baz") + // pass FALSE as the second argument to return the original text unchanged $crawler->filterXPath('//body/p')->text('Default text content', false); Access the attribute value of the first node of the current selection:: From 377c0c0d544277b48879e918f515bc2f1142c423 Mon Sep 17 00:00:00 2001 From: Alexander Grimalovsky Date: Wed, 1 Jul 2020 22:55:10 +0300 Subject: [PATCH 366/752] Fixed mention of minimum PHP version for v5.x Minimum PHP version for Symfony 5.x is 7.2.5, but documentation doesn't reflect this change and keep same PHP version as 3.x. --- contributing/code/pull_requests.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/contributing/code/pull_requests.rst b/contributing/code/pull_requests.rst index 74048987ced..ee8ce72825b 100644 --- a/contributing/code/pull_requests.rst +++ b/contributing/code/pull_requests.rst @@ -25,7 +25,7 @@ Before working on Symfony, setup a friendly environment with the following software: * Git; -* PHP version 7.1.3 or above. +* PHP version 7.2.5 or above. Configure Git ~~~~~~~~~~~~~ @@ -193,8 +193,8 @@ want to debug are installed by running ``composer install`` inside it. .. tip:: - If symlinks to your local Symfony fork cannot be resolved inside your project due to - your dev environment (for instance when using Vagrant where only the current project + If symlinks to your local Symfony fork cannot be resolved inside your project due to + your dev environment (for instance when using Vagrant where only the current project directory is mounted), you can alternatively use the ``--copy`` option. .. _work-on-your-patch: From 427d99285b51165d39ac251bea19b4759c8a573b Mon Sep 17 00:00:00 2001 From: Surfoo Date: Mon, 29 Jun 2020 13:52:21 +0200 Subject: [PATCH 367/752] Fixed micro kernel demo --- configuration/micro_kernel_trait.rst | 62 ++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 00f19d6a951..54fdbb54f0b 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -54,9 +54,7 @@ Next, create an ``index.php`` file that defines the kernel class and executes it protected function configureRoutes(RoutingConfigurator $routes) { - // kernel is a service that points to this class - // optional 3rd argument is the route name - $routes->add('/random/{limit}', 'kernel::randomNumber'); + $routes->add('random_number', '/random/{limit}')->controller([$this, 'randomNumber']); } public function randomNumber($limit) @@ -151,7 +149,7 @@ hold the kernel. Now it looks like this:: ]; if ($this->getEnvironment() == 'dev') { - $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); + $bundles[] = new \Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); } return $bundles; @@ -160,6 +158,7 @@ hold the kernel. Now it looks like this:: protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) { $loader->load(__DIR__.'/../config/framework.yaml'); + $loader->load(__DIR__.'/../config/services.yaml'); // configure WebProfilerBundle only if the bundle is enabled if (isset($this->bundles['WebProfilerBundle'])) { @@ -201,6 +200,61 @@ Before continuing, run this command to add support for the new dependencies: $ composer require symfony/yaml symfony/twig-bundle symfony/web-profiler-bundle doctrine/annotations +You need add the following service configuration, which is the default config for a new project: + +.. configuration-block:: + + .. code-block:: yaml + + # config/services.yaml + services: + # default configuration for services in *this* file + _defaults: + autowire: true # Automatically injects dependencies in your services. + autoconfigure: true # 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 + App\: + resource: '../src/*' + + .. code-block:: xml + + + + + + + + + + + + + + + + .. code-block:: php + + // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + + return function(ContainerConfigurator $configurator) { + // default configuration for services in *this* file + $services = $configurator->services() + ->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/*'); + }; + Unlike the previous kernel, this loads an external ``config/framework.yaml`` file, because the configuration started to get bigger: From e1c35a5385d20f0f32e49de94de8f9e5428c129d Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 7 Jul 2020 15:02:05 +0200 Subject: [PATCH 368/752] [#13919] Use ContainerConfigurator and fixes some bugs after testing the example code --- configuration/micro_kernel_trait.rst | 105 +++++++-------------------- 1 file changed, 27 insertions(+), 78 deletions(-) diff --git a/configuration/micro_kernel_trait.rst b/configuration/micro_kernel_trait.rst index 42da9fdeff2..84d8da1f028 100644 --- a/configuration/micro_kernel_trait.rst +++ b/configuration/micro_kernel_trait.rst @@ -24,8 +24,7 @@ Next, create an ``index.php`` file that defines the kernel class and executes it // index.php use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; - use Symfony\Component\Config\Loader\LoaderInterface; - use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\Kernel as BaseKernel; @@ -37,27 +36,27 @@ Next, create an ``index.php`` file that defines the kernel class and executes it { use MicroKernelTrait; - public function registerBundles() + public function registerBundles(): array { return [ - new Symfony\Bundle\FrameworkBundle\FrameworkBundle() + new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), ]; } - protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) + protected function configureContainer(ContainerConfigurator $c): void { // PHP equivalent of config/packages/framework.yaml - $c->loadFromExtension('framework', [ + $c->extension('framework', [ 'secret' => 'S0ME_SECRET' ]); } - protected function configureRoutes(RoutingConfigurator $routes) + protected function configureRoutes(RoutingConfigurator $routes): void { $routes->add('random_number', '/random/{limit}')->controller([$this, 'randomNumber']); } - public function randomNumber($limit) + public function randomNumber(int $limit): JsonResponse { return new JsonResponse([ 'number' => random_int(0, $limit), @@ -89,9 +88,9 @@ that define your bundles, your services and your routes: **registerBundles()** This is the same ``registerBundles()`` that you see in a normal kernel. -**configureContainer(ContainerBuilder $c, LoaderInterface $loader)** +**configureContainer(ContainerConfigurator $c)** This method builds and configures the container. In practice, you will use - ``loadFromExtension`` to configure different bundles (this is the equivalent + ``extension()`` to configure different bundles (this is the equivalent of what you see in a normal ``config/packages/*`` file). You can also register services directly in PHP or load external configuration files (shown below). @@ -132,8 +131,7 @@ hold the kernel. Now it looks like this:: namespace App; use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; - use Symfony\Component\Config\Loader\LoaderInterface; - use Symfony\Component\DependencyInjection\ContainerBuilder; + use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; use Symfony\Component\HttpKernel\Kernel as BaseKernel; use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; @@ -141,7 +139,7 @@ hold the kernel. Now it looks like this:: { use MicroKernelTrait; - public function registerBundles() + public function registerBundles(): array { $bundles = [ new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(), @@ -155,21 +153,27 @@ hold the kernel. Now it looks like this:: return $bundles; } - protected function configureContainer(ContainerBuilder $c, LoaderInterface $loader) + protected function configureContainer(ContainerConfigurator $c): void { - $loader->load(__DIR__.'/../config/framework.yaml'); - $loader->load(__DIR__.'/../config/services.yaml'); + $c->import(__DIR__.'/../config/framework.yaml'); + + // register all classes in /src/ as service + $c->services() + ->load('App\\', __DIR__.'/*') + ->autowire() + ->autoconfigure() + ; // configure WebProfilerBundle only if the bundle is enabled if (isset($this->bundles['WebProfilerBundle'])) { - $c->loadFromExtension('web_profiler', [ + $c->extension('web_profiler', [ 'toolbar' => true, 'intercept_redirects' => false, ]); } } - protected function configureRoutes(RoutingConfigurator $routes) + protected function configureRoutes(RoutingConfigurator $routes): void { // import the WebProfilerRoutes, only if the bundle is enabled if (isset($this->bundles['WebProfilerBundle'])) { @@ -178,17 +182,17 @@ hold the kernel. Now it looks like this:: } // load the annotation routes - $routes->import(__DIR__.'/../src/Controller/', 'annotation'); + $routes->import(__DIR__.'/Controller/', 'annotation'); } // optional, to use the standard Symfony cache directory - public function getCacheDir() + public function getCacheDir(): string { return __DIR__.'/../var/cache/'.$this->getEnvironment(); } // optional, to use the standard Symfony logs directory - public function getLogDir() + public function getLogDir(): string { return __DIR__.'/../var/log'; } @@ -200,61 +204,6 @@ Before continuing, run this command to add support for the new dependencies: $ composer require symfony/yaml symfony/twig-bundle symfony/web-profiler-bundle doctrine/annotations -You need add the following service configuration, which is the default config for a new project: - -.. configuration-block:: - - .. code-block:: yaml - - # config/services.yaml - services: - # default configuration for services in *this* file - _defaults: - autowire: true # Automatically injects dependencies in your services. - autoconfigure: true # 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 - App\: - resource: '../src/*' - - .. code-block:: xml - - - - - - - - - - - - - - - - .. code-block:: php - - // config/services.php - namespace Symfony\Component\DependencyInjection\Loader\Configurator; - - return function(ContainerConfigurator $configurator) { - // default configuration for services in *this* file - $services = $configurator->services() - ->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/*'); - }; - Unlike the previous kernel, this loads an external ``config/framework.yaml`` file, because the configuration started to get bigger: @@ -299,6 +248,7 @@ has one file in it:: namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class MicroController extends AbstractController @@ -306,7 +256,7 @@ has one file in it:: /** * @Route("/random/{limit}") */ - public function randomNumber($limit) + public function randomNumber(int $limit): Response { $number = random_int(0, $limit); @@ -381,7 +331,6 @@ As before you can use the :doc:`Symfony Local Web Server .. code-block:: terminal - cd public/ $ symfony server:start Then visit the page in your browser: http://localhost:8000/random/10 From 02ee00b734d96aa7929012e8ad938d72d1c04d12 Mon Sep 17 00:00:00 2001 From: Thomas Trautner Date: Tue, 7 Jul 2020 10:18:53 +0200 Subject: [PATCH 369/752] Remove links to not existing channel pages --- notifier.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notifier.rst b/notifier.rst index 5e0b971827c..cc66c6f854d 100644 --- a/notifier.rst +++ b/notifier.rst @@ -31,10 +31,10 @@ by using transports. The notifier component supports the following channels: -* `SMS `_ sends notifications to phones via SMS messages -* `Chat `_ sends notifications to chat services like Slack +* SMS sends notifications to phones via SMS messages +* Chat sends notifications to chat services like Slack and Telegram; -* `Email `_ integrates the :doc:`Symfony Mailer `; +* Email integrates the :doc:`Symfony Mailer `; * Browser uses :ref:`flash messages `. .. tip:: From 9848b6ed5bada3a6ef8fc56c4a4219946b1f1d57 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 8 Jul 2020 17:14:23 +0200 Subject: [PATCH 370/752] Added some links --- notifier.rst | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/notifier.rst b/notifier.rst index cc66c6f854d..4857a3a2d18 100644 --- a/notifier.rst +++ b/notifier.rst @@ -31,17 +31,19 @@ by using transports. The notifier component supports the following channels: -* SMS sends notifications to phones via SMS messages -* Chat sends notifications to chat services like Slack - and Telegram; -* Email integrates the :doc:`Symfony Mailer `; -* Browser uses :ref:`flash messages `. +* :ref:`SMS channel ` sends notifications to phones via + SMS messages; +* :ref:`Chat channel ` sends notifications to chat + services like Slack and Telegram; +* :ref:`Email channel ` integrates the :doc:`Symfony Mailer `; +* Browser channel uses :ref:`flash messages `. .. tip:: Use :doc:`secrets ` to securily store your API's tokens. +.. _notifier-sms-channel: .. _notifier-texter-dsn: SMS Channel @@ -109,6 +111,7 @@ configure the ``texter_transports``: ], ]); +.. _notifier-chat-channel: .. _notifier-chatter-dsn: Chat Channel @@ -174,6 +177,8 @@ Chatters are configured using the ``chatter_transports`` setting: ], ]); +.. _notifier-email-channel: + Email Channel ~~~~~~~~~~~~~ @@ -279,7 +284,7 @@ transport: %env(SLACK_DSN)% || %env(TELEGRAM_DSN)% - Date: Wed, 8 Jul 2020 17:22:02 +0200 Subject: [PATCH 371/752] Updated some Docrine config changes for Symfony 5.1 --- doctrine/multiple_entity_managers.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/doctrine/multiple_entity_managers.rst b/doctrine/multiple_entity_managers.rst index 3cbfbd75eb3..38711b468c1 100644 --- a/doctrine/multiple_entity_managers.rst +++ b/doctrine/multiple_entity_managers.rst @@ -192,8 +192,8 @@ for each entity manager. the connection or entity manager, the default (i.e. ``default``) is used. If you use a different name than ``default`` for the default entity manager, - you will need to redefine the default entity manager in ``prod`` environment - configuration too: + you will need to redefine the default entity manager in the ``prod`` environment + configuration and in the Doctrine migrations configuration (if you use that): .. code-block:: yaml @@ -204,6 +204,13 @@ for each entity manager. # ... + .. code-block:: yaml + + # config/packages/doctrine_migrations.yaml + doctrine_migrations: + # ... + em: 'your default entity manager name' + When working with multiple connections to create your databases: .. code-block:: terminal From 8b1767fc8b74a6c5e6835ec30c583f3f14921131 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 9 Jul 2020 09:11:14 +0200 Subject: [PATCH 372/752] Removed the versionadded directive --- components/property_info.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index dd6cda0b742..44bfe2c9558 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -490,10 +490,6 @@ service by defining it as a service with one or more of the following * ``property_info.initializable_extractor`` if it provides initializable information (it checks if a property can be initialized through the constructor). -.. versionadded:: 4.2 - - The ``property_info.initializable_extractor`` was introduced in Symfony 4.2. - .. _`phpDocumentor Reflection`: https://github.com/phpDocumentor/ReflectionDocBlock .. _`phpdocumentor/reflection-docblock`: https://packagist.org/packages/phpdocumentor/reflection-docblock .. _`Doctrine ORM`: https://www.doctrine-project.org/projects/orm.html From 486a1fe9b3d4280507c4f5acb6c7971e76457725 Mon Sep 17 00:00:00 2001 From: Souhail Date: Fri, 10 Jul 2020 10:54:54 +0200 Subject: [PATCH 373/752] Update experimental_authenticators.rst Fix the link for `PreAuthenticatedUserBadge` class --- security/experimental_authenticators.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 4299a452dcf..a8c5ee3cc55 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -464,7 +464,7 @@ the following badges are supported: authentication. The constructor requires a token ID (unique per form) and CSRF token (unique per request). See :doc:`/security/csrf`. -:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Badge\\PreAuthenticatedBadge` +:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Badge\\PreAuthenticatedUserBadge` Indicates that this user was pre-authenticated (i.e. before Symfony was initiated). This skips the :doc:`pre-authentication user checker `. From 9b7bae9656bd7bfea13dcfb8c946949a06069e9c Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 12 Jul 2020 23:27:40 +0200 Subject: [PATCH 374/752] Add doc for Isin constraint --- reference/constraints.rst | 1 + reference/constraints/Isin.rst | 99 +++++++++++++++++++++++++++++++ reference/constraints/map.rst.inc | 1 + 3 files changed, 101 insertions(+) create mode 100644 reference/constraints/Isin.rst diff --git a/reference/constraints.rst b/reference/constraints.rst index faa5ed3cac2..a3c99715834 100644 --- a/reference/constraints.rst +++ b/reference/constraints.rst @@ -62,6 +62,7 @@ Validation Constraints Reference constraints/Bic constraints/Isbn constraints/Issn + constraints/Isin constraints/AtLeastOneOf constraints/Sequentially diff --git a/reference/constraints/Isin.rst b/reference/constraints/Isin.rst new file mode 100644 index 00000000000..86c1c3a3973 --- /dev/null +++ b/reference/constraints/Isin.rst @@ -0,0 +1,99 @@ +Isin +==== + +Validates that a value is a valid +`International Securities Identification Number (ISIN)`_. + +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Isin` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\IsinValidator` +========== =================================================================== + +Basic Usage +----------- + +.. configuration-block:: + + .. code-block:: php-annotations + + // src/Entity/UnitAccount.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class UnitAccount + { + /** + * @Assert\Isin + */ + protected $isin; + } + + .. code-block:: yaml + + # config/validator/validation.yaml + App\Entity\UnitAccount: + properties: + isin: + - Isin: ~ + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // src/Entity/UnitAccount.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; + + class UnitAccount + { + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addPropertyConstraint('isin', new Assert\Isin()); + } + } + +.. include:: /reference/constraints/_empty-values-are-valid.rst.inc + +Options +------- + +.. include:: /reference/constraints/_groups-option.rst.inc + +message +~~~~~~~ + +**type**: ``string`` default: ``This value is not a valid International Securities Identification Number (ISIN).`` + +The message shown if the given value is not a valid ISIN. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + +.. include:: /reference/constraints/_payload-option.rst.inc + +.. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number diff --git a/reference/constraints/map.rst.inc b/reference/constraints/map.rst.inc index 05e820db8ee..d8e8cfcd2f9 100644 --- a/reference/constraints/map.rst.inc +++ b/reference/constraints/map.rst.inc @@ -80,6 +80,7 @@ Financial and other Number Constraints * :doc:`Iban ` * :doc:`Isbn ` * :doc:`Issn ` +* :doc:`Isin ` Other Constraints ~~~~~~~~~~~~~~~~~ From 4de67df7cdb8d299ac0ab57f8cb5bb7a12b351fb Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 13 Jul 2020 15:17:22 +0200 Subject: [PATCH 375/752] [Mailer] Allow UTF-8 chars in email addresses --- mailer.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mailer.rst b/mailer.rst index 9dd1df9bb39..51bc410ce8a 100644 --- a/mailer.rst +++ b/mailer.rst @@ -161,6 +161,16 @@ both strings or address objects:: :class:`Symfony\\Component\\Mailer\\Event\\MessageEvent` event to set the same ``From`` email to all messages. +.. note:: + + The local part of the address (what goes before the ``@``) can include UTF-8 + characters, except for the sender address (to avoid issues with bounced emails). + For example: ``föóbàr@example.com``, ``用户@example.com``, ``θσερ@example.com``, etc. + + .. versionadded:: 5.2 + + Support for UTF-8 characters in email addresses was introduced in Symfony 5.2. + Multiple addresses are defined with the ``addXXX()`` methods:: $email = (new Email()) From 3be2860ceb7f0203bab46930b89d9b5fcc7a2af0 Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Tue, 14 Jul 2020 10:33:29 -0400 Subject: [PATCH 376/752] default path of migrations changed in recipe --- doctrine.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doctrine.rst b/doctrine.rst index 99f0384892a..abeb4daa46d 100644 --- a/doctrine.rst +++ b/doctrine.rst @@ -225,7 +225,7 @@ If everything worked, you should see something like this: SUCCESS! - Next: Review the new migration "src/Migrations/Version20180207231217.php" + Next: Review the new migration "migrations/Version20180207231217.php" Then: Run the migration with php bin/console doctrine:migrations:migrate If you open this file, it contains the SQL needed to update your database! To run From 264aaf1bb51c00b2a98ec9a7c83aef668bb60bcb Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 13 Jul 2020 14:46:55 +0200 Subject: [PATCH 377/752] [HttpFoundation] Document HeaderUtils::parseQuery() --- components/http_foundation.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index e29c16ff384..0677f3a2f73 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -272,6 +272,14 @@ this complexity and defines some methods for the most common tasks:: HeaderUtils::unquote('"foo \"bar\""'); // => 'foo "bar"' + // Parses a query string but maintains dots (PHP parse_str() replaces '.' by '_') + HeaderUtils::parseQuery('foo[bar.baz]=qux'); + // => ['foo' => ['bar.baz' => 'qux']] + +.. versionadded:: 5.2 + + The ``parseQuery()`` method was introduced in Symfony 5.2. + Accessing ``Accept-*`` Headers Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From fe2ad65e1563f8eba3414aa91b63206e4f53ed60 Mon Sep 17 00:00:00 2001 From: Abdouni Abdelkarim Date: Wed, 15 Jul 2020 10:40:39 +0200 Subject: [PATCH 378/752] Update service_container.rst Hello, I removed the `Migrations` folder from exclude. Since 5.1, this directory has been moved outside of `src`. --- service_container.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/service_container.rst b/service_container.rst index 67195adeb3b..c78af339afb 100644 --- a/service_container.rst +++ b/service_container.rst @@ -159,7 +159,7 @@ each time you ask for it. # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/*' - exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' + exclude: '../src/{DependencyInjection,Entity,Tests,Kernel.php}' # ... @@ -178,7 +178,7 @@ each time you ask for it. - + @@ -201,7 +201,7 @@ each time you ask for it. // 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/*') - ->exclude('../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'); + ->exclude('../src/{DependencyInjection,Entity,Tests,Kernel.php}'); }; .. tip:: @@ -408,7 +408,7 @@ pass here. No problem! In your configuration, you can explicitly set this argume # same as before App\: resource: '../src/*' - exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' + exclude: '../src/{DependencyInjection,Entity,Tests,Kernel.php}' # explicitly configure the service App\Updates\SiteUpdateManager: @@ -431,7 +431,7 @@ pass here. No problem! In your configuration, you can explicitly set this argume @@ -453,7 +453,7 @@ pass here. No problem! In your configuration, you can explicitly set this argume // same as before $services->load('App\\', '../src/*') - ->exclude('../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'); + ->exclude('../src/{DependencyInjection,Entity,Tests,Kernel.php}'); $services->set(SiteUpdateManager::class) ->arg('$adminEmail', 'manager@example.com') @@ -929,7 +929,7 @@ key. For example, the default Symfony configuration contains this: # this creates a service per class whose id is the fully-qualified class name App\: resource: '../src/*' - exclude: '../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}' + exclude: '../src/{DependencyInjection,Entity,Tests,Kernel.php}' .. code-block:: xml @@ -943,7 +943,7 @@ key. For example, the default Symfony configuration contains this: - + @@ -958,7 +958,7 @@ key. For example, the default Symfony configuration contains this: // 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/*') - ->exclude('../src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'); + ->exclude('../src/{DependencyInjection,Entity,Tests,Kernel.php}'); }; .. tip:: From 6a539f68eb8fc3b91dc9ccc016f536f611c44867 Mon Sep 17 00:00:00 2001 From: Iliya Miroslavov Iliev Date: Tue, 21 Jul 2020 11:10:22 +0300 Subject: [PATCH 379/752] Update OVH Cloud configuration --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index ebc46605a22..c1b6ebfabe5 100644 --- a/notifier.rst +++ b/notifier.rst @@ -59,7 +59,7 @@ Service Package DSN ========== =============================== ==================================================== Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` -OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://KEY:SECRET@default?from=FROM`` +OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` FreeMobile ``symfony/freemobile-notifier`` ``freemobile://LOGIN:PASS@default?phone=PHONE`` ========== =============================== ==================================================== From ae0b34e90e7893bfb96c91481c18c35fccec2e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tam=C3=A1s=20Moln=C3=A1r?= Date: Tue, 28 Jul 2020 09:11:30 +0200 Subject: [PATCH 380/752] [String] Fix missing locale in slugger substitution map --- components/string.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/string.rst b/components/string.rst index 2d5d1dd8e9e..7d2ec49a198 100644 --- a/components/string.rst +++ b/components/string.rst @@ -469,7 +469,7 @@ that only includes safe ASCII characters:: // $slug = 'Workspace-settings' // you can also pass an array with additional character substitutions - $slugger = new AsciiSlugger('en', ['%' => 'percent', '€' => 'euro']); + $slugger = new AsciiSlugger('en', ['en' => ['%' => 'percent', '€' => 'euro']]); $slug = $slugger->slug('10% or 5€'); // $slug = '10-percent-or-5-euro' From a1ce6020bc31ce49cb5b0c6b15a451be755bda3d Mon Sep 17 00:00:00 2001 From: fliespl Date: Tue, 28 Jul 2020 13:05:34 +0200 Subject: [PATCH 381/752] verify_peer in dsn should be 0 Setting it to false value resolves to true in php 7.4 since false is taken as string. --- components/mailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mailer.rst b/components/mailer.rst index 1f004e90bc6..7e2dd89e798 100644 --- a/components/mailer.rst +++ b/components/mailer.rst @@ -171,7 +171,7 @@ configurable with the ``verify_peer`` option. Although it's not recommended to disable this verification for security reasons, it can be useful while developing the application or when using a self-signed certificate:: - $dsn = 'smtp://user:pass@smtp.example.com?verify_peer=false' + $dsn = 'smtp://user:pass@smtp.example.com?verify_peer=0' .. versionadded:: 5.1 From 4ea23f77a4353a57d7dd9a7e308eee4db7dff692 Mon Sep 17 00:00:00 2001 From: Andrius Date: Mon, 3 Aug 2020 00:56:30 +0300 Subject: [PATCH 382/752] Update performance.rst Correct path for opcache.preload in symfony cache dir. --- performance.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/performance.rst b/performance.rst index b919f6a3906..7d4ea2e5fb9 100644 --- a/performance.rst +++ b/performance.rst @@ -120,7 +120,7 @@ The preload file path is the same as the compiled service container but with the .. code-block:: ini ; php.ini - opcache.preload=/path/to/project/var/cache/prod/srcApp_KernelProdContainer.preload.php + opcache.preload=/path/to/project/var/cache/prod/App_KernelProdContainer.preload.php Use the :ref:`container.preload ` and :ref:`container.no_preload ` service tags to define From ff3a2b58b1a81167ed8b771f29466de3542ee141 Mon Sep 17 00:00:00 2001 From: Milan Pavkovic Date: Wed, 5 Aug 2020 18:30:28 +0200 Subject: [PATCH 383/752] Remove reference to non-existing fromBinary method --- components/uid.rst | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index f2fcd074533..c8eee0ece94 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -62,15 +62,10 @@ to create each type of UUID:: If your UUID is generated by another system, use the ``fromString()`` method to create an object and make use of the utilities available for Symfony UUIDs:: - // this value is generated somewhere else + // this value is generated somewhere else (can also be in binary format) $uuidValue = 'd9e7a184-5d5b-11ea-a62a-3499710062d0'; $uuid = Uuid::fromString($uuidValue); -If your UUIDs are generated in binary format, use the ``fromBinary()`` method -to create the objects for them:: - - $uuid = Uuid::fromBinary($uuidBinaryContents); - Converting UUIDs ~~~~~~~~~~~~~~~~ @@ -140,15 +135,10 @@ Instantiate the ``Ulid`` class to generate a random ULID value:: If your ULID is generated by another system, use the ``fromString()`` method to create an object and make use of the utilities available for Symfony ULIDs:: - // this value is generated somewhere else + // this value is generated somewhere else (can also be in binary format) $ulidValue = '01E439TP9XJZ9RPFH3T1PYBCR8'; $ulid = Ulid::fromString($ulidValue); -If your ULIDs are generated in binary format, use the ``fromBinary()`` method -to create the objects for them:: - - $ulid = Ulid::fromBinary($ulidBinaryContents); - Converting ULIDs ~~~~~~~~~~~~~~~~ From d6f8fd83dce5cb5ed477cecc8a013bfceeb76ebf Mon Sep 17 00:00:00 2001 From: Lorenzo Date: Sun, 9 Aug 2020 20:09:25 +0100 Subject: [PATCH 384/752] Update chatters.rst fix to use a working image url --- notifier/chatters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index 17eac35885f..40e9cea2096 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -77,7 +77,7 @@ some interactive options called `Block elements`_:: ->text('The Symfony Community') ->accessory( new SlackImageBlockElement( - 'https://example.com/symfony-logo.png', + 'https://symfony.com/favicons/apple-touch-icon.png', 'Symfony' ) ) From b92adf679b1f2630bd07d7f03bed92d34523a35f Mon Sep 17 00:00:00 2001 From: Ivan Yivoff Date: Tue, 11 Aug 2020 15:47:15 +0200 Subject: [PATCH 385/752] Update event_dispatcher.rst Update code example to match 5.1 PHP configuration format. --- event_dispatcher.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 8bef74f26d9..15742afce71 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -101,8 +101,10 @@ using a special "tag": // config/services.php use App\EventListener\ExceptionListener; + + $services = $containerConfigurator->services(); - $container->register(ExceptionListener::class) + $services->set(ExceptionListener::class) ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) ; From e82b66b787a929d2c2898efc98aa7bb18ff7c77b Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Mon, 27 Jul 2020 19:32:49 -0500 Subject: [PATCH 386/752] [Console] allow multiline responses to console questions --- components/console/helpers/questionhelper.rst | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index e2c5898fa49..89716c8d078 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -234,6 +234,36 @@ You can also specify if you want to not trim the answer by setting it directly w $name = $helper->ask($input, $output, $question); } +Accept Multiline Answers +~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + The ``setMultiline()`` and ``isMultiline()`` methods were introduced in + Symfony 5.2. + +By default, the question helper stops reading user input when it receives a newline +character (i.e., when the user hits ``ENTER`` once). However, you may specify that +the response to a question should allow multiline answers by passing ``true`` to +:method:`Symfony\\Component\\Console\\Question\\Question::setMultiline`:: + + use Symfony\Component\Console\Question\Question; + + // ... + public function execute(InputInterface $input, OutputInterface $output) + { + // ... + $helper = $this->getHelper('question'); + + $question = new Question('How do you solve world peace?'); + $question->setMultiline(true); + + $answer = $helper->ask($input, $output, $question); + } + +Multiline questions stop reading user input after receiving an end-of-transmission +control character (``Ctrl-D`` on Unix systems or ``Ctrl-Z`` on Windows). + Hiding the User's Response ~~~~~~~~~~~~~~~~~~~~~~~~~~ From 605e9888ff1481b765363895f0a617d8f9e955b4 Mon Sep 17 00:00:00 2001 From: fernandokarpinski <31803120+fernandokarpinski@users.noreply.github.com> Date: Tue, 11 Aug 2020 23:41:59 -0300 Subject: [PATCH 387/752] Update routing.rst --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index b2e252d87b5..0b675a67a60 100644 --- a/routing.rst +++ b/routing.rst @@ -1881,7 +1881,7 @@ Now, if the session is used, the application will report it based on your * ``enabled``: will throw an :class:`Symfony\\Component\\HttpKernel\\Exception\\UnexpectedSessionUsageException` exception * ``disabled``: will log a warning -It well help you understanding and hopefully fixing unexpected behavior in your application. +It will help you in understanding and hopefully fixing unexpected behavior in your application. .. _routing-generating-urls: From 4a5be126e1f1e7adfc3f55e95e1219b1b2159e2d Mon Sep 17 00:00:00 2001 From: khoptynskyi Date: Sun, 16 Aug 2020 17:25:22 +0300 Subject: [PATCH 388/752] [Console] added TableCellStyle documentation --- components/console/helpers/table.rst | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/components/console/helpers/table.rst b/components/console/helpers/table.rst index bc680cc5ad0..d50cc160c06 100644 --- a/components/console/helpers/table.rst +++ b/components/console/helpers/table.rst @@ -393,3 +393,36 @@ This will display the following table in the terminal: | Love | | Symfony | +---------+ + +.. versionadded:: 5.2 + +Styling of table cells +---------------------- + +You can customize a table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`:: + + use Symfony\Component\Console\Helper\Table; + use Symfony\Component\Console\Helper\TableCellStyle; + + $table = new Table($output); + + $table->setRows([ + [ + '978-0804169127', + new TableCell( + 'Divine Comedy', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + 'fg' => 'red', + 'bg' => 'green', + + // or + 'cellFormat' => '%s', + ]) + ] + ) + ], + ]); + + $table->render(); From abf4680a807eaaa3b597abb250407aee2c26e860 Mon Sep 17 00:00:00 2001 From: Antonio Pauletich Date: Mon, 17 Aug 2020 01:03:24 +0200 Subject: [PATCH 389/752] Add Beanstalkd Messenger bridge documentation --- messenger.rst | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/messenger.rst b/messenger.rst index 87f37600524..3b5e81ced07 100644 --- a/messenger.rst +++ b/messenger.rst @@ -992,6 +992,102 @@ auto_setup Whether the table should be created automatically during send / get. true ================== =================================== ====================== +Beanstalkd Transport +~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + Install it by running: + + .. code-block:: terminal + + $ composer require symfony/beanstalkd-messenger + +.. code-block:: bash + + # .env + MESSENGER_TRANSPORT_DSN=beanstalkd://localhost + +The format is ``beanstalkd://:?tube_name=&timeout=&ttr=``. + +The ``port`` setting is optional and defaults to ``11300`` if not set. + +The transport has a number of options: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/messenger.yaml + framework: + messenger: + transports: + async_priority_high: "%env(MESSENGER_TRANSPORT_DSN)%?tube_name=high_priority" + async_normal: + dsn: "%env(MESSENGER_TRANSPORT_DSN)%" + options: + tube_name: normal_priority + + .. code-block:: xml + + + + + + + + + + + + normal_priority + + + + + + + + .. code-block:: php + + // config/packages/messenger.php + $container->loadFromExtension('framework', [ + 'messenger' => [ + 'transports' => [ + 'async_priority_high' => '%env(MESSENGER_TRANSPORT_DSN)%?tube_name=high_priority', + 'async_priority_low' => [ + 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%', + 'options' => [ + 'tube_name' => 'normal_priority' + ] + ], + ], + ], + ]); + +Options defined under ``options`` take precedence over ones defined in the DSN. + +================== =================================== ====================== + Option Description Default +================== =================================== ====================== +tube_name Name of the queue default +timeout Message reservation timeout 0 (will cause the + - in seconds. server to immediately + return either a + response or a + TransportException + will be thrown) +ttr The message time to run before it + is put back in the ready queue + - in seconds. 90 +================== =================================== ====================== + Redis Transport ~~~~~~~~~~~~~~~ From 54eafd372f054ad17151700fd0c9fda633a4373d Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Sun, 16 Aug 2020 21:03:42 +0200 Subject: [PATCH 390/752] Documentation about custom data collectors with autowire/autoconfigure --- profiler/data_collector.rst | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 41378ab6464..5081ac76692 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -104,18 +104,25 @@ The information collected by your data collector can be displayed both in the web debug toolbar and in the web profiler. To do so, you need to create a Twig template that includes some specific blocks. -However, first you must add some getters in the data collector class to give the +However, first make your DataCollector to extends :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector` instead of :class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector`. When extending :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector`, you don't need to implement `getName` method; your collector FQDN is returned as identifier (you can also override it if needed). Though you need to implement `getTemplate` with the template you're going to use in the profiler (see below). + +Then you must add some getters in the data collector class to give the template access to the collected information:: // src/DataCollector/RequestCollector.php namespace App\DataCollector; - use Symfony\Component\HttpKernel\DataCollector\DataCollector; + use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; - class RequestCollector extends DataCollector + class RequestCollector extends AbstractDataCollector { // ... + public static function getTemplate(): ?string + { + return 'data_collector/template.html.twig'; + } + public function getMethod() { return $this->data['method']; @@ -227,8 +234,9 @@ The ``menu`` and ``panel`` blocks are the only required blocks to define the contents displayed in the web profiler panel associated with this data collector. All blocks have access to the ``collector`` object. -Finally, to enable the data collector template, override your service configuration -to specify a tag that contains the template: +That's it ! Your data collector is now accessible in the toolbar. + +If you don't use the default configuration with :ref:`autowire and autoconfigure `, you'll need to configure the data collector explicitely: .. configuration-block:: @@ -240,9 +248,8 @@ to specify a tag that contains the template: tags: - name: data_collector - template: 'data_collector/template.html.twig' # must match the value returned by the getName() method - id: 'app.request_collector' + id: 'App\DataCollector\RequestCollector' # optional priority # priority: 300 @@ -259,8 +266,7 @@ to specify a tag that contains the template: @@ -277,10 +283,8 @@ to specify a tag that contains the template: $services = $configurator->services(); $services->set(RequestCollector::class) - ->autowire() ->tag('data_collector', [ - 'template' => 'data_collector/template.html.twig', - 'id' => 'app.request_collector', + 'id' => RequestCollector::class, // 'priority' => 300, ]); }; @@ -289,3 +293,12 @@ The position of each panel in the toolbar is determined by the collector priorit Priorities are defined as positive or negative integers and they default to ``0``. Most built-in collectors use ``255`` as their priority. If you want your collector to be displayed before them, use a higher value (like 300). + +.. versionadded:: 5.2 + + :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector` was introduced in Symfony 5.2. + +.. note:: + + Before the introduction of :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector`, template path was defined in the service configuration (`template` key). This is still possible to define the template in the service configuration. In this case **template in service configuration takes precedence over template defined in data collector code**. + From 5892dfb9876233188cd94a9bd21cb28bbed7170c Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Mon, 17 Aug 2020 15:22:30 +0200 Subject: [PATCH 391/752] Fix debug:container command --- 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 2150bbb487a..2b6ad5f5e1b 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -336,7 +336,7 @@ the compiling and warming up of the container: .. code-block:: terminal - $ debug:container --deprecations + $ php bin/console debug:container --deprecations .. versionadded:: 5.1 From 0025c0645f5cbdeb1090c883ae5513ca0c8b7ab7 Mon Sep 17 00:00:00 2001 From: Tomas Date: Tue, 18 Aug 2020 10:38:41 +0300 Subject: [PATCH 392/752] Fix inconsistent security docs --- security/form_login.rst | 9 +++++---- security/guard_authentication.rst | 9 +++++---- security/json_login_setup.rst | 18 ++++++++++-------- security/multiple_guard_authenticators.rst | 18 ++++++++++-------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/security/form_login.rst b/security/form_login.rst index 4dcd039e347..06d7e22c500 100644 --- a/security/form_login.rst +++ b/security/form_login.rst @@ -28,7 +28,8 @@ First, enable ``form_login`` under your firewall: firewalls: main: - anonymous: lazy + anonymous: true + lazy: true form_login: login_path: login check_path: login @@ -46,8 +47,7 @@ First, enable ``form_login`` under your firewall: https://symfony.com/schema/dic/security/security-1.0.xsd"> - - + @@ -59,7 +59,8 @@ First, enable ``form_login`` under your firewall: $container->loadFromExtension('security', [ 'firewalls' => [ 'main' => [ - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'form_login' => [ 'login_path' => 'login', 'check_path' => 'login', diff --git a/security/guard_authentication.rst b/security/guard_authentication.rst index d88bea0de20..9245faace34 100644 --- a/security/guard_authentication.rst +++ b/security/guard_authentication.rst @@ -189,7 +189,8 @@ Finally, configure your ``firewalls`` key in ``security.yaml`` to use this authe # ... main: - anonymous: lazy + anonymous: true + lazy: true logout: ~ guard: @@ -217,8 +218,7 @@ Finally, configure your ``firewalls`` key in ``security.yaml`` to use this authe - - + @@ -241,7 +241,8 @@ Finally, configure your ``firewalls`` key in ``security.yaml`` to use this authe 'firewalls' => [ 'main' => [ 'pattern' => '^/', - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'logout' => true, 'guard' => [ 'authenticators' => [ diff --git a/security/json_login_setup.rst b/security/json_login_setup.rst index 44ffa5d02e9..b304286bc30 100644 --- a/security/json_login_setup.rst +++ b/security/json_login_setup.rst @@ -17,7 +17,8 @@ First, enable the JSON login under your firewall: firewalls: main: - anonymous: lazy + anonymous: true + lazy: true json_login: check_path: /login @@ -34,8 +35,7 @@ First, enable the JSON login under your firewall: https://symfony.com/schema/dic/security/security-1.0.xsd"> - - + @@ -47,7 +47,8 @@ First, enable the JSON login under your firewall: $container->loadFromExtension('security', [ 'firewalls' => [ 'main' => [ - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'json_login' => [ 'check_path' => '/login', ], @@ -165,7 +166,8 @@ The security configuration should be: firewalls: main: - anonymous: lazy + anonymous: true + lazy: true json_login: check_path: login username_path: security.credentials.login @@ -184,8 +186,7 @@ The security configuration should be: https://symfony.com/schema/dic/security/security-1.0.xsd"> - - + @@ -199,7 +200,8 @@ The security configuration should be: $container->loadFromExtension('security', [ 'firewalls' => [ 'main' => [ - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'json_login' => [ 'check_path' => 'login', 'username_path' => 'security.credentials.login', diff --git a/security/multiple_guard_authenticators.rst b/security/multiple_guard_authenticators.rst index d3ef59a2494..b6ea9ca5f11 100644 --- a/security/multiple_guard_authenticators.rst +++ b/security/multiple_guard_authenticators.rst @@ -27,7 +27,8 @@ This is how your security configuration can look in action: # ... firewalls: default: - anonymous: lazy + anonymous: true + lazy: true guard: authenticators: - App\Security\LoginFormAuthenticator @@ -48,8 +49,7 @@ This is how your security configuration can look in action: - - + App\Security\LoginFormAuthenticator App\Security\FacebookConnectAuthenticator @@ -68,7 +68,8 @@ This is how your security configuration can look in action: // ... 'firewalls' => [ 'default' => [ - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'guard' => [ 'entry_point' => LoginFormAuthenticator::class, 'authenticators' => [ @@ -105,7 +106,8 @@ the solution is to split the configuration into two separate firewalls: authenticators: - App\Security\ApiTokenAuthenticator default: - anonymous: lazy + anonymous: true + lazy: true guard: authenticators: - App\Security\LoginFormAuthenticator @@ -133,8 +135,7 @@ the solution is to split the configuration into two separate firewalls: App\Security\ApiTokenAuthenticator - - + App\Security\LoginFormAuthenticator @@ -163,7 +164,8 @@ the solution is to split the configuration into two separate firewalls: ], ], 'default' => [ - 'anonymous' => 'lazy', + 'anonymous' => true, + 'lazy' => true, 'guard' => [ 'authenticators' => [ LoginFormAuthenticator::class, From 8586afa9600590ff900fd26926ba39f0b0dce146 Mon Sep 17 00:00:00 2001 From: Thibaut Cheymol Date: Tue, 18 Aug 2020 09:14:14 +0200 Subject: [PATCH 393/752] [Mailer] Add documentation for Mailjet mailer --- mailer.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/mailer.rst b/mailer.rst index 7f22f370dcf..3bb13432a36 100644 --- a/mailer.rst +++ b/mailer.rst @@ -45,6 +45,7 @@ Amazon SES ``composer require symfony/amazon-mailer`` Gmail ``composer require symfony/google-mailer`` MailChimp ``composer require symfony/mailchimp-mailer`` Mailgun ``composer require symfony/mailgun-mailer`` +Mailjet ``composer require symfony/mailjet-mailer`` Postmark ``composer require symfony/postmark-mailer`` SendGrid ``composer require symfony/sendgrid-mailer`` ================== ============================================= @@ -86,16 +87,17 @@ transport, but you can force to use one: This table shows the full list of available DNS formats for each third party provider: -==================== ========================================== =========================================== ======================================== - Provider SMTP HTTP API -==================== ========================================== =========================================== ======================================== - Amazon SES ses+smtp://ACCESS_KEY:SECRET_KEY@default ses+https://ACCESS_KEY:SECRET_KEY@default ses+api://ACCESS_KEY:SECRET_KEY@default - Google Gmail gmail+smtp://USERNAME:PASSWORD@default n/a n/a - Mailchimp Mandrill mandrill+smtp://USERNAME:PASSWORD@default mandrill+https://KEY@default mandrill+api://KEY@default - Mailgun mailgun+smtp://USERNAME:PASSWORD@default mailgun+https://KEY:DOMAIN@default mailgun+api://KEY:DOMAIN@default - Postmark postmark+smtp://ID:ID@default n/a postmark+api://KEY@default - Sendgrid sendgrid+smtp://apikey:KEY@default n/a sendgrid+api://KEY@default -==================== ========================================== =========================================== ======================================== +==================== ============================================= =========================================== ======================================== + Provider SMTP HTTP API +==================== ============================================= =========================================== ======================================== + Amazon SES ses+smtp://ACCESS_KEY:SECRET_KEY@default ses+https://ACCESS_KEY:SECRET_KEY@default ses+api://ACCESS_KEY:SECRET_KEY@default + Google Gmail gmail+smtp://USERNAME:PASSWORD@default n/a n/a + Mailchimp Mandrill mandrill+smtp://USERNAME:PASSWORD@default mandrill+https://KEY@default mandrill+api://KEY@default + Mailgun mailgun+smtp://USERNAME:PASSWORD@default mailgun+https://KEY:DOMAIN@default mailgun+api://KEY:DOMAIN@default + Mailjet mailjet+smtp://ACCESS_KEY:SECRET_KEY@default n/a mailjet+api://ACCESS_KEY:SECRET_KEY@default + Postmark postmark+smtp://ID:ID@default n/a postmark+api://KEY@default + Sendgrid sendgrid+smtp://apikey:KEY@default n/a sendgrid+api://KEY@default +==================== ============================================= =========================================== ======================================== .. caution:: From 0bf59205ecd7aa4e93797f9e78154409ad0e6e54 Mon Sep 17 00:00:00 2001 From: noniagriconomie Date: Wed, 12 Aug 2020 11:26:56 +0200 Subject: [PATCH 394/752] Fix package name modified post merge --- notifier.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/notifier.rst b/notifier.rst index c1b6ebfabe5..a6a8a32d9aa 100644 --- a/notifier.rst +++ b/notifier.rst @@ -54,15 +54,15 @@ to send SMS messages to mobile phones. This feature requires subscribing to a third-party service that sends SMS messages. Symfony provides integration with a couple popular SMS services: -========== =============================== ==================================================== -Service Package DSN -========== =============================== ==================================================== -Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` -Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` -OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` -Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` -FreeMobile ``symfony/freemobile-notifier`` ``freemobile://LOGIN:PASS@default?phone=PHONE`` -========== =============================== ==================================================== +========== ================================ ==================================================== +Service Package DSN +========== ================================ ==================================================== +Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` +Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` +OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` +Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` +FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` +========== ================================ ==================================================== .. versionadded:: 5.1 From 2fdc9caeb4649af80539f1f89ec7a9f9f6e95152 Mon Sep 17 00:00:00 2001 From: Mohammad Emran Hasan Date: Thu, 30 Apr 2020 15:42:31 +0600 Subject: [PATCH 395/752] [Notifier] Add Zulip entry --- notifier.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/notifier.rst b/notifier.rst index f832cd01780..daba65356de 100644 --- a/notifier.rst +++ b/notifier.rst @@ -125,14 +125,15 @@ The chat channel is used to send chat messages to users by using :class:`Symfony\\Component\\Notifier\\Chatter` classes. Symfony provides integration with these chat services: -========== =============================== ============================================ +========== =============================== ================================================= Service Package DSN -========== =============================== ============================================ +========== =============================== ================================================= Slack ``symfony/slack-notifier`` ``slack://default/ID`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` -========== =============================== ============================================ +Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` +========== =============================== ================================================= .. versionadded:: 5.1 @@ -140,6 +141,10 @@ RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?chann 5.1. The Slack DSN changed in Symfony 5.1 to use Slack Incoming Webhooks instead of legacy tokens. +.. versionadded:: 5.2 + + The Zulip integration was introduced in Symfony 5.2. + Chatters are configured using the ``chatter_transports`` setting: .. code-block:: bash From e1c774bab6c795e5a1938cab9734d1142168b8d0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Fri, 21 Aug 2020 17:03:31 +0200 Subject: [PATCH 396/752] [#13716] add versionadded directive --- notifier.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/notifier.rst b/notifier.rst index 380e3000610..13aa4c51246 100644 --- a/notifier.rst +++ b/notifier.rst @@ -69,6 +69,10 @@ Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM` The OvhCloud, Sinch and FreeMobile integrations were introduced in Symfony 5.1. +.. versionadded:: 5.2 + + The Smsapi integration was introduced in Symfony 5.2. + To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From bc29b4c0048d176fa1a939b976564cc694dd1cb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Fri, 7 Aug 2020 12:46:23 +0200 Subject: [PATCH 397/752] [Notifier] Adjust notifier documentation --- notifier.rst | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/notifier.rst b/notifier.rst index 80e15e1042d..c4ab9fd660e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -338,7 +338,7 @@ To send a notification, autowire the use Symfony\Component\Notifier\Notification\Notification; use Symfony\Component\Notifier\NotifierInterface; - use Symfony\Component\Notifier\Recipient\AdminRecipient; + use Symfony\Component\Notifier\Recipient\Recipient; class InvoiceController extends AbstractController { @@ -355,7 +355,7 @@ To send a notification, autowire the ->content('You got a new invoice for 15 EUR.'); // The receiver of the Notification - $recipient = new AdminRecipient( + $recipient = new Recipient( $user->getEmail(), $user->getPhonenumber() ); @@ -375,7 +375,7 @@ both an email and sms notification to the user. The default notification also has a ``content()`` and ``emoji()`` method to set the notification content and icon. -Symfony provides three types of recipients: +Symfony provides the following recipients: :class:`Symfony\\Component\\Notifier\\Recipient\\NoRecipient` This is the default and is useful when there is no need to have @@ -383,14 +383,15 @@ Symfony provides three types of recipients: the current requests's :ref:`session flashbag `; :class:`Symfony\\Component\\Notifier\\Recipient\\Recipient` - This contains only the email address of the user and can be used for - messages on the email and browser channel; - -:class:`Symfony\\Component\\Notifier\\Recipient\\AdminRecipient` This can contain both email address and phonenumber of the user. This recipient can be used for all channels (depending on whether they are actually set). +.. versionadded:: 5.2 + + The ``AdminRecipient`` class was removed in Symfony 5.2, you should use + ``Recipient`` instead. + Configuring Channel Policies ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -505,7 +506,8 @@ very high and the recipient has a phone number:: namespace App\Notifier; use Symfony\Component\Notifier\Notification\Notification; - use Symfony\Component\Notifier\Recipient\Recipient; + use Symfony\Component\Notifier\Recipient\RecipientInterface; + use Symfony\Component\Notifier\Recipient\SmsRecipientInterface; class InvoiceNotification extends Notification { @@ -516,12 +518,11 @@ very high and the recipient has a phone number:: $this->price = $price; } - public function getChannels(Recipient $recipient) + public function getChannels(RecipientInterface $recipient) { if ( $this->price > 10000 - && $recipient instanceof AdminRecipient - && null !== $recipient->getPhone() + && $recipient instanceof SmsRecipientInterface ) { return ['sms']; } @@ -545,7 +546,7 @@ and its ``asChatMessage()`` method:: use Symfony\Component\Notifier\Message\ChatMessage; use Symfony\Component\Notifier\Notification\ChatNotificationInterface; use Symfony\Component\Notifier\Notification\Notification; - use Symfony\Component\Notifier\Recipient\Recipient; + use Symfony\Component\Notifier\Recipient\SmsRecipientInterface; class InvoiceNotification extends Notification implements ChatNotificationInterface { @@ -556,7 +557,7 @@ and its ``asChatMessage()`` method:: $this->price = $price; } - public function asChatMessage(Recipient $recipient, string $transport = null): ?ChatMessage + public function asChatMessage(RecipientInterface $recipient, string $transport = null): ?ChatMessage { // Add a custom emoji if the message is sent to Slack if ('slack' === $transport) { From 7bfacde00a13c34fe94370d80109ce2b531eca35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20TAMARELLE?= Date: Fri, 31 Jul 2020 18:53:14 +0200 Subject: [PATCH 398/752] [Notifier] Add GoogleChat to the list of supported chat transports --- notifier.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/notifier.rst b/notifier.rst index cbb9ce65dc2..a3d21bb3f76 100644 --- a/notifier.rst +++ b/notifier.rst @@ -133,15 +133,16 @@ The chat channel is used to send chat messages to users by using :class:`Symfony\\Component\\Notifier\\Chatter` classes. Symfony provides integration with these chat services: -========== =============================== ================================================= +========== =============================== ============================================================================ Service Package DSN -========== =============================== ================================================= +========== =============================== ============================================================================ Slack ``symfony/slack-notifier`` ``slack://default/ID`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` +GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` -========== =============================== ================================================= +========== =============================== ============================================================================ .. versionadded:: 5.1 @@ -151,7 +152,7 @@ Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?cha .. versionadded:: 5.2 - The Zulip integration was introduced in Symfony 5.2. + The GoogleChat and Zulip integrations were introduced in Symfony 5.2. Chatters are configured using the ``chatter_transports`` setting: From e7bc75f4eca455a4484f8060a8d15dd4d800d9cc Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 22 Aug 2020 13:18:40 +0200 Subject: [PATCH 399/752] fix table markup --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 488db6b878b..bb1aa53fb6c 100644 --- a/notifier.rst +++ b/notifier.rst @@ -55,7 +55,7 @@ a third-party service that sends SMS messages. Symfony provides integration with a couple popular SMS services: ========== ================================ ==================================================== -Service Package DSN +Service Package DSN ========== ================================ ==================================================== Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` From 157a21b47f1ce91fe741db3994315674adbca5d6 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 22 Aug 2020 13:34:41 +0200 Subject: [PATCH 400/752] fix table markup --- notifier.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notifier.rst b/notifier.rst index bb1aa53fb6c..858deeacfee 100644 --- a/notifier.rst +++ b/notifier.rst @@ -133,16 +133,16 @@ The chat channel is used to send chat messages to users by using :class:`Symfony\\Component\\Notifier\\Chatter` classes. Symfony provides integration with these chat services: -========== =============================== ============================================================================ -Service Package DSN -========== =============================== ============================================================================ +========== ================================ ============================================================================ +Service Package DSN +========== ================================ ============================================================================ Slack ``symfony/slack-notifier`` ``slack://default/ID`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` -========== =============================== ============================================================================ +========== ================================ ============================================================================ .. versionadded:: 5.1 From ff655425243bf4a0a584168a06ec755942c214dd Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sat, 22 Aug 2020 13:54:42 +0200 Subject: [PATCH 401/752] finally fix the table markup --- notifier.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/notifier.rst b/notifier.rst index 858deeacfee..32455105550 100644 --- a/notifier.rst +++ b/notifier.rst @@ -136,12 +136,12 @@ integration with these chat services: ========== ================================ ============================================================================ Service Package DSN ========== ================================ ============================================================================ -Slack ``symfony/slack-notifier`` ``slack://default/ID`` -Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` +Slack ``symfony/slack-notifier`` ``slack://default/ID`` +Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` -Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` -RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` -Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` +Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` +RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` +Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` ========== ================================ ============================================================================ .. versionadded:: 5.1 From b7928e520f0057542a4743d95447fc1e9b2bbb17 Mon Sep 17 00:00:00 2001 From: tambait Date: Tue, 25 Aug 2020 13:35:36 +0200 Subject: [PATCH 402/752] [Notifier] Fix wrong package name for the RocketChat service --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index a6a8a32d9aa..be0a87937d9 100644 --- a/notifier.rst +++ b/notifier.rst @@ -134,7 +134,7 @@ Service Package DSN Slack ``symfony/slack-notifier`` ``slack://default/ID`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` -RocketChat ``symfony/rocketchat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` +RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` ========== =============================== ============================================ .. versionadded:: 5.1 From 0847c868631ad49c964eba2b0414f61bc2f170f6 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 25 Aug 2020 14:19:07 +0200 Subject: [PATCH 403/752] Fix: Indention --- notifier.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/notifier.rst b/notifier.rst index eb204af9067..4dafd6d63b6 100644 --- a/notifier.rst +++ b/notifier.rst @@ -57,12 +57,12 @@ with a couple popular SMS services: ========== ================================ ==================================================== Service Package DSN ========== ================================ ==================================================== -Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` -Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` -OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` -Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` -FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` -Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` +Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` +Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` +OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` +Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` +FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` +Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` ========== ================================ ==================================================== .. versionadded:: 5.1 From f526431fe423a0a7e3e6ffc4c3e2ddb4d515f112 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 25 Aug 2020 18:17:03 +0200 Subject: [PATCH 404/752] fix table markup --- notifier.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/notifier.rst b/notifier.rst index be0a87937d9..7aab8e37de0 100644 --- a/notifier.rst +++ b/notifier.rst @@ -128,14 +128,14 @@ The chat channel is used to send chat messages to users by using :class:`Symfony\\Component\\Notifier\\Chatter` classes. Symfony provides integration with these chat services: -========== =============================== ============================================ -Service Package DSN -========== =============================== ============================================ -Slack ``symfony/slack-notifier`` ``slack://default/ID`` -Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` -Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` -RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` -========== =============================== ============================================ +========== ================================ ============================================ +Service Package DSN +========== ================================ ============================================ +Slack ``symfony/slack-notifier`` ``slack://default/ID`` +Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` +Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` +RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` +========== ================================ ============================================ .. versionadded:: 5.1 From 883dc985a43b826528a37a7721a1c2754104dc5e Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Sat, 15 Aug 2020 18:52:12 +0200 Subject: [PATCH 405/752] RedisTagAwareAdapter integration --- cache.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cache.rst b/cache.rst index d29265d5f7f..1cb422990c3 100644 --- a/cache.rst +++ b/cache.rst @@ -102,6 +102,11 @@ The Cache component comes with a series of adapters pre-configured: * :doc:`cache.adapter.pdo ` * :doc:`cache.adapter.psr6 ` * :doc:`cache.adapter.redis ` +* :ref:`cache.adapter.redis_tag_aware ` (Redis adapter optimized to work with tags) + +.. versionadded:: 5.2 + + ``cache.adapter.redis_tag_aware`` has been introduced in Symfony 5.2. Some of these adapters could be configured via shortcuts. Using these shortcuts will create pools with service IDs that follow the pattern ``cache.[type]``. From 8631322f7e0144b0ff11cb5c0df29ed053e5d52e Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Tue, 25 Aug 2020 17:39:42 +0200 Subject: [PATCH 406/752] [PropertyAccess] Allow to disable magic __get & __set --- components/property_access.rst | 34 +++++++++++++++++++++------ reference/configuration/framework.rst | 28 ++++++++++++++++++++++ 2 files changed, 55 insertions(+), 7 deletions(-) diff --git a/components/property_access.rst b/components/property_access.rst index df0f3d99b51..7c8390f9a24 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -191,6 +191,8 @@ method:: $value = $propertyAccessor->getValue($person, 'birthday'); +.. _components-property-access-magic-get: + Magic ``__get()`` Method ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -213,6 +215,11 @@ The ``getValue()`` method can also use the magic ``__get()`` method:: var_dump($propertyAccessor->getValue($person, 'Wouter')); // [...] +.. versionadded:: 5.2 + + The magic `__get` method can be disabled since in Symfony 5.2. + see `Enable other Features`_. + .. _components-property-access-magic-call: Magic ``__call()`` Method @@ -273,6 +280,8 @@ also write to an array. This can be achieved using the // or // var_dump($person['first_name']); // 'Wouter' +.. _components-property-access-writing-to-objects: + Writing to Objects ------------------ @@ -351,6 +360,11 @@ see `Enable other Features`_:: var_dump($person->getWouter()); // [...] +.. versionadded:: 5.2 + + The magic `__set` method can be disabled since in Symfony 5.2. + see `Enable other Features`_. + Writing to Array Properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -461,14 +475,20 @@ configured to enable extra features. To do that you could use the // ... $propertyAccessorBuilder = PropertyAccess::createPropertyAccessorBuilder(); - // enables magic __call - $propertyAccessorBuilder->enableMagicCall(); + $propertyAccessorBuilder->enableMagicCall(); // enables magic __call + $propertyAccessorBuilder->enableMagicGet(); // enables magic __get + $propertyAccessorBuilder->enableMagicSet(); // enables magic __set + $propertyAccessorBuilder->enableMagicMethods(); // enables magic __get, __set and __call - // disables magic __call - $propertyAccessorBuilder->disableMagicCall(); + $propertyAccessorBuilder->disableMagicCall(); // enables magic __call + $propertyAccessorBuilder->disableMagicGet(); // enables magic __get + $propertyAccessorBuilder->disableMagicSet(); // enables magic __set + $propertyAccessorBuilder->disableMagicMethods(); // enables magic __get, __set and __call - // checks if magic __call handling is enabled + // checks if magic __call, __get or __set handling are enabled $propertyAccessorBuilder->isMagicCallEnabled(); // true or false + $propertyAccessorBuilder->isMagicGetEnabled(); // true or false + $propertyAccessorBuilder->isMagicSetEnabled(); // true or false // At the end get the configured property accessor $propertyAccessor = $propertyAccessorBuilder->getPropertyAccessor(); @@ -480,7 +500,7 @@ configured to enable extra features. To do that you could use the Or you can pass parameters directly to the constructor (not the recommended way):: - // ... - $propertyAccessor = new PropertyAccessor(true); // this enables handling of magic __call + // enable handling of magic __call, __set but not __get: + $propertyAccessor = new PropertyAccessor(PropertyAccessor::MAGIC_CALL | PropertyAccessor::MAGIC_SET); .. _The Inflector component: https://github.com/symfony/inflector diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 6c64626f07a..3db77d3c328 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -167,6 +167,8 @@ Configuration * `property_access`_ * `magic_call`_ + * `magic_get`_ + * `magic_set`_ * `throw_exception_on_invalid_index`_ * `throw_exception_on_invalid_property_path`_ @@ -2127,6 +2129,32 @@ When enabled, the ``property_accessor`` service uses PHP's :ref:`magic __call() method ` when its ``getValue()`` method is called. +magic_get +......... + +**type**: ``boolean`` **default**: ``true`` + +When enabled, the ``property_accessor`` service uses PHP's +:ref:`magic __get() method ` when +its ``getValue()`` method is called. + +.. versionadded:: 5.2 + + The magic `magic_get` option was introduced in Symfony 5.2. + +magic_set +......... + +**type**: ``boolean`` **default**: ``true`` + +When enabled, the ``property_accessor`` service uses PHP's +:ref:`magic __set() method ` when +its ``setValue()`` method is called. + +.. versionadded:: 5.2 + + The magic `magic_set` option was introduced in Symfony 5.2. + throw_exception_on_invalid_index ................................ From 27f13a880fe9c46140763207a56caf36a862940a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 26 Aug 2020 10:56:09 +0200 Subject: [PATCH 407/752] Change the way to create table in Lock PDO --- components/lock.rst | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index cc14aa01334..95734c22c2e 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -350,25 +350,11 @@ support blocking, and expects a TTL to avoid stalled locks:: This store does not support TTL lower than 1 second. -Before storing locks in the database, you must create the table that stores -the information. The store provides a method called -:method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable` -to set up this table for you according to the database engine used:: - - try { - $store->createTable(); - } catch (\PDOException $exception) { - // the table could not be created for some reason - } - -A great way to set up the table in production is to call the ``createTable()`` -method in your local computer and then generate a -:ref:`database migration `: - -.. code-block:: terminal - - $ php bin/console doctrine:migrations:diff - $ php bin/console doctrine:migrations:migrate +The table where values are stored is created automatically on the first call to +the :method:`Symfony\\Component\\Lock\\Store\\PdoStore::save` method. +You can also create this table explicitly by calling the +:method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable` method in +your code. .. _lock-store-redis: From 6d37db16e3fce3965d4dbd644e21980801cab66b Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 26 Aug 2020 11:21:55 +0200 Subject: [PATCH 408/752] minor #14055 --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index 0b675a67a60..188ba1d8fba 100644 --- a/routing.rst +++ b/routing.rst @@ -1881,7 +1881,7 @@ Now, if the session is used, the application will report it based on your * ``enabled``: will throw an :class:`Symfony\\Component\\HttpKernel\\Exception\\UnexpectedSessionUsageException` exception * ``disabled``: will log a warning -It will help you in understanding and hopefully fixing unexpected behavior in your application. +It will help you understand and hopefully fixing unexpected behavior in your application. .. _routing-generating-urls: From 9a74dce178cbacaee4dacda8b6b3113ebf776d8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 26 Aug 2020 12:44:50 +0200 Subject: [PATCH 409/752] Document RecoverableMessageHandlingException --- messenger.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/messenger.rst b/messenger.rst index f334ae66b89..ff43fd0ec08 100644 --- a/messenger.rst +++ b/messenger.rst @@ -725,6 +725,15 @@ and should not be retried. If you throw :class:`Symfony\\Component\\Messenger\\Exception\\UnrecoverableMessageHandlingException`, the message will not be retried. + +Forcing Retrying +~~~~~~~~~~~~~~~~ + +Sometimes handling a message must fail in a way that you *know* is temporary +and must be retried. If you throw +:class:`Symfony\\Component\\Messenger\\Exception\\RecoverableMessageHandlingException`, +the message will always be retried. + .. _messenger-failure-transport: Saving & Retrying Failed Messages From 5f6f585aec060aff8fe6571daeb4ca1eb7e29286 Mon Sep 17 00:00:00 2001 From: Gary PEGEOT Date: Fri, 28 Aug 2020 11:39:19 +0200 Subject: [PATCH 410/752] [HTTP_CLIENT] Add documentation for "mock_response_factory" --- http_client.rst | 76 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/http_client.rst b/http_client.rst index 33e6c9732dd..5eb3b09f711 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1373,6 +1373,82 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts $mockResponse = new MockResponse($body()); +Using the Symfony Framework, if you want to use your callback in functional tests, you can do as follow: + +First, create an invokable or iterable class responsible of generating the response:: + + namespace App\Tests; + + use Symfony\Contracts\HttpClient\ResponseInterface; + use Symfony\Component\HttpClient\Response\MockResponse; + + class MockClientCallback + { + public function __invoke(string $method, string $url, array $options = []): ResponseInterface + { + // load a fixture file or generate data + // ... + return new MockResponse($data); + } + } + +Then configure the framework to use your callback: + +.. configuration-block:: + + .. code-block:: yaml + + # config/services_test.yaml + services: + # ... + App\Tests\MockClientCallback: ~ + + # config/packages/test/framework.yaml + framework: + http_client: + mock_response_factory: App\Tests\MockClientCallback + + .. code-block:: xml + + + + + + + + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + $container->loadFromExtension('framework', [ + 'http_client' => [ + 'mock_response_factory' => MockClientCallback::class, + ], + ]); + + +The ``MockHttpClient`` will now be used in test environment with your callback to generate responses. + .. _`cURL PHP extension`: https://www.php.net/curl .. _`PSR-17`: https://www.php-fig.org/psr/psr-17/ .. _`PSR-18`: https://www.php-fig.org/psr/psr-18/ From 6a3b3554a7d3163a8199d740903558040e828c57 Mon Sep 17 00:00:00 2001 From: Valentin Date: Fri, 28 Aug 2020 23:42:48 +0200 Subject: [PATCH 411/752] [Serializer] Add an @Ignore annotation #28744 Update serializer.rst Update components/serializer.rst Co-authored-by: Oskar Stark Update components/serializer.rst Co-authored-by: Antoine Makdessi Update components/serializer.rst Co-authored-by: Antoine Makdessi Update components/serializer.rst Co-authored-by: Oskar Stark Update components/serializer.rst Co-authored-by: Antoine Makdessi Update serializer.rst --- components/serializer.rst | 77 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index ef205bf59be..b3735deb32a 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -413,8 +413,81 @@ As for groups, attributes can be selected during both the serialization and dese Ignoring Attributes ------------------- -As an option, there's a way to ignore attributes from the origin object. -To remove those attributes provide an array via the ``AbstractNormalizer::IGNORED_ATTRIBUTES`` +All attributes are included by default when serializing objects. You have two alternatives to ignore some of those attributes. + +* `Option 1: Using @Ignore annotation`_ +* `Option 2: Using the context`_ + +Option 1: Using ``@Ignore`` annotation +-------------------------------------- + +.. configuration-block:: + + .. code-block:: php-annotations + + namespace App\Model; + + use Symfony\Component\Serializer\Annotation\Ignore; + + class MyClass + { + public $foo; + + /** + * @Ignore() + */ + public $bar; + } + + .. code-block:: yaml + + App\Model\MyClass: + attributes: + foo: + ignore: false + bar: + ignore: true + + .. code-block:: xml + + + + + + false + + + + true + + + + +You are now able to ignore specific attributes during serialization:: + + use App\Model\MyClass; + use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; + use Symfony\Component\Serializer\Serializer; + + $obj = new MyClass(); + $obj->foo = 'foo'; + $obj->bar = 'bar'; + + $normalizer = new ObjectNormalizer($classMetadataFactory); + $serializer = new Serializer([$normalizer]); + + $data = $serializer->normalize($obj); + // $data = ['foo' => 'foo']; + + +Option 2: Using the context +--------------------------- + +By providing an array via the ``AbstractNormalizer::IGNORED_ATTRIBUTES`` key in the ``context`` parameter of the desired serializer method:: use Acme\Person; From 57cfedbfd15ebd7f65e76f847dd86f22164829be Mon Sep 17 00:00:00 2001 From: Stewart Malik Date: Sun, 23 Aug 2020 18:35:49 +0930 Subject: [PATCH 412/752] [Workflow] Choose which Workflow events should be dispatched --- workflow.rst | 169 ++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 159 insertions(+), 10 deletions(-) diff --git a/workflow.rst b/workflow.rst index 21ae4192d58..c44b821b3ce 100644 --- a/workflow.rst +++ b/workflow.rst @@ -351,14 +351,6 @@ order: * ``workflow.[workflow name].announce`` * ``workflow.[workflow name].announce.[transition name]`` - You can avoid triggering those events by using the context:: - - $workflow->apply($subject, $transitionName, [Workflow::DISABLE_ANNOUNCE_EVENT => true]); - - .. versionadded:: 5.1 - - The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1. - .. note:: The leaving and entering events are triggered even for transitions that stay @@ -452,6 +444,163 @@ missing a title:: The optional second argument of ``setBlocked()`` was introduced in Symfony 5.1. +Choosing which Events to Dispatch +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + Ability to choose which events to dispatch was introduced in Symfony 5.2. + +You are able to specify which events (does not apply to Guard event) will be +fired when performing each transition by passing an array of workflow events +to the ``events_to_dispatch`` configuration option. + +Valid options for ``events_to_dispatch`` are: + + * ``null`` - all events are dispatched + * ``[]`` - no events are dispatched + * ``['workflow.leave', 'workflow.completed']`` - only specific events are dispatched + +.. note:: + + Guard Events are still dispatched in all instances. + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/workflow.yaml + framework: + workflows: + blog_publishing: + # ... + events_to_dispatch: ['workflow.leave', 'workflow.completed'] + # ... + + .. code-block:: xml + + + + + + + + workflow.leave + workflow.completed + + + + + + .. code-block:: php + + // config/packages/workflow.php + $container->loadFromExtension('framework', [ + // ... + 'workflows' => [ + 'blog_publishing' => [ + // ... + 'events_to_dispatch' => [ + 'workflow.leave', + 'workflow.completed', + ], + // ... + ], + ], + ]); + +To specify that no events will be dispatched pass an empty array to the +configuration option. + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/workflow.yaml + framework: + workflows: + blog_publishing: + # ... + events_to_dispatch: [] + # ... + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/workflow.php + $container->loadFromExtension('framework', [ + // ... + 'workflows' => [ + 'blog_publishing' => [ + // ... + 'events_to_dispatch' => [], + // ... + ], + ], + ]); + +You are also able to explicitly disable a specific event from being fired +when applying a transition:: + + use App\Entity\BlogPost; + use Symfony\Component\Workflow\Exception\LogicException; + + $post = new BlogPost(); + + $workflow = $this->container->get('workflow.blog_publishing'); + + try { + $workflow->apply($post, 'to_review', [ + Workflow::DISABLE_ANNOUNCE_EVENT => true, + Workflow::DISABLE_LEAVE_EVENT => true, + ]); + } catch (LogicException $exception) { + // ... + } + +Choosing to disable an event for a specific transition will take precedence +over any events specified in the workflow configuration. In the above example +the ``workflow.leave`` event will not be fired, even if it has been specified +as an event to be dispatched for all transitions in the workflow configuration. + +.. versionadded:: 5.1 + + The ``Workflow::DISABLE_ANNOUNCE_EVENT`` constant was introduced in Symfony 5.1. + +.. versionadded:: 5.2 + + The constants for other events (as seen below) were introduced in Symfony 5.2. + + * ``Workflow::DISABLE_LEAVE_EVENT`` + * ``Workflow::DISABLE_TRANSITION_EVENT`` + * ``Workflow::DISABLE_ENTER_EVENT`` + * ``Workflow::DISABLE_ENTERED_EVENT`` + * ``Workflow::DISABLE_COMPLETED_EVENT`` + Event Methods ~~~~~~~~~~~~~ @@ -665,7 +814,7 @@ of domain logic in your templates: ``workflow_has_marked_place()`` Returns ``true`` if the marking of the given object has the given state. - + ``workflow_transition_blockers()`` Returns :class:`Symfony\\Component\\Workflow\\TransitionBlockerList` for the given transition. @@ -700,7 +849,7 @@ The following example shows these functions in action: {% if 'reviewed' in workflow_marked_places(post) %} Reviewed {% endif %} - + {# Loop through the transition blockers #} {% for blocker in workflow_transition_blockers(post, 'publish') %} {{ blocker.message }} From 237468ee17a8ac1c3ebad7bc278a359ebe86062c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 31 Aug 2020 09:43:11 +0200 Subject: [PATCH 413/752] Tweaks and rewords --- workflow.rst | 90 ++++++++++++---------------------------------------- 1 file changed, 21 insertions(+), 69 deletions(-) diff --git a/workflow.rst b/workflow.rst index c44b821b3ce..4bbd6ee8ccc 100644 --- a/workflow.rst +++ b/workflow.rst @@ -451,19 +451,9 @@ Choosing which Events to Dispatch Ability to choose which events to dispatch was introduced in Symfony 5.2. -You are able to specify which events (does not apply to Guard event) will be -fired when performing each transition by passing an array of workflow events -to the ``events_to_dispatch`` configuration option. - -Valid options for ``events_to_dispatch`` are: - - * ``null`` - all events are dispatched - * ``[]`` - no events are dispatched - * ``['workflow.leave', 'workflow.completed']`` - only specific events are dispatched - -.. note:: - - Guard Events are still dispatched in all instances. +If you prefer to control which events are fired when performing each transition, +use the ``events_to_dispatch`` configuration option. This option does not apply +to :ref:`Guard events `, which are always fired: .. configuration-block:: @@ -473,8 +463,12 @@ Valid options for ``events_to_dispatch`` are: framework: workflows: blog_publishing: - # ... + # you can pass one or more event names events_to_dispatch: ['workflow.leave', 'workflow.completed'] + + # pass an empty array to not dispatch any event + events_to_dispatch: [] + # ... .. code-block:: xml @@ -489,9 +483,13 @@ Valid options for ``events_to_dispatch`` are: > - + workflow.leave workflow.completed + + + + @@ -504,67 +502,21 @@ Valid options for ``events_to_dispatch`` are: // ... 'workflows' => [ 'blog_publishing' => [ - // ... + // you can pass one or more event names 'events_to_dispatch' => [ 'workflow.leave', 'workflow.completed', ], - // ... - ], - ], - ]); - -To specify that no events will be dispatched pass an empty array to the -configuration option. - -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/workflow.yaml - framework: - workflows: - blog_publishing: - # ... - events_to_dispatch: [] - # ... - - .. code-block:: xml - - - - - - - - - - - - - - .. code-block:: php - // config/packages/workflow.php - $container->loadFromExtension('framework', [ - // ... - 'workflows' => [ - 'blog_publishing' => [ - // ... + // pass an empty array to not dispatch any event 'events_to_dispatch' => [], + // ... ], ], ]); -You are also able to explicitly disable a specific event from being fired -when applying a transition:: +You can also disable a specific event from being fired when applying a transition:: use App\Entity\BlogPost; use Symfony\Component\Workflow\Exception\LogicException; @@ -582,10 +534,10 @@ when applying a transition:: // ... } -Choosing to disable an event for a specific transition will take precedence -over any events specified in the workflow configuration. In the above example -the ``workflow.leave`` event will not be fired, even if it has been specified -as an event to be dispatched for all transitions in the workflow configuration. +Disabling an event for a specific transition will take precedence over any +events specified in the workflow configuration. In the above example the +``workflow.leave`` event will not be fired, even if it has been specified as an +event to be dispatched for all transitions in the workflow configuration. .. versionadded:: 5.1 From e492a64fed530e78bccabd5483d51c983edc128e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 31 Aug 2020 09:47:19 +0200 Subject: [PATCH 414/752] Removed an unneeded versionadded directive --- components/property_info.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index 40b8b94ea77..d67034b04fa 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -293,10 +293,6 @@ string values: ``array``, ``bool``, ``callable``, ``float``, ``int``, Constants inside the :class:`Symfony\\Component\\PropertyInfo\\Type` class, in the form ``Type::BUILTIN_TYPE_*``, are provided for convenience. -.. versionadded:: 4.4 - - Support for typed properties (added in PHP 7.4) was introduced in Symfony 4.4. - ``Type::isNullable()`` ~~~~~~~~~~~~~~~~~~~~~~ From 24c1086aa16a04852c95d170751fc04ab3ca4edd Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 31 Aug 2020 10:29:14 +0200 Subject: [PATCH 415/752] Minor syntax fixes --- components/property_access.rst | 4 ++-- reference/configuration/framework.rst | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/components/property_access.rst b/components/property_access.rst index 7c8390f9a24..c99091c4e15 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -217,7 +217,7 @@ The ``getValue()`` method can also use the magic ``__get()`` method:: .. versionadded:: 5.2 - The magic `__get` method can be disabled since in Symfony 5.2. + The magic ``__get()`` method can be disabled since in Symfony 5.2. see `Enable other Features`_. .. _components-property-access-magic-call: @@ -362,7 +362,7 @@ see `Enable other Features`_:: .. versionadded:: 5.2 - The magic `__set` method can be disabled since in Symfony 5.2. + The magic ``__set()`` method can be disabled since in Symfony 5.2. see `Enable other Features`_. Writing to Array Properties diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 3db77d3c328..e2015e923fa 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2140,7 +2140,7 @@ its ``getValue()`` method is called. .. versionadded:: 5.2 - The magic `magic_get` option was introduced in Symfony 5.2. + The ``magic_get`` option was introduced in Symfony 5.2. magic_set ......... @@ -2153,7 +2153,7 @@ its ``setValue()`` method is called. .. versionadded:: 5.2 - The magic `magic_set` option was introduced in Symfony 5.2. + The ``magic_set`` option was introduced in Symfony 5.2. throw_exception_on_invalid_index ................................ From 74041eeb27f67b1b10b327bc6288df48b7aa5df2 Mon Sep 17 00:00:00 2001 From: Smaine Milianni Date: Wed, 19 Aug 2020 08:51:09 +0100 Subject: [PATCH 416/752] linkedin documentation wip --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 460be529f97..6c19202a77e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -142,6 +142,7 @@ GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_T Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` +LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` ========== ================================ =========================================================================== .. versionadded:: 5.1 @@ -152,7 +153,7 @@ Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?ch .. versionadded:: 5.2 - The GoogleChat and Zulip integrations were introduced in Symfony 5.2. + The GoogleChat, LinkedIn and Zulip integrations were introduced in Symfony 5.2. Chatters are configured using the ``chatter_transports`` setting: From 56be70089e07a3d36c47bf298b1bb065d13f0030 Mon Sep 17 00:00:00 2001 From: Valentin Silvestre <17164385+vasilvestre@users.noreply.github.com> Date: Mon, 31 Aug 2020 11:44:16 +0200 Subject: [PATCH 417/752] Update serializer.rst --- components/serializer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index b3735deb32a..fefa16f55f1 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -419,7 +419,7 @@ All attributes are included by default when serializing objects. You have two al * `Option 2: Using the context`_ Option 1: Using ``@Ignore`` annotation --------------------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. configuration-block:: @@ -485,7 +485,7 @@ You are now able to ignore specific attributes during serialization:: Option 2: Using the context ---------------------------- +~~~~~~~~~~~~~~~~~~~~~~~~~~~ By providing an array via the ``AbstractNormalizer::IGNORED_ATTRIBUTES`` key in the ``context`` parameter of the desired serializer method:: From dcd5b4ce86088786de05a6ee61930137d4746c0e Mon Sep 17 00:00:00 2001 From: Valentin Silvestre <17164385+vasilvestre@users.noreply.github.com> Date: Mon, 31 Aug 2020 14:24:01 +0200 Subject: [PATCH 418/752] Update serializer.rst Remove default value (false) from ignoring rules in XML and YML files as I didn't put them in PHP code. --- components/serializer.rst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index fefa16f55f1..8bc88446651 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -443,8 +443,6 @@ Option 1: Using ``@Ignore`` annotation App\Model\MyClass: attributes: - foo: - ignore: false bar: ignore: true @@ -457,10 +455,6 @@ Option 1: Using ``@Ignore`` annotation https://symfony.com/schema/dic/serializer-mapping/serializer-mapping-1.0.xsd" > - - false - - true From 563206fc4ee10ece5b3808de156dbc37dd26c3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Fri, 28 Aug 2020 16:08:30 +0200 Subject: [PATCH 419/752] [Sempahore] Added first round of documentation --- components/semaphore.rst | 79 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 components/semaphore.rst diff --git a/components/semaphore.rst b/components/semaphore.rst new file mode 100644 index 00000000000..4677b0627ba --- /dev/null +++ b/components/semaphore.rst @@ -0,0 +1,79 @@ +.. index:: + single: Semaphore + single: Components; Semaphore + +The Semaphore Component +======================= + + The Semaphore Component manages `semaphores`_, a mechanism to provide + exclusive access to a shared resource. + +.. versionadded:: 5.2 + + The Semaphore Component was introduced in Symfony 5.2. + +Installation +------------ + +.. code-block:: terminal + + $ composer require symfony/semaphore + +.. include:: /components/require_autoload.rst.inc + +Usage +----- + +Semaphore are used to guarantee exclusive access to some shared resource. + +Semaphore are created using a :class:`Symfony\\Component\\Semaphore\\SemaphoreFactory` class, +which in turn requires another class to manage the storage of Semaphore:: + + use Symfony\Component\Semaphore\SemaphoreFactory; + use Symfony\Component\Semaphore\Store\RedisStore; + + $redis = new Redis(); + $redis->connect('172.17.0.2'); + + $store = new RedisStore($redis); + $factory = new SemaphoreFactory($store); + + +The semaphore is created by calling the +:method:`Symfony\\Component\\Semaphore\\SemaphoreFactory::createSemaphore` +method. Its first argument is an arbitrary string that represents the locked +resource. Its second argument is the number of process allowed. Then, a call to +the :method:`Symfony\\Component\\Semaphore\\SemaphoreInterface::acquire` method +will try to acquire the semaphore:: + + // ... + $semaphore = $factory->createSemaphore('pdf-invoice-generation', 2); + + if ($semaphore->acquire()) { + // The resource "pdf-invoice-generation" is locked. + // You can compute and generate invoice safely here. + + $semaphore->release(); + } + +If the semaphore can not be acquired, the method returns ``false``. The +``acquire()`` method can be safely called repeatedly, even if the semaphore is +already acquired. + +.. note:: + + Unlike other implementations, the Semaphore Component distinguishes + semaphores instances even when they are created for the same resource. If a + semaphore has to be used by several services, they should share the same + ``Semaphore`` instance returned by the ``SemaphoreFactory::createSemaphore`` + method. + +.. tip:: + + If you don't release the semaphore explicitly, it will be released + automatically on instance destruction. In some cases, it can be useful to + lock a resource across several requests. To disable the automatic release + behavior, set the last argument of the ``createLock()`` method to + ``false``. + +.. _`semaphores`: https://en.wikipedia.org/wiki/Semaphore_(programming) From 4188b0a9b642a7e2a6a5cba4df1c1bd796f37b7d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 31 Aug 2020 17:58:13 +0200 Subject: [PATCH 420/752] Minor tweak --- components/console/helpers/table.rst | 66 ++++++++++++++-------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/components/console/helpers/table.rst b/components/console/helpers/table.rst index d50cc160c06..aa4c293d834 100644 --- a/components/console/helpers/table.rst +++ b/components/console/helpers/table.rst @@ -265,6 +265,39 @@ Here is a full list of things you can customize: This method can also be used to override a built-in style. +.. versionadded:: 5.2 + + The option to style table cells was introduced in Symfony 5.2. + +In addition to the built-in table styles, you can also apply different styles +to each table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`:: + + use Symfony\Component\Console\Helper\Table; + use Symfony\Component\Console\Helper\TableCellStyle; + + $table = new Table($output); + + $table->setRows([ + [ + '978-0804169127', + new TableCell( + 'Divine Comedy', + [ + 'style' => new TableCellStyle([ + 'align' => 'center', + 'fg' => 'red', + 'bg' => 'green', + + // or + 'cellFormat' => '%s', + ]) + ] + ) + ], + ]); + + $table->render(); + Spanning Multiple Columns and Rows ---------------------------------- @@ -393,36 +426,3 @@ This will display the following table in the terminal: | Love | | Symfony | +---------+ - -.. versionadded:: 5.2 - -Styling of table cells ----------------------- - -You can customize a table cell via :class:`Symfony\\Component\\Console\\Helper\\TableCellStyle`:: - - use Symfony\Component\Console\Helper\Table; - use Symfony\Component\Console\Helper\TableCellStyle; - - $table = new Table($output); - - $table->setRows([ - [ - '978-0804169127', - new TableCell( - 'Divine Comedy', - [ - 'style' => new TableCellStyle([ - 'align' => 'center', - 'fg' => 'red', - 'bg' => 'green', - - // or - 'cellFormat' => '%s', - ]) - ] - ) - ], - ]); - - $table->render(); From d6331b371dc71e0c730fb397440eb7b53393bd26 Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Tue, 1 Sep 2020 15:22:14 +0200 Subject: [PATCH 421/752] Add documentation about quiet configuration --- components/phpunit_bridge.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 2b6ad5f5e1b..fc7c0d6ae2e 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -296,6 +296,8 @@ By default, the bridge will display a detailed output with the number of deprecations and where they arise. If this is too much for you, you can use ``SYMFONY_DEPRECATIONS_HELPER=verbose=0`` to turn the verbose output off. +It's also possible to change verbosity per deprecation type, for instance ``quiet[]=indirect&quiet[]=other`` will hide details for deprecations of types "indirect" and "other". + Disabling the Deprecation Helper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 3c9e289e31b2cb84f8969a0e36ed9abdaa6ecfc3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 3 Sep 2020 17:51:42 +0200 Subject: [PATCH 422/752] Minor tweak --- components/serializer.rst | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 8bc88446651..6f15604325e 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -413,12 +413,10 @@ As for groups, attributes can be selected during both the serialization and dese Ignoring Attributes ------------------- -All attributes are included by default when serializing objects. You have two alternatives to ignore some of those attributes. +All attributes are included by default when serializing objects. There are two +options to ignore some of those attributes. -* `Option 1: Using @Ignore annotation`_ -* `Option 2: Using the context`_ - -Option 1: Using ``@Ignore`` annotation +Option 1: Using ``@Ignore`` Annotation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. configuration-block:: @@ -461,7 +459,7 @@ Option 1: Using ``@Ignore`` annotation -You are now able to ignore specific attributes during serialization:: +You can now ignore specific attributes during serialization:: use App\Model\MyClass; use Symfony\Component\Serializer\Normalizer\ObjectNormalizer; @@ -477,12 +475,12 @@ You are now able to ignore specific attributes during serialization:: $data = $serializer->normalize($obj); // $data = ['foo' => 'foo']; - -Option 2: Using the context +Option 2: Using the Context ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -By providing an array via the ``AbstractNormalizer::IGNORED_ATTRIBUTES`` -key in the ``context`` parameter of the desired serializer method:: +Pass an array with the names of the attributes to ignore using the +``AbstractNormalizer::IGNORED_ATTRIBUTES`` key in the ``context`` of the +serializer method:: use Acme\Person; use Symfony\Component\Serializer\Encoder\JsonEncoder; @@ -805,7 +803,7 @@ There are several types of normalizers available: :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` Normalizes errors according to the API Problem spec `RFC 7807`_. - + .. _component-serializer-encoders: Encoders From e2989290cf3a28ebcc454d1cb13354116744e5cf Mon Sep 17 00:00:00 2001 From: Zmey Date: Thu, 3 Sep 2020 01:21:08 +0300 Subject: [PATCH 423/752] Added support for using the "{{ label }}" placeholder in constraint messages --- components/form.rst | 5 +++++ forms.rst | 5 +++++ reference/constraints/Blank.rst | 5 +++++ reference/constraints/CardScheme.rst | 5 +++++ reference/constraints/Choice.rst | 5 +++++ reference/constraints/Currency.rst | 5 +++++ reference/constraints/Date.rst | 5 +++++ reference/constraints/DateTime.rst | 5 +++++ reference/constraints/Email.rst | 5 +++++ reference/constraints/Expression.rst | 5 +++++ reference/constraints/Hostname.rst | 5 +++++ reference/constraints/Iban.rst | 5 +++++ reference/constraints/Ip.rst | 5 +++++ reference/constraints/IsFalse.rst | 5 +++++ reference/constraints/IsNull.rst | 5 +++++ reference/constraints/IsTrue.rst | 5 +++++ reference/constraints/Isbn.rst | 20 ++++++++++++++++++++ reference/constraints/Isin.rst | 5 +++++ reference/constraints/Issn.rst | 5 +++++ reference/constraints/Language.rst | 5 +++++ reference/constraints/Locale.rst | 5 +++++ reference/constraints/Luhn.rst | 5 +++++ reference/constraints/NotBlank.rst | 5 +++++ reference/constraints/NotNull.rst | 5 +++++ reference/constraints/Range.rst | 5 +++++ reference/constraints/Regex.rst | 5 +++++ reference/constraints/Time.rst | 5 +++++ reference/constraints/Timezone.rst | 5 +++++ reference/constraints/Type.rst | 5 +++++ reference/constraints/UniqueEntity.rst | 5 +++++ reference/constraints/Url.rst | 5 +++++ reference/constraints/Uuid.rst | 5 +++++ 32 files changed, 175 insertions(+) diff --git a/components/form.rst b/components/form.rst index 7ac59478ceb..cdcf9ee54a8 100644 --- a/components/form.rst +++ b/components/form.rst @@ -728,6 +728,11 @@ and the errors will display next to the fields on error. For a list of all of the built-in validation constraints, see :doc:`/reference/constraints`. +.. versionadded:: 5.2 + + Constraint message can contains ``{{ label }}`` placeholder that will be replaced + by corresponding form field label (in view of ``label_format`` option). + Accessing Form Errors ~~~~~~~~~~~~~~~~~~~~~ diff --git a/forms.rst b/forms.rst index 02336d32169..9ab6b2101ab 100644 --- a/forms.rst +++ b/forms.rst @@ -548,6 +548,11 @@ corresponding errors printed out with the form. Read the :doc:`Symfony validation documentation ` to learn more about this powerful feature. +.. versionadded:: 5.2 + + Constraint message can contains ``{{ label }}`` placeholder that will be replaced + by corresponding form field label (in view of ``label_format`` option). + Other Common Form Features -------------------------- diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 5f0c6191fc1..8a5ba13671a 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -102,6 +102,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 6adfe62d893..64d6157e2c8 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -112,8 +112,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc schemes diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index 707bfd11bc5..fd8481d6152 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -392,6 +392,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 901a989010b..651af1b1a92 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -94,8 +94,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`3-letter ISO 4217`: https://en.wikipedia.org/wiki/ISO_4217 diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index db55de84dd6..4b1e99c3ed1 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -98,6 +98,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index 41b4db2acc0..582f93aeac8 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -107,6 +107,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index ce8d428858a..468051004a0 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -101,8 +101,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + mode ~~~~ diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index f3af00f1d3a..2ed816f3a03 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -260,8 +260,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc values diff --git a/reference/constraints/Hostname.rst b/reference/constraints/Hostname.rst index 4cbe606ccb4..9e67fb3c8fc 100644 --- a/reference/constraints/Hostname.rst +++ b/reference/constraints/Hostname.rst @@ -110,8 +110,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc ``requireTld`` diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index aa3caeb67f8..709270f7b12 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -108,8 +108,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`International Bank Account Number (IBAN)`: https://en.wikipedia.org/wiki/International_Bank_Account_Number diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index 60865c024bc..9d744d54c09 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -95,8 +95,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 861072a1250..17881aa9a75 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -125,6 +125,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsNull.rst b/reference/constraints/IsNull.rst index 2bded13311d..252c23d934b 100644 --- a/reference/constraints/IsNull.rst +++ b/reference/constraints/IsNull.rst @@ -96,6 +96,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index 2066b6d4e73..2698ad233e9 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -129,6 +129,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index d2ad1e2c909..e30d4e96040 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -109,8 +109,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_groups-option.rst.inc isbn10Message @@ -127,8 +132,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + isbn13Message ~~~~~~~~~~~~~ @@ -143,8 +153,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + message ~~~~~~~ @@ -159,8 +174,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc type diff --git a/reference/constraints/Isin.rst b/reference/constraints/Isin.rst index 86c1c3a3973..c646f33a53a 100644 --- a/reference/constraints/Isin.rst +++ b/reference/constraints/Isin.rst @@ -92,8 +92,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`International Securities Identification Number (ISIN)`: https://en.wikipedia.org/wiki/International_Securities_Identification_Number diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index 374cc7d2751..6cc5734aaa2 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -102,8 +102,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc requireHyphen diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index 7d58491c416..dac3e2819db 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -106,8 +106,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`ISO 639-1`: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index dbdf0905df5..f5f381629e3 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -107,8 +107,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`ICU format locale IDs`: http://userguide.icu-project.org/locale diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 6d322349da4..2bee41d5f2c 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -101,8 +101,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _`Luhn algorithm`: https://en.wikipedia.org/wiki/Luhn_algorithm diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index c3c16f21eae..f5711e001c3 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -105,8 +105,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 2c548b2eb3e..56d088c4cba 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -94,6 +94,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 6e7fc8d7f86..4470d26eb07 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -330,8 +330,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + max ~~~ diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index d7e3c8f2ebd..642a1fc180d 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -275,8 +275,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + pattern ~~~~~~~ diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index a8e362d22dc..e94613e1f6f 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -101,6 +101,11 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc diff --git a/reference/constraints/Timezone.rst b/reference/constraints/Timezone.rst index 045c258bda4..98ca73c156a 100644 --- a/reference/constraints/Timezone.rst +++ b/reference/constraints/Timezone.rst @@ -123,8 +123,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc zone diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 209520c41c7..1962dffa284 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -162,8 +162,13 @@ Parameter Description =============== ============================================================== ``{{ type }}`` The expected type ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc .. _reference-constraint-type-type: diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index e6e449d949b..2bf2533f57e 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -291,8 +291,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_payload-option.rst.inc repositoryMethod diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index fdc58880797..5f4ac23245f 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -98,8 +98,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. configuration-block:: .. code-block:: php-annotations diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index 4406555ac30..6e9794b8b5d 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -97,8 +97,13 @@ You can use the following parameters in this message: Parameter Description =============== ============================================================== ``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label =============== ============================================================== +.. versionadded:: 5.2 + + The ``{{ label }}`` parameter was introduced in Symfony 5.2. + .. include:: /reference/constraints/_normalizer-option.rst.inc .. include:: /reference/constraints/_payload-option.rst.inc From 070450bdd76cae5151b9f98ce70debc0d0e01f91 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 3 Sep 2020 17:57:19 +0200 Subject: [PATCH 424/752] Removed some unneeded versionadded directives --- components/form.rst | 5 ----- forms.rst | 5 ----- 2 files changed, 10 deletions(-) diff --git a/components/form.rst b/components/form.rst index cdcf9ee54a8..7ac59478ceb 100644 --- a/components/form.rst +++ b/components/form.rst @@ -728,11 +728,6 @@ and the errors will display next to the fields on error. For a list of all of the built-in validation constraints, see :doc:`/reference/constraints`. -.. versionadded:: 5.2 - - Constraint message can contains ``{{ label }}`` placeholder that will be replaced - by corresponding form field label (in view of ``label_format`` option). - Accessing Form Errors ~~~~~~~~~~~~~~~~~~~~~ diff --git a/forms.rst b/forms.rst index 9ab6b2101ab..02336d32169 100644 --- a/forms.rst +++ b/forms.rst @@ -548,11 +548,6 @@ corresponding errors printed out with the form. Read the :doc:`Symfony validation documentation ` to learn more about this powerful feature. -.. versionadded:: 5.2 - - Constraint message can contains ``{{ label }}`` placeholder that will be replaced - by corresponding form field label (in view of ``label_format`` option). - Other Common Form Features -------------------------- From b7bd5728b15b89a32ea79eebe737abf948a256e1 Mon Sep 17 00:00:00 2001 From: Damien Fayet Date: Sun, 6 Sep 2020 20:20:39 +0200 Subject: [PATCH 425/752] Leave impersonation functions --- reference/twig_reference.rst | 27 +++++++++++++++++++++++++++ security/impersonating_user.rst | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 4a97ab73308..4e05024cb1b 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -267,6 +267,33 @@ expression Creates an :class:`Symfony\\Component\\ExpressionLanguage\\Expression` related to the :doc:`ExpressionLanguage component `. +impersonation_exit_path +~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: twig + + {{ impersonation_exit_path(exitTo = null) }} + +``exitTo`` *(optional)* + **type**: ``string`` + +Generates a relative URL to exit impersonation. If `exitTo` is specified it will use its value to build the URl, +elsewhere it will use the current URI. +If we are not impersonating a user, it will return an empty string. + +impersonation_exit_url +~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: twig + + {{ impersonation_exit_url(exitTo = null) }} + +``exitTo`` *(optional)* + **type**: ``string`` + +Equal to the `impersonation_exit_path`_ function, but it'll generate an absolute URL +instead of a relative one. + Form Related Functions ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/security/impersonating_user.rst b/security/impersonating_user.rst index 8ab25dab9a6..4ea6482f5f0 100644 --- a/security/impersonating_user.rst +++ b/security/impersonating_user.rst @@ -94,7 +94,7 @@ instance, to show a link to exit impersonation in a template: .. code-block:: html+twig {% if is_granted('IS_IMPERSONATOR') %} - Exit impersonation + Exit impersonation {% endif %} .. versionadded:: 5.1 From 4787bba5f8526b44c0d7bc07d311585ee2a3c080 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Sep 2020 14:48:19 +0200 Subject: [PATCH 426/752] Rewords --- reference/twig_reference.rst | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 4e05024cb1b..a12e712abce 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -277,9 +277,15 @@ impersonation_exit_path ``exitTo`` *(optional)* **type**: ``string`` -Generates a relative URL to exit impersonation. If `exitTo` is specified it will use its value to build the URl, -elsewhere it will use the current URI. -If we are not impersonating a user, it will return an empty string. +.. versionadded:: 5.2 + + The ``impersonation_exit_path()` function was introduced in Symfony 5.2. + +Generates a URL that you can visit to exit :doc:`user impersonation `. +After exiting impersonation, the user is redirected to the current URI. If you +prefer to redirect to a different URI, define its value in the ``exitTo`` argument. + +If no user is being impersonated, the function returns an empty string. impersonation_exit_url ~~~~~~~~~~~~~~~~~~~~~~ @@ -291,8 +297,12 @@ impersonation_exit_url ``exitTo`` *(optional)* **type**: ``string`` -Equal to the `impersonation_exit_path`_ function, but it'll generate an absolute URL -instead of a relative one. +.. versionadded:: 5.2 + + The ``impersonation_exit_url()` function was introduced in Symfony 5.2. + +It's similar to the `impersonation_exit_path`_ function, but it generates +absolute URLs instead of relative URLs. Form Related Functions ~~~~~~~~~~~~~~~~~~~~~~ From a4d71a2c82e12c17d5ab828ae5da1add67255b21 Mon Sep 17 00:00:00 2001 From: Ian Littman Date: Fri, 4 Sep 2020 01:31:46 -0500 Subject: [PATCH 427/752] Add information about HttpBrowser header handling --- components/browser_kit.rst | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index d248b7de939..ffd49aa2483 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -310,6 +310,30 @@ dedicated web crawler or scraper such as `Goutte`_:: $openPullRequests = trim($browser->clickLink('Pull requests')->filter( '.table-list-header-toggle a:nth-child(1)' )->text()); + +Dealing with Headers +~~~~~~~~~~~~~~~~~~~~ + +The fifth parameter of `request()` accepts an array of headers in the same format +you'd see in a FastCGI request: all-upper-case, dashes replaced with underscores, +prefixed with `HTTP_`. Array keys are lower-cased, with `HTTP_` stripped, and +underscores turned to dashes, before saving those headers to the request. + +If you're making a request to an application that has special rules about header +capitalization or punctuation, you'll want to override HttpBrowser's `getHeaders()` +method, which takes a Request object and returns an asociative array of headers. +For example:: + + protected function getHeaders(Request $request): array + { + $headers = parent::getHeaders($request); + if (isset($request->getServer()['api_key'])) { + $headers['api_key'] = $request->getServer()['api_key']; + } + return $headers; + } + +This override is available as of Symfony 5.2. Learn more ---------- From e3991444ab4c40b27066fc22fb4027087ea34c5c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Sep 2020 20:09:27 +0200 Subject: [PATCH 428/752] Minor reword --- components/browser_kit.rst | 50 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index ffd49aa2483..b73783f95e0 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -161,6 +161,32 @@ provides access to the form properties (e.g. ``$form->getUri()``, // submit that form $crawler = $client->submit($form); +Custom Header Handling +~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + The ``getHeaders()`` method was introduced in Symfony 5.2. + +The optional HTTP headers passed to the ``request()`` method follows the FastCGI +request format (uppercase, underscores instead of dashes and prefixed with ``HTTP_``). +Before saving those headers to the request, they are lower-cased, with ``HTTP_`` +stripped, and underscores turned to dashes. + +If you're making a request to an application that has special rules about header +capitalization or punctuation, override the ``getHeaders()`` method, which must +return an associative array of headers:: + + protected function getHeaders(Request $request): array + { + $headers = parent::getHeaders($request); + if (isset($request->getServer()['api_key'])) { + $headers['api_key'] = $request->getServer()['api_key']; + } + + return $headers; + } + Cookies ------- @@ -310,30 +336,6 @@ dedicated web crawler or scraper such as `Goutte`_:: $openPullRequests = trim($browser->clickLink('Pull requests')->filter( '.table-list-header-toggle a:nth-child(1)' )->text()); - -Dealing with Headers -~~~~~~~~~~~~~~~~~~~~ - -The fifth parameter of `request()` accepts an array of headers in the same format -you'd see in a FastCGI request: all-upper-case, dashes replaced with underscores, -prefixed with `HTTP_`. Array keys are lower-cased, with `HTTP_` stripped, and -underscores turned to dashes, before saving those headers to the request. - -If you're making a request to an application that has special rules about header -capitalization or punctuation, you'll want to override HttpBrowser's `getHeaders()` -method, which takes a Request object and returns an asociative array of headers. -For example:: - - protected function getHeaders(Request $request): array - { - $headers = parent::getHeaders($request); - if (isset($request->getServer()['api_key'])) { - $headers['api_key'] = $request->getServer()['api_key']; - } - return $headers; - } - -This override is available as of Symfony 5.2. Learn more ---------- From 63d7ffb152fd0276c64aea3faa6b8c611600056f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Sep 2020 20:51:06 +0200 Subject: [PATCH 429/752] Added the missing versionadded directive --- messenger.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 677a2cf7dce..7518a22488e 100644 --- a/messenger.rst +++ b/messenger.rst @@ -725,10 +725,13 @@ and should not be retried. If you throw :class:`Symfony\\Component\\Messenger\\Exception\\UnrecoverableMessageHandlingException`, the message will not be retried. - Forcing Retrying ~~~~~~~~~~~~~~~~ +.. versionadded:: 5.1 + + The ``RecoverableMessageHandlingException`` was introduced in Symfony 5.1. + Sometimes handling a message must fail in a way that you *know* is temporary and must be retried. If you throw :class:`Symfony\\Component\\Messenger\\Exception\\RecoverableMessageHandlingException`, From 940b4021829d638a63dc4c32ded08c4802316ec9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Fr=C3=A9mont?= Date: Tue, 8 Sep 2020 09:44:14 +0200 Subject: [PATCH 430/752] Debugging the validator constraints --- validation.rst | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/validation.rst b/validation.rst index fd18f003d56..14aab162aae 100644 --- a/validation.rst +++ b/validation.rst @@ -719,6 +719,81 @@ constraint that's applied to the class itself. When that class is validated, methods specified by that constraint are simply executed so that each can provide more custom validation. +Debugging the constraints +------------------------- + +The ``debug:validator 'App\Entity\DummyClassOne'`` command lists validation constraints of ``App\Entity\DummyClassOne`` resource. + +.. code-block:: terminal + + $ php bin/console debug:validator 'App\Entity\DummyClassOne' + + App\Entity\DummyClassOne + ----------------------------------------------------- + + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | Property | Name | Groups | Options | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ | + | | | | "message" => "This value should not be blank.", | + | | | | "allowNull" => false, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ | + | | | | "message" => "This value is not a valid email address.", | + | | | | "mode" => null, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + +You can also list validation constraints for all resources of a path. + +.. code-block:: terminal + + $ php bin/console debug:validator src/Entity + + App\Entity\DummyClassOne + ------------------------ + + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | Property | Name | Groups | Options | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ | + | | | | "message" => "This value should not be blank.", | + | | | | "allowNull" => false, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ | + | | | | "message" => "This value is not a valid email address.", | + | | | | "mode" => null, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + + App\Entity\DummyClassTwo + ------------------------ + + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | Property | Name | Groups | Options | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ | + | | | | "message" => "This value should not be blank.", | + | | | | "allowNull" => false, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ | + | | | | "message" => "This value is not a valid email address.", | + | | | | "mode" => null, | + | | | | "normalizer" => null, | + | | | | "payload" => null | + | | | | ] | + +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ + Final Thoughts -------------- From eb910e3a7f25966ee7c42ee8fddaf7dc48fe0c90 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 8 Sep 2020 19:15:01 +0200 Subject: [PATCH 431/752] Added the versionadded directive --- components/phpunit_bridge.rst | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index fc7c0d6ae2e..177131e9415 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -296,7 +296,13 @@ By default, the bridge will display a detailed output with the number of deprecations and where they arise. If this is too much for you, you can use ``SYMFONY_DEPRECATIONS_HELPER=verbose=0`` to turn the verbose output off. -It's also possible to change verbosity per deprecation type, for instance ``quiet[]=indirect&quiet[]=other`` will hide details for deprecations of types "indirect" and "other". +It's also possible to change verbosity per deprecation type. For example, using +``quiet[]=indirect&quiet[]=other`` will hide details for deprecations of types +"indirect" and "other". + +.. versionadded:: 5.1 + + The ``quiet`` option was introduced in Symfony 5.1. Disabling the Deprecation Helper ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From a8396f3da3dc2f569f8f712691b2c638d8fb3cbc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 8 Sep 2020 19:26:29 +0200 Subject: [PATCH 432/752] Tweaks --- validation.rst | 55 +++++++++----------------------------------------- 1 file changed, 10 insertions(+), 45 deletions(-) diff --git a/validation.rst b/validation.rst index 14aab162aae..559c31a74f8 100644 --- a/validation.rst +++ b/validation.rst @@ -719,16 +719,21 @@ constraint that's applied to the class itself. When that class is validated, methods specified by that constraint are simply executed so that each can provide more custom validation. -Debugging the constraints +Debugging the Constraints ------------------------- -The ``debug:validator 'App\Entity\DummyClassOne'`` command lists validation constraints of ``App\Entity\DummyClassOne`` resource. +.. versionadded:: 5.2 + + The ``debug:validator`` command was introduced in Symfony 5.2. + +Use the ``debug:validator`` command to list the validation constraints of a +given class: .. code-block:: terminal - $ php bin/console debug:validator 'App\Entity\DummyClassOne' + $ php bin/console debug:validator 'App\Entity\SomeClass' - App\Entity\DummyClassOne + App\Entity\SomeClass ----------------------------------------------------- +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ @@ -748,52 +753,12 @@ The ``debug:validator 'App\Entity\DummyClassOne'`` command lists validation cons | | | | ] | +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ -You can also list validation constraints for all resources of a path. +You can also validate all the classes stored in a given directory: .. code-block:: terminal $ php bin/console debug:validator src/Entity - App\Entity\DummyClassOne - ------------------------ - - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - | Property | Name | Groups | Options | - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ | - | | | | "message" => "This value should not be blank.", | - | | | | "allowNull" => false, | - | | | | "normalizer" => null, | - | | | | "payload" => null | - | | | | ] | - | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ | - | | | | "message" => "This value is not a valid email address.", | - | | | | "mode" => null, | - | | | | "normalizer" => null, | - | | | | "payload" => null | - | | | | ] | - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - - App\Entity\DummyClassTwo - ------------------------ - - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - | Property | Name | Groups | Options | - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - | firstArgument | Symfony\Component\Validator\Constraints\NotBlank | Default | [ | - | | | | "message" => "This value should not be blank.", | - | | | | "allowNull" => false, | - | | | | "normalizer" => null, | - | | | | "payload" => null | - | | | | ] | - | firstArgument | Symfony\Component\Validator\Constraints\Email | Default | [ | - | | | | "message" => "This value is not a valid email address.", | - | | | | "mode" => null, | - | | | | "normalizer" => null, | - | | | | "payload" => null | - | | | | ] | - +---------------+--------------------------------------------------+---------+------------------------------------------------------------+ - Final Thoughts -------------- From f54b53b63887fefd59446c6f86b7795dea1c8c3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Romey?= Date: Mon, 4 May 2020 10:18:18 +0200 Subject: [PATCH 433/752] [Notifier] Add Infobip --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 6c19202a77e..4e44eb75d02 100644 --- a/notifier.rst +++ b/notifier.rst @@ -63,6 +63,7 @@ OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPL Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` +Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM`` ========== ================================ ==================================================== .. versionadded:: 5.1 @@ -71,7 +72,7 @@ Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FRO .. versionadded:: 5.2 - The Smsapi integration was introduced in Symfony 5.2. + The Smsapi and Infobip integrations were introduced in Symfony 5.2. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 63ea8b7db68c2486650e5edb328bfb86aada02eb Mon Sep 17 00:00:00 2001 From: Deamon Date: Thu, 30 Apr 2020 23:56:33 +0200 Subject: [PATCH 434/752] Add Mobyt Notifier doc --- notifier.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 4e44eb75d02..023c4d110be 100644 --- a/notifier.rst +++ b/notifier.rst @@ -64,7 +64,8 @@ Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@d FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM`` -========== ================================ ==================================================== +Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` +========== =============================== ==================================================== .. versionadded:: 5.1 @@ -72,7 +73,7 @@ Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM .. versionadded:: 5.2 - The Smsapi and Infobip integrations were introduced in Symfony 5.2. + The Smsapi, Infobip and Mobyt integrations were introduced in Symfony 5.2. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 34ff1e3a72153c084f85f7b725d70b2e72918441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Thu, 10 Sep 2020 14:56:09 +0200 Subject: [PATCH 435/752] fix build error: inline literal start-string without end-string --- reference/twig_reference.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index a12e712abce..0a6c9db3154 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -279,7 +279,7 @@ impersonation_exit_path .. versionadded:: 5.2 - The ``impersonation_exit_path()` function was introduced in Symfony 5.2. + The ``impersonation_exit_path()`` function was introduced in Symfony 5.2. Generates a URL that you can visit to exit :doc:`user impersonation `. After exiting impersonation, the user is redirected to the current URI. If you @@ -299,7 +299,7 @@ impersonation_exit_url .. versionadded:: 5.2 - The ``impersonation_exit_url()` function was introduced in Symfony 5.2. + The ``impersonation_exit_url()`` function was introduced in Symfony 5.2. It's similar to the `impersonation_exit_path`_ function, but it generates absolute URLs instead of relative URLs. From 9204ff20ef28376260ec0aa2836e7bc661163f67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Romey?= Date: Thu, 10 Sep 2020 14:57:07 +0200 Subject: [PATCH 436/752] Sort notifiers --- notifier.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notifier.rst b/notifier.rst index 7aab8e37de0..9737df6395e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -57,11 +57,11 @@ with a couple popular SMS services: ========== ================================ ==================================================== Service Package DSN ========== ================================ ==================================================== -Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` +FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` -FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` +Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` ========== ================================ ==================================================== .. versionadded:: 5.1 @@ -131,10 +131,10 @@ integration with these chat services: ========== ================================ ============================================ Service Package DSN ========== ================================ ============================================ -Slack ``symfony/slack-notifier`` ``slack://default/ID`` -Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` +Slack ``symfony/slack-notifier`` ``slack://default/ID`` +Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` ========== ================================ ============================================ .. versionadded:: 5.1 From 8dec0b7ccf950bfb0b6958e102b017dcd9cea7a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Sch=C3=A4dlich?= Date: Thu, 10 Sep 2020 14:53:05 +0200 Subject: [PATCH 437/752] add symfony/esendex-notifier integration docs --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 37545c22534..ea066e5ed00 100644 --- a/notifier.rst +++ b/notifier.rst @@ -57,6 +57,7 @@ with a couple popular SMS services: ========== ================================ ==================================================== Service Package DSN ========== ================================ ==================================================== +Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` @@ -73,7 +74,7 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.2 - The Smsapi, Infobip and Mobyt integrations were introduced in Symfony 5.2. + The Smsapi, Infobip, Mobyt and Esendex integrations were introduced in Symfony 5.2. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 93f8374641aaadbb2115ee8df4972897213674b7 Mon Sep 17 00:00:00 2001 From: Tomas Date: Fri, 11 Sep 2020 10:47:51 +0300 Subject: [PATCH 438/752] Add Uid normalizer to normalizers list --- components/serializer.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index 6f15604325e..5cbe58e0487 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -804,6 +804,12 @@ There are several types of normalizers available: :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` Normalizes errors according to the API Problem spec `RFC 7807`_. +:class:`Symfony\\Component\\Serializer\\Normalizer\\UidNormalizer` + This normalizer converts objects that implement + :class:`Symfony\\Component\\Uid\\AbstractUid` into strings. Also it can + denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid` + or :class:`Symfony\\Component\\Uid\\Ulid`. + .. _component-serializer-encoders: Encoders From 082923b47022d93d6df16198ac73e17a5694e6cc Mon Sep 17 00:00:00 2001 From: Zmey Date: Fri, 11 Sep 2020 17:33:09 +0300 Subject: [PATCH 439/752] Added ability to use csv ips in security.access_control --- security/access_control.rst | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/security/access_control.rst b/security/access_control.rst index d7a96345b8e..385a499d2fb 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -133,6 +133,73 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that :ref:`Deny access in PHP code ` if you want to disallow access based on ``$_GET`` parameter values. +.. versionadded:: 5.2 + + Environment variables can be used to pass comma separated ip addresses + (as a single value or as one of array values): + + .. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + parameters: + env(TRUSTED_IPS): '10.0.0.1, 10.0.0.2' + security: + # ... + access_control: + - { path: '^/admin', ips: '%env(TRUSTED_IPS)%' } + - { path: '^/admin', ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] } + + .. code-block:: xml + + + + + + + 10.0.0.1, 10.0.0.2 + + + + + + + 127.0.0.1 + ::1 + %env(TRUSTED_IPS)% + + + + + .. code-block:: php + + // config/packages/security.php + $container->setParameter('env(TRUSTED_IPS)', '10.0.0.1, 10.0.0.2'); + $container->loadFromExtension('security', [ + // ... + 'access_control' => [ + [ + 'path' => '^/admin', + 'ips' => '%env(TRUSTED_IPS)%', + ], + [ + 'path' => '^/admin', + 'ips' => [ + '127.0.0.1', + '::1', + '%env(TRUSTED_IPS)%', + ], + ], + ], + ]); + .. _security-access-control-enforcement-options: 2. Access Enforcement From 6e85c11b7970e7705e3174eda1d1c78d115ea993 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 11 Sep 2020 20:40:25 +0200 Subject: [PATCH 440/752] Added the versionadded directive --- components/serializer.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/serializer.rst b/components/serializer.rst index 5cbe58e0487..84a8b297848 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -810,6 +810,10 @@ There are several types of normalizers available: denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid` or :class:`Symfony\\Component\\Uid\\Ulid`. +.. versionadded:: 5.2 + + The ``UidNormalizer`` was introduced in Symfony 5.2. + .. _component-serializer-encoders: Encoders From 86c2f6dda4f0057a0429f2d831cb1c430b9ea670 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 11:16:28 +0200 Subject: [PATCH 441/752] [Console] Documented the info() method --- console/style.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/console/style.rst b/console/style.rst index c800e56f976..a8cdad20004 100644 --- a/console/style.rst +++ b/console/style.rst @@ -325,6 +325,27 @@ Result Methods 'Consectetur adipiscing elit', ]); +:method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::info` + It's similar to the ``success()`` method (the given string or array of strings + are displayed with a green background) but the ``[OK]`` label is not prefixed. + It's meant to be used once to display the final result of executing the given + command, without showing the result as a successful or failed one:: + + // use simple strings for short success messages + $io->info('Lorem ipsum dolor sit amet'); + + // ... + + // consider using arrays when displaying long success messages + $io->info([ + 'Lorem ipsum dolor sit amet', + 'Consectetur adipiscing elit', + ]); + +.. versionadded:: 5.2 + + The ``info()`` method was introduced in Symfony 5.2. + :method:`Symfony\\Component\\Console\\Style\\SymfonyStyle::warning` It displays the given string or array of strings highlighted as a warning message (with a red background and the ``[WARNING]`` label). It's meant to be From a83c6e124ac2ce76e728913810f5395e8931f035 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 11:37:15 +0200 Subject: [PATCH 442/752] [Console] Document the setAutoExit() method --- console.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/console.rst b/console.rst index 8b015737c85..e76d2743425 100644 --- a/console.rst +++ b/console.rst @@ -376,6 +376,14 @@ console:: } } +If you are using a :doc:`single-command application `, +call ``setAutoExit(false)`` on it to get the command result in ``CommandTester``. + +.. versionadded:: 5.2 + + The ``setAutoExit()`` method for single-command applications was introduced + in Symfony 5.2. + .. tip:: You can also test a whole console application by using From cec6219b430950a6b3ae4cfa008f69b3a1929381 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 11:57:38 +0200 Subject: [PATCH 443/752] Minor tweak --- messenger.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/messenger.rst b/messenger.rst index bff5ce65a3f..8b3b93ad415 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1009,11 +1009,13 @@ Beanstalkd Transport .. versionadded:: 5.2 - Install it by running: + The Beanstalkd transport was introduced in Symfony 5.2. - .. code-block:: terminal +Install it by running: + +.. code-block:: terminal - $ composer require symfony/beanstalkd-messenger + $ composer require symfony/beanstalkd-messenger .. code-block:: bash From 62a71dc67c479625ea11c3767d117ef8e3460121 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 12:11:36 +0200 Subject: [PATCH 444/752] [Console] Choice values can also be objects --- components/console/helpers/questionhelper.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/console/helpers/questionhelper.rst b/components/console/helpers/questionhelper.rst index 89716c8d078..a4cc68b80b2 100644 --- a/components/console/helpers/questionhelper.rst +++ b/components/console/helpers/questionhelper.rst @@ -105,6 +105,7 @@ from a predefined list:: $helper = $this->getHelper('question'); $question = new ChoiceQuestion( 'Please select your favorite color (defaults to red)', + // choices can also be PHP objects that implement __toString() method ['red', 'blue', 'yellow'], 0 ); @@ -116,6 +117,10 @@ from a predefined list:: // ... do something with the color } +.. versionadded:: 5.2 + + Support for using PHP objects as choice values was introduced in Symfony 5.2. + The option which should be selected by default is provided with the third argument of the constructor. The default is ``null``, which means that no option is the default one. From dfd97c57ab8faf8548442381382a3cbe36fb24bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sat, 12 Sep 2020 14:25:27 +0200 Subject: [PATCH 445/752] Add documentation about read/write locks --- components/lock.rst | 72 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index 09c7abab8eb..53a7514e935 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -165,6 +165,56 @@ This component also provides two useful methods related to expiring locks: ``getExpiringDate()`` (which returns ``null`` or a ``\DateTimeImmutable`` object) and ``isExpired()`` (which returns a boolean). +Shared Locks +------------ + +Sometimes, a data structure cannot be updated atomically and is invalid during +the time of the update. In this situation, other process should not read or +write the data until the update is complete. But once updated, multiple process +can read the data in parallel. + +In this situation, a common solution is to use shared lock which allows +concurent access for read-only operations, while write operations require +exclusive access. + +Use the :method:`Symfony\\Component\\Lock\\LockInterface::acquireRead` method +to acquire a read-only lock, and the existing +:method:`Symfony\\Component\\Lock\\LockInterface::acquire` method to acquire a +write lock.:: + + $lock = $factory->createLock('user'.$user->id); + if (!$lock->acquireRead()) { + return; + } + +Similare to the ``acquire`` method, pass ``true`` as the argument of the ``acquireRead()`` +method to acquire the lock in a blocking mode.:: + + $lock = $factory->createLock('user'.$user->id); + $lock->acquireRead(true); + +When a read-only lock is acquired with the method ``acquireRead``, it's +possible to **Promote** the lock, and change it to write lock, by calling the +``acquire`` method.:: + + $lock = $factory->createLock('user'.$userId); + $lock->acquireRead(true); + + if (!$this->shouldUpdate($userId)) { + return; + } + + $lock->acquire(true); // Promote the lock to write lock + $this->update($userId); + +In the same way, it's possible to **Demote** a write lock, and change it to a +read-only lock by calling the ``acquireRead`` method. + +.. versionadded:: 5.2 + + The ``Lock::acquireRead`` method and ``SharedLockStoreInterface`` interface + and were introduced in Symfony 5.2. + The Owner of The Lock --------------------- @@ -219,17 +269,17 @@ Locks are created and managed in ``Stores``, which are classes that implement The component includes the following built-in store types: -============================================ ====== ======== ======== -Store Scope Blocking Expiring -============================================ ====== ======== ======== -:ref:`FlockStore ` local yes no -:ref:`MemcachedStore ` remote no yes -:ref:`MongoDbStore ` remote no yes -:ref:`PdoStore ` remote no yes -:ref:`RedisStore ` remote no yes -:ref:`SemaphoreStore ` local yes no -:ref:`ZookeeperStore ` remote no no -============================================ ====== ======== ======== +============================================ ====== ======== ======== ======= +Store Scope Blocking Expiring Sharing +============================================ ====== ======== ======== ======= +:ref:`FlockStore ` local yes no yes +:ref:`MemcachedStore ` remote no yes no +:ref:`MongoDbStore ` remote no yes no +:ref:`PdoStore ` remote no yes no +:ref:`RedisStore ` remote no yes yes +:ref:`SemaphoreStore ` local yes no no +:ref:`ZookeeperStore ` remote no no no +============================================ ====== ======== ======== ======= .. _lock-store-flock: From c5c006ffff68c276026d7fd82c6396699ddb43ae Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 15:11:15 +0200 Subject: [PATCH 446/752] [Process] Document the method to configure options --- components/process.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/components/process.rst b/components/process.rst index c7b286fec71..c70c602ac98 100644 --- a/components/process.rst +++ b/components/process.rst @@ -102,6 +102,21 @@ with a non-zero code):: :method:`Symfony\\Component\\Process\\Process::getLastOutputTime` method. This method returns ``null`` if the process wasn't started! +Configuring Process Options +--------------------------- + +.. versionadded:: 5.2 + + The feature to configure process options was introduced in Symfony 5.2. + +Symfony uses the PHP :phpfunction:`proc_open` function to run the processes. +You can configure the options passed to the ``other_options`` argument of +``proc_open()`` using the ``setOptions()`` method:: + + $process = new Process(['...', '...', '...']); + // this option allows a subprocess to continue running after the main script exited + $process->setOptions(['create_new_console' => true]); + Using Features From the OS Shell -------------------------------- From 0e3d907dbd7358d24ee01c77dc1a92c2d55483d7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 15:24:23 +0200 Subject: [PATCH 447/752] [Cache] Mention the changes in prefix_seed --- reference/configuration/framework.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 6710badcece..b443750a124 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2716,6 +2716,12 @@ It's also useful when using `blue/green deployment`_ strategies and more generally, when you need to abstract out the actual deployment directory (for example, when warming caches offline). +.. versionadded:: 5.2 + + Starting from Symfony 5.2, the ``%kernel.container_class%`` parameter is no + longer appended automatically to the value of this option. This allows + sharing caches between applications or different environments. + .. _reference-lock: lock From 12c71a6e2f83f44033ba7239eba334c300f11297 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 15:51:52 +0200 Subject: [PATCH 448/752] Tweaks --- notifier.rst | 10 +++++++++- notifier/chatters.rst | 10 +++++++--- notifier/texters.rst | 10 +++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/notifier.rst b/notifier.rst index ea066e5ed00..9d0b5148553 100644 --- a/notifier.rst +++ b/notifier.rst @@ -376,7 +376,7 @@ To send a notification, autowire the ); // Send the notification to the recipient - $notifier->send($notification, $recipient); + $sentMessage = $notifier->send($notification, $recipient); // ... } @@ -387,6 +387,14 @@ channels. The channels specify which channel (or transport) should be used to send the notification. For instance, ``['email', 'sms']`` will send both an email and sms notification to the user. +The ``send()`` method used to send the notification returns a variable of type +:class:`Symfony\\Component\\Notifier\\Message\\SentMessage` which provides +information such as the message ID and the original message contents. + +.. versionadded:: 5.2 + + The ``SentMessage`` class was introduced in Symfony 5.2. + The default notification also has a ``content()`` and ``emoji()`` method to set the notification content and icon. diff --git a/notifier/chatters.rst b/notifier/chatters.rst index fa8392f4a48..efbd040593e 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -38,9 +38,13 @@ you to send messages to chat services like Slack or Telegram:: } } -The ``$sentMessage`` (instance of -:class:`Symfony\\Component\\Notifier\\Message\\SentMessage`) returned by -``send()`` contains info about the sent message. +The ``send()`` method returns a variable of type +:class:`Symfony\\Component\\Notifier\\Message\\SentMessage` which provides +information such as the message ID and the original message contents. + +.. versionadded:: 5.2 + + The ``SentMessage`` class was introduced in Symfony 5.2. .. seealso:: diff --git a/notifier/texters.rst b/notifier/texters.rst index bd9ec44ebcd..eb663b13726 100644 --- a/notifier/texters.rst +++ b/notifier/texters.rst @@ -39,9 +39,13 @@ you to send SMS messages:: } } -The ``$sentMessage`` (instance of -:class:`Symfony\\Component\\Notifier\\Message\\SentMessage`) returned by -``send()`` contains info about the sent message. +The ``send()`` method returns a variable of type +:class:`Symfony\\Component\\Notifier\\Message\\SentMessage` which provides +information such as the message ID and the original message contents. + +.. versionadded:: 5.2 + + The ``SentMessage`` class was introduced in Symfony 5.2. .. seealso:: From 5d971ee2f4cefd89b51dd35fed317bfb1a52da6f Mon Sep 17 00:00:00 2001 From: Ahmad Ra'fat Date: Mon, 27 Jul 2020 14:03:28 +0200 Subject: [PATCH 449/752] [Stopwatch] Add name property to the stopwatchEvent --- components/stopwatch.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/components/stopwatch.rst b/components/stopwatch.rst index e6e11d9c53e..c0265f272e5 100644 --- a/components/stopwatch.rst +++ b/components/stopwatch.rst @@ -102,6 +102,7 @@ For example:: $event->getEndTime(); // returns the end time of the very last period $event->getDuration(); // returns the event duration, including all periods $event->getMemory(); // returns the max memory usage of all periods + $event->getName(); // returns the event name Sections -------- From fc9ab91cc45500444742f7b393574793c8ad5453 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 15:56:01 +0200 Subject: [PATCH 450/752] Added the versionadded directive --- components/stopwatch.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/stopwatch.rst b/components/stopwatch.rst index c0265f272e5..d381d3316a5 100644 --- a/components/stopwatch.rst +++ b/components/stopwatch.rst @@ -104,6 +104,10 @@ For example:: $event->getMemory(); // returns the max memory usage of all periods $event->getName(); // returns the event name +.. versionadded:: 5.2 + + The ``getName()`` method was introduced in Symfony 5.2. + Sections -------- From 729c7df5d62d2d9adce8d0ef120a192a523b7fc9 Mon Sep 17 00:00:00 2001 From: pizzaminded Date: Mon, 7 Sep 2020 23:09:12 +0200 Subject: [PATCH 451/752] [HttpClient] Providing additional options to CurlHttpClient section --- http_client.rst | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/http_client.rst b/http_client.rst index a1d8c4bd0a3..8814f8f2292 100644 --- a/http_client.rst +++ b/http_client.rst @@ -728,6 +728,39 @@ When using this component in a full-stack Symfony application, this behavior is not configurable and cURL will be used automatically if the cURL PHP extension is installed and enabled. Otherwise, the native PHP streams will be used. +Providing Additional Options to CurlHttpClient +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is possible to provide additional cURL options to ``CurlHttpClient``. PHP exposes +a lot of `cURL options`_ that can be passed to ``curl_setopt`` function, but only some +of them are used in ``CurlHttpClient`` in favor of bigger component portability. + +To provide cURL-related parameters to request, add an ``extra.curl`` option in your +configuration:: + + use Symfony\Component\HttpClient\CurlHttpClient; + + $client = new CurlHttpClient(); + + $client->request('POST', 'https://...', [ + // ... + 'extra' => [ + 'curl' => [ + CURLOPT_IPRESOLVE => CURL_IPRESOLVE_V6 + ] + ] + ]); + + +This option is available only when using ``CurlHttpClient``, other clients will ignore these options. + +.. note:: + + Some cURL options are impossible to override due of. e.g Thread Safety or existing options in + ``$options`` configuration which will set given attributes internally. An exception will be + thrown while overriding them. + + HTTP/2 Support ~~~~~~~~~~~~~~ @@ -1391,3 +1424,4 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts .. _`Symfony Contracts`: https://github.com/symfony/contracts .. _`libcurl`: https://curl.haxx.se/libcurl/ .. _`amphp/http-client`: https://packagist.org/packages/amphp/http-client +.. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php From 935ea466268a7376594ab08902eb643e17d8b267 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 16:06:44 +0200 Subject: [PATCH 452/752] Minor reword --- http_client.rst | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/http_client.rst b/http_client.rst index 8814f8f2292..c34911ceaf6 100644 --- a/http_client.rst +++ b/http_client.rst @@ -728,15 +728,19 @@ When using this component in a full-stack Symfony application, this behavior is not configurable and cURL will be used automatically if the cURL PHP extension is installed and enabled. Otherwise, the native PHP streams will be used. -Providing Additional Options to CurlHttpClient -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Configuring CurlHttpClient Options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -It is possible to provide additional cURL options to ``CurlHttpClient``. PHP exposes -a lot of `cURL options`_ that can be passed to ``curl_setopt`` function, but only some -of them are used in ``CurlHttpClient`` in favor of bigger component portability. +.. versionadded:: 5.2 -To provide cURL-related parameters to request, add an ``extra.curl`` option in your -configuration:: + The feature to configure extra cURL options was introduced in Symfony 5.2. + +PHP allows to configure lots of `cURL options`_ via the :phpfunction:`curl_setopt` +function. In order to make the component more portable when not using cURL, the +``CurlHttpClient`` only uses some of those options (and they are ignored in the +rest of clients). + +Add an ``extra.curl`` option in your configuration to pass those extra options:: use Symfony\Component\HttpClient\CurlHttpClient; @@ -751,15 +755,10 @@ configuration:: ] ]); - -This option is available only when using ``CurlHttpClient``, other clients will ignore these options. - .. note:: - Some cURL options are impossible to override due of. e.g Thread Safety or existing options in - ``$options`` configuration which will set given attributes internally. An exception will be - thrown while overriding them. - + Some cURL options are impossible to override (e.g. because of thread safety) + and you'll get an exception when trying to override them. HTTP/2 Support ~~~~~~~~~~~~~~ From 90caccc0f04e7a32671a57a012307b9a950bd31b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 12 Sep 2020 12:27:17 +0200 Subject: [PATCH 453/752] [Uid] Mention the new Doctrine types and generators --- components/uid.rst | 111 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/components/uid.rst b/components/uid.rst index c8eee0ece94..f1c569df97d 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -112,6 +112,62 @@ UUID objects created with the ``Uuid`` class can use the following methods // * int < 0 if $uuid1 is less than $uuid4 $uuid1->compare($uuid4); // e.g. int(4) +Storing UUIDs in Databases +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can store UUID values as any other regular string/binary values in the database. +However, if you :doc:`use Doctrine `, it's more convenient to use the +special Doctrine types which convert to/from UUID objects automatically:: + + // src/Entity/Product.php + namespace App\Entity; + + use Doctrine\ORM\Mapping as ORM; + + /** + * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") + */ + class Product + { + /** + * @ORM\Column(type="uuid") + */ + private $someProperty; + + /** + * @ORM\Column(type="uuid_binary") + */ + private $anotherProperty; + + // ... + } + +There's also a Doctrine generator to help autogenerate UUID values for the +entity primary keys:: + + // there are generators for UUID V1 and V6 too + use Symfony\Bridge\Doctrine\Types\UuidV4Generator; + + /** + * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") + */ + class Product + { + /** + * @ORM\Id + * @ORM\Column(type="uuid", unique=true) + * @ORM\GeneratedValue(strategy="CUSTOM") + * @ORM\CustomIdGenerator(class=UuidV4Generator::class) + */ + private $id; + + // ... + } + +.. versionadded:: 5.2 + + The UUID types and generators were introduced in Symfony 5.2. + ULIDs ----- @@ -172,6 +228,61 @@ ULID objects created with the ``Ulid`` class can use the following methods:: // this method returns $ulid1 <=> $ulid2 $ulid1->compare($ulid2); // e.g. int(-1) +Storing ULIDs in Databases +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You can store ULID values as any other regular string/binary values in the database. +However, if you :doc:`use Doctrine `, it's more convenient to use the +special Doctrine types which convert to/from ULID objects automatically:: + + // src/Entity/Product.php + namespace App\Entity; + + use Doctrine\ORM\Mapping as ORM; + + /** + * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") + */ + class Product + { + /** + * @ORM\Column(type="ulid") + */ + private $someProperty; + + /** + * @ORM\Column(type="ulid_binary") + */ + private $anotherProperty; + + // ... + } + +There's also a Doctrine generator to help autogenerate ULID values for the +entity primary keys:: + + use Symfony\Bridge\Doctrine\Types\UlidGenerator; + + /** + * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") + */ + class Product + { + /** + * @ORM\Id + * @ORM\Column(type="uuid", unique=true) + * @ORM\GeneratedValue(strategy="CUSTOM") + * @ORM\CustomIdGenerator(class=UlidGenerator::class) + */ + private $id; + + // ... + } + +.. versionadded:: 5.2 + + The ULID types and generator were introduced in Symfony 5.2. + .. _`unique identifiers`: https://en.wikipedia.org/wiki/UID .. _`UUIDs`: https://en.wikipedia.org/wiki/Universally_unique_identifier .. _`ULIDs`: https://github.com/ulid/spec From db7298f7d081361867e6d7cf08e2f4dab7c59d45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honor=C3=A9=20Hounwanou?= Date: Mon, 14 Sep 2020 10:59:27 -0400 Subject: [PATCH 454/752] Fix small typo by removing semicolon --- security/experimental_authenticators.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index a8c5ee3cc55..83b3199d9ef 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -493,7 +493,7 @@ authenticator, you would initialize the passport like this:: return new Passport($user, new PasswordCredentials($password), [ // $this->userRepository must implement PasswordUpgraderInterface new PasswordUpgradeBadge($password, $this->userRepository), - new CsrfTokenBadge('login', $csrfToken); + new CsrfTokenBadge('login', $csrfToken), ]); } } From 8d28f6b089045459e65245b3d615a07418f6d2d7 Mon Sep 17 00:00:00 2001 From: Andrey Bolonin Date: Tue, 11 Aug 2020 21:40:16 +0300 Subject: [PATCH 455/752] Update custom-transport.rst --- messenger/custom-transport.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/messenger/custom-transport.rst b/messenger/custom-transport.rst index e0fbcb3ca23..f4e5531109c 100644 --- a/messenger/custom-transport.rst +++ b/messenger/custom-transport.rst @@ -35,7 +35,7 @@ The transport object needs to implement the and :class:`Symfony\\Component\\Messenger\\Transport\\Receiver\\ReceiverInterface`). Here is a simplified example of a database transport:: - use Ramsey\Uuid\Uuid; + use Symfony\Component\Uid\Uuid; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp; use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer; @@ -108,8 +108,7 @@ Here is a simplified example of a database transport:: public function send(Envelope $envelope): Envelope { $encodedMessage = $this->serializer->encode($envelope); - $uuid = Uuid::uuid4()->toString(); - + $uuid = (string) Uuid::v4(); // Add a message to the "my_queue" table $this->db->createQuery( 'INSERT INTO my_queue (id, envelope, delivered_at, handled) From 51aa10d2096bf4e234aaf1fb6ae4eee15c06ba13 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 15 Sep 2020 08:24:37 +0200 Subject: [PATCH 456/752] Sort import statements in a code example --- 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 f4e5531109c..be41d63a41e 100644 --- a/messenger/custom-transport.rst +++ b/messenger/custom-transport.rst @@ -35,12 +35,12 @@ The transport object needs to implement the and :class:`Symfony\\Component\\Messenger\\Transport\\Receiver\\ReceiverInterface`). Here is a simplified example of a database transport:: - use Symfony\Component\Uid\Uuid; use Symfony\Component\Messenger\Envelope; use Symfony\Component\Messenger\Stamp\TransportMessageIdStamp; use Symfony\Component\Messenger\Transport\Serialization\PhpSerializer; use Symfony\Component\Messenger\Transport\Serialization\SerializerInterface; use Symfony\Component\Messenger\Transport\TransportInterface; + use Symfony\Component\Uid\Uuid; class YourTransport implements TransportInterface { From 53fb3c73582b0fd1897b29098f89a871f628b7f8 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Tue, 15 Sep 2020 01:19:38 -0400 Subject: [PATCH 457/752] Add new way of mapping form data --- form/data_mappers.rst | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/form/data_mappers.rst b/form/data_mappers.rst index 15e66ce54b3..24a0f41d39e 100644 --- a/form/data_mappers.rst +++ b/form/data_mappers.rst @@ -189,6 +189,45 @@ method:: Cool! When using the ``ColorType`` form, the custom data mapper methods will create a new ``Color`` object now. +Mapping Form Fields Using Callbacks +----------------------------------- + +Conveniently, you can also map data from and into a form field by using the +``getter`` and ``setter`` options. For example, suppose you have a form with some +fields and only one of them needs to be mapped in some special way or you only +need to change how it's written into the underlying object. In that case, register +a PHP callable that is able to write or read to/from that specific object:: + + public function buildForm(FormBuilderInterface $builder, array $options) + { + // ... + + $builder->add('state', ChoiceType::class, [ + 'choices' => [ + 'active' => true, + 'paused' => false, + ], + 'getter' => function (Task $task, FormInterface $form): bool { + return !$task->isCancelled() && !$task->isPaused(); + }, + 'setter' => function (Task &$task, bool $state, FormInterface $form): void { + if ($state) { + $task->activate(); + } else { + $task->pause(); + } + }, + ]); + } + +If available, these options have priority over the property path accessor and +the default data mapper will still use the :doc:`PropertyAccess component ` +for the other form fields. + +.. versionadded:: 5.2 + + The ``getter`` and ``setter`` options were introduced in Symfony 5.2. + .. caution:: When a form has the ``inherit_data`` option set to ``true``, it does not use the data mapper and From 26ff76c7382250e33f17c562eca6ee00898e06c6 Mon Sep 17 00:00:00 2001 From: Gary Houbre Date: Tue, 15 Sep 2020 15:57:49 +0200 Subject: [PATCH 458/752] Path from Controller Test - Messenger Page Doc --- messenger.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/messenger.rst b/messenger.rst index 3d7e8c32563..d20b46472c2 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1110,8 +1110,8 @@ Then, while testing, messages will *not* be delivered to the real transport. Even better, in a test, you can check that exactly one message was sent during a request:: - // tests/DefaultControllerTest.php - namespace App\Tests; + // tests/Controller/DefaultControllerTest.php + namespace App\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\Messenger\Transport\InMemoryTransport; From 5b3a13b6cf1cf958a3ccefa40205929cd196f31e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 17 Sep 2020 13:58:49 +0200 Subject: [PATCH 459/752] Add documentation for Retryable client --- http_client.rst | 23 +++++ reference/configuration/framework.rst | 126 ++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) diff --git a/http_client.rst b/http_client.rst index 3ead5a7a6f8..44be44aee82 100644 --- a/http_client.rst +++ b/http_client.rst @@ -143,6 +143,7 @@ Some options are described in this guide: * `Query String Parameters`_ * `Headers`_ * `Redirects`_ +* `Retry Failed Requests`_ * `HTTP Proxies`_ Check out the full :ref:`http_client config reference ` @@ -654,6 +655,28 @@ making a request. Use the ``max_redirects`` setting to configure this behavior 'max_redirects' => 0, ]); +Retry Failed Requests +~~~~~~~~~~~~~~~~~~~~~ + +Some times, requests failed because of temporary issue in the server or +because network issue. You can use the +:class:`Symfony\\Component\\HttpClient\\RetryableHttpClient` +client to automatically retry the request when it fails.:: + + use Symfony\Component\HttpClient\RetryableHttpClient; + + $client = new RetryableHttpClient(HttpClient::create()); + +The ``RetryableHttpClient`` uses a +:class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface` to +decide if the request should be retried, and a +:class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface` to +define the waiting time between each retry. + +By default, it retries until 3 attemps, the requests responding with a +status code in (423, 425, 429, 500, 502, 503, 504, 507 or 510) and wait +expentially from 1 second for the first retry, to 4 seconds at the 3rd attempt. + HTTP Proxies ~~~~~~~~~~~~ diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index b443750a124..1d1b788f7a5 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -137,11 +137,34 @@ Configuration * `proxy`_ * `query`_ * `resolve`_ + + * :ref:`retry_failed ` + + * `backoff_service`_ + * `decider_service`_ + * :ref:`enabled ` + * `delay`_ + * `http_codes`_ + * `max_delay`_ + * `max_retries`_ + * `multiplier`_ + * `timeout`_ * `max_duration`_ * `verify_host`_ * `verify_peer`_ + * :ref:`retry_failed ` + + * `backoff_service`_ + * `decider_service`_ + * :ref:`enabled ` + * `delay`_ + * `http_codes`_ + * `max_delay`_ + * `max_retries`_ + * `multiplier`_ + * `http_method_override`_ * `ide`_ * :ref:`lock ` @@ -742,6 +765,33 @@ If you use for example as the type and name of an argument, autowiring will inject the ``my_api.client`` service into your autowired classes. +.. _reference-http-client-retry-failed: + +By enabling the optional ``retry_failed`` configuration, the HTTP client service +will automaticaly retry failed HTTP requests. + +.. code-block:: yaml + + # config/packages/framework.yaml + framework: + # ... + http_client: + # ... + retry_failed: + # backoff_service: app.custom_backoff + # decider_service: app.custom_decider + http_codes: [429, 500] + max_retries: 2 + delay: 1000 + multiplier: 3 + max_delay: 500 + + scoped_clients: + my_api.client: + # ... + retry_failed: + max_retries: 4 + auth_basic .......... @@ -769,6 +819,19 @@ in the `Microsoft NTLM authentication protocol`_. The value of this option must follow the format ``username:password``. This authentication mechanism requires using the cURL-based transport. +backoff_service +............... + +**type**: ``string`` + +The service id used to compute the time to wait between retries. By default, it +uses an instance of +:class:`Symfony\\Component\\HttpClient\\Retry\\ExponentialBackOff` configured +with ``delay``, ``max_delay`` and ``multiplier`` options. This class has to +implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`. +This options cannot be used along `delay`_, `max_delay`_ or `multiplier`_ +options. + base_uri ........ @@ -837,6 +900,36 @@ ciphers A list of the names of the ciphers allowed for the SSL/TLS connections. They can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``). +decider_service +............... + +**type**: ``string`` + +The service id used to decide if a request should be retried. By default, it +uses an instance of +:class:`Symfony\\Component\\HttpClient\\Retry\\HttpStatusCodeDecider` configured +with ``http_codes`` options. This class has to +implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`. +This options cannot be used along `http_codes`_ option. + +delay +..... + +**type**: ``integer`` **default**: ``1000`` + +The initial delay in milliseconds used to compute the waiting time between +retries. This options cannot be used along `backoff_service`_ option. + +.. _reference-http-client-retry-enabled: + +enabled +....... + +**type**: ``boolean`` **default**: ``false`` + +Whether to enable the support for retry failed HTTP request or not. +This setting is automatically set to true when one of the child settings is configured. + headers ....... @@ -845,6 +938,14 @@ headers An associative array of the HTTP headers added before making the request. This value must use the format ``['header-name' => header-value, ...]``. +http_codes +.......... + +**type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]`` + +The list of HTTP status codes that triggers a retry of the request. +This options cannot be used along `decider_service`_ option. + http_version ............ @@ -870,6 +971,15 @@ local_pk The path of a file that contains the `PEM formatted`_ private key of the certificate defined in the ``local_cert`` option. +max_delay +......... + +**type**: ``integer`` **default**: ``0`` + +The maximum amount of milliseconds initial to wait between retries. +Use ``0`` to not limit the duration. +This options cannot be used along `backoff_service`_ option. + max_duration ............ @@ -896,6 +1006,22 @@ max_redirects The maximum number of redirects to follow. Use ``0`` to not follow any redirection. +max_retries +........... + +**type**: ``integer`` **default**: ``3`` + +The maximum number of retries before aborting. When the maximum is reach, the +client returns the last received responses. + +multiplier +.......... + +**type**: ``float`` **default**: ``2`` + +Multiplier to apply to the delay each time a retry occurs. +This options cannot be used along `backoff_service`_ option. + no_proxy ........ From 98dcd36a1accc647f14fb319568470a088b4c56a Mon Sep 17 00:00:00 2001 From: Valentin Silvestre Date: Fri, 18 Sep 2020 09:52:01 +0200 Subject: [PATCH 460/752] Add AMPS support --- messenger.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/messenger.rst b/messenger.rst index 6fe7fe7d3f3..3064ef12793 100644 --- a/messenger.rst +++ b/messenger.rst @@ -844,6 +844,12 @@ options. AMQP Transport ~~~~~~~~~~~~~~ +.. versionadded:: 5.2 + + Starting from Symfony 5.2, the AMQP transport can handle AMQPS DSN. + Be aware that using it without using CA certificate can throw an exception. + An alternative is to use AMQP DSN and specify the port to use. + .. versionadded:: 5.1 Starting from Symfony 5.1, the AMQP transport has moved to a separate package. @@ -860,7 +866,13 @@ The ``amqp`` transport configuration looks like this: # .env MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages + # or use the AMQPS protocol + MESSENGER_TRANSPORT_DSN=amqps://guest:guest@localhost/%2f/messages + + To use Symfony's built-in AMQP transport, you need the AMQP PHP extension. +If you want to use TLS/SSL encrypted AMQP you must provide a CA certificate. You need to set it using ``amqp.cacert = /etc/ssl/certs`` (path depends on your system) in your ``php.ini`` file or by setting the ``cacert`` parameter (e.g ``amqps://localhost?cacert=/etc/ssl/certs/``) +By default TLS/SSL encrypted AMQP uses port 5671. You can overwrite this behavior by setting the ``port`` parameter (e.g. ``amqps://localhost?cacert=/etc/ssl/certs/&port=12345``). .. note:: From f168c286c665aed785fae1b78a22daaa91e2c544 Mon Sep 17 00:00:00 2001 From: Mynyx Date: Fri, 18 Sep 2020 11:02:55 +0200 Subject: [PATCH 461/752] Update forms.rst https://symfony.com/doc/current/form/form_themes.html#symfony-built-in-form-themes --- forms.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forms.rst b/forms.rst index ab433b533db..5867d2f07d1 100644 --- a/forms.rst +++ b/forms.rst @@ -352,7 +352,7 @@ can set this option to generate forms compatible with the Bootstrap 4 CSS framew ]); The :ref:`built-in Symfony form themes ` include -Bootstrap 3 and 4 and Foundation 5. You can also +Bootstrap 3 and 4 as well as Foundation 5 and 6. You can also :ref:`create your own Symfony form theme `. In addition to form themes, Symfony allows you to From c0a2ef5de26888e529e2d0bcdbdf5e06ebbbb58c Mon Sep 17 00:00:00 2001 From: Egor Ushakov Date: Fri, 18 Sep 2020 12:57:55 +0300 Subject: [PATCH 462/752] Update serializer.rst IMHO using "format" in current edition confuses readers with $format parameter next to $type --- serializer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serializer.rst b/serializer.rst index 81cc0e4ad93..dfee3270aee 100644 --- a/serializer.rst +++ b/serializer.rst @@ -70,7 +70,7 @@ As well as the following normalizers: * :class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer` to deal with objects implementing the :phpclass:`JsonSerializable` interface * :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer` to - denormalize arrays of objects using a format like `MyObject[]` (note the `[]` suffix) + denormalize arrays of objects using for a `$type` parameter string in `MyObject[]` format (note the `[]` suffix) * :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer` for objects implementing the :class:`Symfony\\Component\\Validator\\ConstraintViolationListInterface` interface * :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` for :class:`Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` objects From cd6c0fd8b4396b48ddd9a0baa986d9b21b8f82db Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 18 Sep 2020 17:53:53 +0200 Subject: [PATCH 463/752] Tweak --- serializer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serializer.rst b/serializer.rst index dfee3270aee..1fae4a6e4f3 100644 --- a/serializer.rst +++ b/serializer.rst @@ -70,7 +70,7 @@ As well as the following normalizers: * :class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer` to deal with objects implementing the :phpclass:`JsonSerializable` interface * :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer` to - denormalize arrays of objects using for a `$type` parameter string in `MyObject[]` format (note the `[]` suffix) + denormalize arrays of objects using a notation like ``MyObject[]`` (note the ``[]`` suffix) * :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer` for objects implementing the :class:`Symfony\\Component\\Validator\\ConstraintViolationListInterface` interface * :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` for :class:`Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` objects From b73c12889b07da6a08c56b5164d80d72870d6313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B2=D0=B0=D0=BD?= Date: Sun, 20 Sep 2020 16:18:57 +0500 Subject: [PATCH 464/752] Update reset_password.rst --- security/reset_password.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/reset_password.rst b/security/reset_password.rst index 7899440ba86..bbde221f015 100644 --- a/security/reset_password.rst +++ b/security/reset_password.rst @@ -12,7 +12,7 @@ Generating the Reset Password Code .. code-block:: terminal - $ php composer require symfonycasts/reset-password-bundle + $ composer require symfonycasts/reset-password-bundle ..... $ php bin/console make:reset-password From a533c359913a4dd6ae7bc195c67fec37732c2a85 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 15:36:55 +0200 Subject: [PATCH 465/752] Tweaks and rewords --- components/lock.rst | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index 53a7514e935..c0f20586e6d 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -168,34 +168,37 @@ object) and ``isExpired()`` (which returns a boolean). Shared Locks ------------ -Sometimes, a data structure cannot be updated atomically and is invalid during -the time of the update. In this situation, other process should not read or -write the data until the update is complete. But once updated, multiple process -can read the data in parallel. +.. versionadded:: 5.2 + + Shared locks (and the associated ``acquireRead()`` method and + ``SharedLockStoreInterface``) were introduced in Symfony 5.2. -In this situation, a common solution is to use shared lock which allows -concurent access for read-only operations, while write operations require -exclusive access. +A shared or `readers–writer lock`_ is a synchronization primitive that allows +concurrent access for read-only operations, while write operations require +exclusive access. This means that multiple threads can read the data in parallel +but an exclusive lock is needed for writing or modifying data. They are used for +example for data structures that cannot be updated atomically and are invalid +until the update is complete. Use the :method:`Symfony\\Component\\Lock\\LockInterface::acquireRead` method to acquire a read-only lock, and the existing :method:`Symfony\\Component\\Lock\\LockInterface::acquire` method to acquire a -write lock.:: +write lock:: $lock = $factory->createLock('user'.$user->id); if (!$lock->acquireRead()) { return; } -Similare to the ``acquire`` method, pass ``true`` as the argument of the ``acquireRead()`` -method to acquire the lock in a blocking mode.:: +Similar to the ``acquire()`` method, pass ``true`` as the argument of ``acquireRead()`` +to acquire the lock in a blocking mode:: $lock = $factory->createLock('user'.$user->id); $lock->acquireRead(true); -When a read-only lock is acquired with the method ``acquireRead``, it's -possible to **Promote** the lock, and change it to write lock, by calling the -``acquire`` method.:: +When a read-only lock is acquired with the method ``acquireRead()``, it's +possible to **promote** the lock, and change it to write lock, by calling the +``acquire()`` method:: $lock = $factory->createLock('user'.$userId); $lock->acquireRead(true); @@ -207,13 +210,8 @@ possible to **Promote** the lock, and change it to write lock, by calling the $lock->acquire(true); // Promote the lock to write lock $this->update($userId); -In the same way, it's possible to **Demote** a write lock, and change it to a -read-only lock by calling the ``acquireRead`` method. - -.. versionadded:: 5.2 - - The ``Lock::acquireRead`` method and ``SharedLockStoreInterface`` interface - and were introduced in Symfony 5.2. +In the same way, it's possible to **demote** a write lock, and change it to a +read-only lock by calling the ``acquireRead()`` method. The Owner of The Lock --------------------- @@ -833,3 +831,4 @@ are still running. .. _`PHP semaphore functions`: https://www.php.net/manual/en/book.sem.php .. _`Replica Set Read and Write Semantics`: https://docs.mongodb.com/manual/applications/replication/ .. _`ZooKeeper`: https://zookeeper.apache.org/ +.. _`readers–writer lock`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock From d485b85259ca9a9f46148b781dc5f8f47f02e160 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 15:47:05 +0200 Subject: [PATCH 466/752] Fix a PHPUnit deprecation --- form/unit_testing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/form/unit_testing.rst b/form/unit_testing.rst index ee096c167dd..795fd55c9ea 100644 --- a/form/unit_testing.rst +++ b/form/unit_testing.rst @@ -159,7 +159,7 @@ make sure the ``FormRegistry`` uses the created instance:: { private $objectManager; - protected function setUp() + protected function setUp(): void { // mock any dependencies $this->objectManager = $this->createMock(ObjectManager::class); From b7c8de755637db188b93b9ee4c6d7953bc749efc Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 16:05:37 +0200 Subject: [PATCH 467/752] [String] Allow to define slugger substitutions with PHP closures --- components/string.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/string.rst b/components/string.rst index 7d2ec49a198..10c0ab43e66 100644 --- a/components/string.rst +++ b/components/string.rst @@ -473,10 +473,19 @@ that only includes safe ASCII characters:: $slug = $slugger->slug('10% or 5€'); // $slug = '10-percent-or-5-euro' + // for more dynamic substitutions, pass a PHP closure instead of an array + $slugger = new AsciiSlugger('en', function ($string, $locale) { + return str_replace('❤️', 'love', $string); + }); + .. versionadded:: 5.1 The feature to define additional substitutions was introduced in Symfony 5.1. +.. versionadded:: 5.2 + + The feature to use a PHP closure to define substitutions was introduced in Symfony 5.2. + The separator between words is a dash (``-``) by default, but you can define another separator as the second argument:: From 8a9cf7adbd5d205a95a323de5adcff4ae783ec2d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 16:32:08 +0200 Subject: [PATCH 468/752] [Messneger] documented the delete_after_ack option --- messenger.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/messenger.rst b/messenger.rst index d20b46472c2..6107fcec87b 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1046,6 +1046,8 @@ group The Redis consumer group name symfony consumer Consumer name used in Redis consumer auto_setup Create the Redis group automatically? true auth The Redis password +delete_after_ack If ``true``, messages are deleted false + automatically after processing them serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` in Redis (the ``Redis::OPT_SERIALIZER`` option) @@ -1056,6 +1058,17 @@ stream_max_entries The maximum number of entries which ``0`` (which means "n tls Enable TLS support for the connection false ================== ===================================== ========================= +.. tip:: + + Set ``delete_after_ack`` to ``true`` (if you use a single group) or define + ``stream_max_entries`` (if you can estimate how many max entries is acceptable + in your case) to avoid memory leaks. Otherwise, all messages will remain + forever in Redis. + +.. versionadded:: 5.1 + + The ``delete_after_ack`` option was introduced in Symfony 5.1. + In Memory Transport ~~~~~~~~~~~~~~~~~~~ From 171b2631f9509b2b47f39ce28f7ff25799ad5cd3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 17:30:38 +0200 Subject: [PATCH 469/752] Rewords --- profiler/data_collector.rst | 117 ++++++++++++++++++------------------ 1 file changed, 59 insertions(+), 58 deletions(-) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 6d7e7ac47c6..276d1e88324 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -14,9 +14,13 @@ Creating a custom Data Collector A data collector is a PHP class that implements the :class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface`. For convenience, your data collectors can also extend from the -:class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector` class, which -implements the interface and provides some utilities and the ``$this->data`` -property to store the collected information. +:class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector` +class, which implements the interface and provides some utilities and the +``$this->data`` property to store the collected information. + +.. versionadded:: 5.2 + + The ``AbstractDataCollector`` class was introduced in Symfony 5.2. The following example shows a custom collector that stores information about the request:: @@ -24,11 +28,12 @@ request:: // src/DataCollector/RequestCollector.php namespace App\DataCollector; + use Symfony\Bundle\FrameworkBundle\DataCollector\AbstractDataCollector; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\DataCollector\DataCollector; - class RequestCollector extends DataCollector + class RequestCollector extends AbstractDataCollector { public function collect(Request $request, Response $response, \Throwable $exception = null) { @@ -37,25 +42,14 @@ request:: 'acceptable_content_types' => $request->getAcceptableContentTypes(), ]; } - - public function reset() - { - $this->data = []; - } - - public function getName() - { - return 'app.request_collector'; - } - - // ... } +These are the method that you can define in the data collector class: + :method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::collect` method: Stores the collected data in local properties (``$this->data`` if you extend - from :class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector`). - If the data to collect cannot be obtained through the request or response, - inject the needed services in the data collector. + from ``AbstractDataCollector``). If you need some services to collect the + data, inject those services in the data collector constructor. .. caution:: @@ -70,14 +64,16 @@ request:: to provide your own ``serialize()`` method. :method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::reset` method: - It's called between requests to reset the state of the profiler. Use it to - remove all the information collected with the ``collect()`` method. + It's called between requests to reset the state of the profiler. By default + it only empties the ``$this->data`` contents, but you can override this method + to do additional cleaning. :method:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollectorInterface::getName` method: Returns the collector identifier, which must be unique in the application. + By default it returns the FQCN of the data collector class, but you can + override this method to return a custom name (e.g. ``app.request_collector``). 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, lowercase and without white spaces. + :doc:`/testing/profiling`) so you may prefer using short strings instead of FQCN strings. The ``collect()`` method is called during the :ref:`kernel.response ` event. If you need to collect data that is only available later, implement @@ -85,17 +81,11 @@ event. If you need to collect data that is only available later, implement and define the ``lateCollect()`` method, which is invoked right before the profiler data serialization (during :ref:`kernel.terminate ` event). -.. _data_collector_tag: - -Enabling Custom Data Collectors -------------------------------- - -If you're using the :ref:`default services.yaml configuration ` -with ``autoconfigure``, then Symfony will automatically see your new data collector! -Your ``collect()`` method should be called next time your refresh. +.. note:: -If you're not using ``autoconfigure``, you can also :ref:`manually wire your service ` -and :doc:`tag ` it with ``data_collector``. + If you're using the :ref:`default services.yaml configuration ` + with ``autoconfigure``, then Symfony will start using your data collector after the + next page refresh. Otherwise, :ref:`enable the data collector by hand `. Adding Web Profiler Templates ----------------------------- @@ -104,10 +94,9 @@ The information collected by your data collector can be displayed both in the web debug toolbar and in the web profiler. To do so, you need to create a Twig template that includes some specific blocks. -However, first make your DataCollector to extends :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector` instead of :class:`Symfony\\Component\\HttpKernel\\DataCollector\\DataCollector`. When extending :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector`, you don't need to implement `getName` method; your collector FQDN is returned as identifier (you can also override it if needed). Though you need to implement `getTemplate` with the template you're going to use in the profiler (see below). - -Then you must add some getters in the data collector class to give the -template access to the collected information:: +First, add the ``getTemplate()`` method in your data collector class to return +the path of the Twig template to use. Then, add some *getters* to give the +template access to the collected information:::: // src/DataCollector/RequestCollector.php namespace App\DataCollector; @@ -140,6 +129,7 @@ block and set the value of two variables called ``icon`` and ``text``: .. code-block:: html+twig + {# templates/data_collector/template.html.twig #} {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} @@ -185,6 +175,7 @@ must also define additional blocks: .. code-block:: html+twig + {# templates/data_collector/template.html.twig #} {% extends '@WebProfiler/Profiler/layout.html.twig' %} {% block toolbar %} @@ -234,9 +225,25 @@ The ``menu`` and ``panel`` blocks are the only required blocks to define the contents displayed in the web profiler panel associated with this data collector. All blocks have access to the ``collector`` object. -That's it ! Your data collector is now accessible in the toolbar. +.. note:: + + The position of each panel in the toolbar is determined by the collector + priority, which can only be defined when :ref:`configuring the data collector by hand `. + +.. note:: + + If you're using the :ref:`default services.yaml configuration ` + with ``autoconfigure``, then Symfony will start displaying your collector data + in the toolbar after the next page refresh. Otherwise, :ref:`enable the data collector by hand `. + +.. _data_collector_tag: + +Enabling Custom Data Collectors +------------------------------- -If you don't use the default configuration with :ref:`autowire and autoconfigure `, you'll need to configure the data collector explicitely: +If you don't use Symfony's default configuration with +:ref:`autowire and autoconfigure ` +you'll need to configure the data collector explicitly: .. configuration-block:: @@ -247,10 +254,12 @@ If you don't use the default configuration with :ref:`autowire and autoconfigure App\DataCollector\RequestCollector: tags: - - name: data_collector + name: data_collector # must match the value returned by the getName() method - id: 'App\DataCollector\RequestCollector' - # optional priority + id: 'App\DataCollector\RequestCollector' + # optional template (it has more priority than the value returned by getTemplate()) + template: 'data_collector/template.html.twig' + # optional priority (positive or negative integer; default = 0) # priority: 300 .. code-block:: xml @@ -264,10 +273,13 @@ If you don't use the default configuration with :ref:`autowire and autoconfigure - + + + @@ -284,21 +296,10 @@ If you don't use the default configuration with :ref:`autowire and autoconfigure $services->set(RequestCollector::class) ->tag('data_collector', [ - 'id' => RequestCollector::class, + 'id' => RequestCollector::class, + // optional template (it has more priority than the value returned by getTemplate()) + 'template' => 'data_collector/template.html.twig', + // optional priority (positive or negative integer; default = 0) // 'priority' => 300, ]); }; - -The position of each panel in the toolbar is determined by the collector priority. -Priorities are defined as positive or negative integers and they default to ``0``. -Most built-in collectors use ``255`` as their priority. If you want your collector -to be displayed before them, use a higher value (like 300). - -.. versionadded:: 5.2 - - :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector` was introduced in Symfony 5.2. - -.. note:: - - Before the introduction of :class:`Symfony\\Bundle\\FrameworkBundle\\DataCollector\\AbstractDataCollector`, template path was defined in the service configuration (`template` key). This is still possible to define the template in the service configuration. In this case **template in service configuration takes precedence over template defined in data collector code**. - From b8e8449bb6a98a48e3a848711b539588a4b1dced Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 17:54:01 +0200 Subject: [PATCH 470/752] Minor reword --- messenger.rst | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/messenger.rst b/messenger.rst index e23e5fb76fa..ced96444d69 100644 --- a/messenger.rst +++ b/messenger.rst @@ -844,12 +844,6 @@ options. AMQP Transport ~~~~~~~~~~~~~~ -.. versionadded:: 5.2 - - Starting from Symfony 5.2, the AMQP transport can handle AMQPS DSN. - Be aware that using it without using CA certificate can throw an exception. - An alternative is to use AMQP DSN and specify the port to use. - .. versionadded:: 5.1 Starting from Symfony 5.1, the AMQP transport has moved to a separate package. @@ -869,10 +863,18 @@ The ``amqp`` transport configuration looks like this: # or use the AMQPS protocol MESSENGER_TRANSPORT_DSN=amqps://guest:guest@localhost/%2f/messages +.. versionadded:: 5.2 + + The AMQPS protocol support was introduced in Symfony 5.2. To use Symfony's built-in AMQP transport, you need the AMQP PHP extension. -If you want to use TLS/SSL encrypted AMQP you must provide a CA certificate. You need to set it using ``amqp.cacert = /etc/ssl/certs`` (path depends on your system) in your ``php.ini`` file or by setting the ``cacert`` parameter (e.g ``amqps://localhost?cacert=/etc/ssl/certs/``) -By default TLS/SSL encrypted AMQP uses port 5671. You can overwrite this behavior by setting the ``port`` parameter (e.g. ``amqps://localhost?cacert=/etc/ssl/certs/&port=12345``). +If you want to use TLS/SSL encrypted AMQP, you must also provide a CA certificate. +Define the certificate path in the ``amqp.cacert`` PHP.ini setting +(e.g. ``amqp.cacert = /etc/ssl/certs``) or in the ``cacert`` parameter of the +DSN (e.g ``amqps://localhost?cacert=/etc/ssl/certs/``). + +The default port used by TLS/SSL encrypted AMQP is 5671, but you can overwrite +it in the ``port`` parameter of the DSN (e.g. ``amqps://localhost?cacert=/etc/ssl/certs/&port=12345``). .. note:: From 1bfa68fd2279bcccc46461c4b4063b88b3701db5 Mon Sep 17 00:00:00 2001 From: soyuka Date: Thu, 6 Aug 2020 10:48:05 +0200 Subject: [PATCH 471/752] Document EventSourceHttpClient --- http_client.rst | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/http_client.rst b/http_client.rst index 3ead5a7a6f8..84f3f14f30b 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1143,6 +1143,52 @@ installed in your application:: ``CachingHttpClient`` accepts a third argument to set the options of the ``HttpCache``. +Consuming Server-Sent Events +---------------------------- + +This component provides an `EventSource`_ implementation to consume Server-Sent Events. +Use the :class:`Symfony\\Component\\HttpClient\\EventSourceHttpClient`, open a +connection to a server with the `text/event-stream` content type and consume the stream:: + + use Symfony\Component\HttpClient\EventSourceHttpClient; + + $client = new EventSourceHttpClient($client, 10); + $source = $client->connect('http://localhost:8080/events'); + while ($source) { + foreach ($client->stream($source, 2) as $r => $chunk) { + // You should handle these chunks yourself + if ($chunk->isTimeout()) { + dump([ + 'timeout' => [ + 'retry' => 1 + count($r->getInfo('previous_info') ?? []) + ], + ]); + continue; + } + if ($chunk->isLast()) { + dump([ + 'eof' => [ + 'retries' => count($r->getInfo('previous_info') ?? []) + ], + ]); + $source = null; + return; + } + + // This is a special ServerSentEvent chunk holding the pushed message + if ($chunk instanceof ServerSentEvent) { + dump($chunk); + } + } + } + +The default reconnection time is `10` seconds and is given onto the second argument of +the :class:`Symfony\\Component\\HttpClient\\EventSourceHttpClient`. The method +:method:`Symfony\\Component\\HttpClient\\Response\\AsyncResponse::stream` takes an +optional timeout argument. +The :class:`Symfony\\Component\\HttpClient\\Chunk\\ServerSentEvent` is a special chunk +capable of parsing an event stream as specified by the `EventSource`_ specification. + Interoperability ---------------- @@ -1419,3 +1465,4 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts .. _`libcurl`: https://curl.haxx.se/libcurl/ .. _`amphp/http-client`: https://packagist.org/packages/amphp/http-client .. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php +.. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource From da7c12b5ade242d9848f18fd423c84db15167b84 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 23 Sep 2020 12:14:57 +0200 Subject: [PATCH 472/752] Rewords and tweaks --- http_client.rst | 56 +++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/http_client.rst b/http_client.rst index 84f3f14f30b..7e46abfce4e 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1146,49 +1146,54 @@ installed in your application:: Consuming Server-Sent Events ---------------------------- -This component provides an `EventSource`_ implementation to consume Server-Sent Events. -Use the :class:`Symfony\\Component\\HttpClient\\EventSourceHttpClient`, open a -connection to a server with the `text/event-stream` content type and consume the stream:: +.. versionadded:: 5.2 + + The feature to consume server-sent events was introduced in Symfony 5.2. + +`Server-sent events`_ is an Internet standard used to push data to web pages. +Its JavaScript API is built around an `EventSource`_ object, which listens to +the events sent from some URL. The events are a stream of data (served with the +``text/event-stream`` MIME type) with the following format: + +.. code-block:: text + + data: This is the first message. + + data: This is the second message, it + data: has two lines. + + data: This is the third message. + +Symfony's HTTP client provides an EventSource implementation to consume these +server-sent events. Use the :class:`Symfony\\Component\\HttpClient\\EventSourceHttpClient` +to wrap your HTTP client, open a connection to a server that responds with a +``text/event-stream`` content type and consume the stream as follows:: use Symfony\Component\HttpClient\EventSourceHttpClient; + // the second optional argument is the reconnection time in seconds (default = 10) $client = new EventSourceHttpClient($client, 10); - $source = $client->connect('http://localhost:8080/events'); + $source = $client->connect('https://localhost:8080/events'); while ($source) { foreach ($client->stream($source, 2) as $r => $chunk) { - // You should handle these chunks yourself if ($chunk->isTimeout()) { - dump([ - 'timeout' => [ - 'retry' => 1 + count($r->getInfo('previous_info') ?? []) - ], - ]); + // ... continue; } + if ($chunk->isLast()) { - dump([ - 'eof' => [ - 'retries' => count($r->getInfo('previous_info') ?? []) - ], - ]); - $source = null; + // ... + return; } - // This is a special ServerSentEvent chunk holding the pushed message + // this is a special ServerSentEvent chunk holding the pushed message if ($chunk instanceof ServerSentEvent) { - dump($chunk); + // do something with the server event ... } } } -The default reconnection time is `10` seconds and is given onto the second argument of -the :class:`Symfony\\Component\\HttpClient\\EventSourceHttpClient`. The method -:method:`Symfony\\Component\\HttpClient\\Response\\AsyncResponse::stream` takes an -optional timeout argument. -The :class:`Symfony\\Component\\HttpClient\\Chunk\\ServerSentEvent` is a special chunk -capable of parsing an event stream as specified by the `EventSource`_ specification. - Interoperability ---------------- @@ -1465,4 +1470,5 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts .. _`libcurl`: https://curl.haxx.se/libcurl/ .. _`amphp/http-client`: https://packagist.org/packages/amphp/http-client .. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php +.. _`Server-sent events`: https://html.spec.whatwg.org/multipage/server-sent-events.html .. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource From 42e156e728f59e7fc0b6ef677eb24a22c68016c5 Mon Sep 17 00:00:00 2001 From: Alexander Menshchikov Date: Wed, 23 Sep 2020 20:31:47 +0300 Subject: [PATCH 473/752] New DI configuration syntax (PHP) instead of "legacy" --- controller/argument_value_resolver.rst | 12 +++- controller/upload_file.rst | 11 ++- doctrine/events.rst | 92 ++++++++++++++++---------- routing/custom_route_loader.rst | 12 +++- session/database.rst | 80 ++++++++++++++-------- 5 files changed, 136 insertions(+), 71 deletions(-) diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index cfd90123e51..00a57bfa0d9 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -226,11 +226,17 @@ and adding a priority. .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\ArgumentResolver\UserValueResolver; - $container->autowire(UserValueResolver::class) - ->addTag('controller.argument_value_resolver', ['priority' => 50]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(UserValueResolver::class) + ->tag('controller.argument_value_resolver', ['priority' => 50]) + ; + }; While adding a priority is optional, it's recommended to add one to make sure the expected value is injected. The built-in ``RequestAttributeValueResolver``, diff --git a/controller/upload_file.rst b/controller/upload_file.rst index 470fbf61dcd..86d2eb72206 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -317,10 +317,17 @@ Then, define a service for this class: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Service\FileUploader; - $container->autowire(FileUploader::class) - ->setArgument('$targetDirectory', '%brochures_directory%'); + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(FileUploader::class) + ->arg('$targetDirectory', '%brochures_directory%') + ; + }; Now you're ready to use this service in the controller:: diff --git a/doctrine/events.rst b/doctrine/events.rst index b1a1fc8e825..7864b3c22f6 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -198,22 +198,28 @@ with the ``doctrine.event_listener`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\SearchIndexer; - // listeners are applied by default to all Doctrine connections - $container->autowire(SearchIndexer::class) - ->addTag('doctrine.event_listener', [ - // this is the only required option for the lifecycle listener tag - 'event' => 'postPersist', + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + // listeners are applied by default to all Doctrine connections + $services->set(SearchIndexer::class) + ->tag('doctrine.event_listener', [ + // this is the only required option for the lifecycle listener tag + 'event' => 'postPersist', - // listeners can define their priority in case multiple listeners are associated - // to the same event (default priority = 0; higher numbers = listener is run earlier) - 'priority' => 500, + // listeners can define their priority in case multiple listeners are associated + // to the same event (default priority = 0; higher numbers = listener is run earlier) + 'priority' => 500, - # you can also restrict listeners to a specific Doctrine connection - 'connection' => 'default', - ]) - ; + # you can also restrict listeners to a specific Doctrine connection + 'connection' => 'default', + ]) + ; + }; .. tip:: @@ -314,29 +320,35 @@ with the ``doctrine.orm.entity_listener`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Entity\User; use App\EventListener\UserChangedNotifier; - $container->autowire(UserChangedNotifier::class) - ->addTag('doctrine.orm.entity_listener', [ - // These are the options required to define the entity listener: - 'event' => 'postUpdate', - 'entity' => User::class, + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(UserChangedNotifier::class) + ->tag('doctrine.orm.entity_listener', [ + // These are the options required to define the entity listener: + 'event' => 'postUpdate', + 'entity' => User::class, - // These are other options that you may define if needed: + // These are other options that you may define if needed: - // set the 'lazy' option to TRUE to only instantiate listeners when they are used - // 'lazy' => true, + // set the 'lazy' option to TRUE to only instantiate listeners when they are used + // 'lazy' => true, - // set the 'entity_manager' option if the listener is not associated to the default manager - // 'entity_manager' => 'custom', + // set the 'entity_manager' option if the listener is not associated to the default manager + // 'entity_manager' => 'custom', - // by default, Symfony looks for a method called after the event (e.g. postUpdate()) - // if it doesn't exist, it tries to execute the '__invoke()' method, but you can - // configure a custom method name with the 'method' option - // 'method' => 'checkUserChanges', - ]) - ; + // by default, Symfony looks for a method called after the event (e.g. postUpdate()) + // if it doesn't exist, it tries to execute the '__invoke()' method, but you can + // configure a custom method name with the 'method' option + // 'method' => 'checkUserChanges', + ]) + ; + }; Doctrine Lifecycle Subscribers ------------------------------ @@ -434,11 +446,17 @@ with the ``doctrine.event_subscriber`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\DatabaseActivitySubscriber; - $container->autowire(DatabaseActivitySubscriber::class) - ->addTag('doctrine.event_subscriber') - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(DatabaseActivitySubscriber::class) + ->tag('doctrine.event_subscriber') + ; + }; If you need to associate the subscriber with a specific Doctrine connection, you can do it in the service configuration: @@ -473,11 +491,17 @@ can do it in the service configuration: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\DatabaseActivitySubscriber; - $container->autowire(DatabaseActivitySubscriber::class) - ->addTag('doctrine.event_subscriber', ['connection' => 'default']) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(DatabaseActivitySubscriber::class) + ->tag('doctrine.event_subscriber', ['connection' => 'default']) + ; + }; .. tip:: diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 1aa1c882f94..a339ec74f61 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -327,11 +327,17 @@ Now define a service for the ``ExtraLoader``: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Routing\ExtraLoader; - $container->autowire(ExtraLoader::class) - ->addTag('routing.loader') - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(ExtraLoader::class) + ->tag('routing.loader') + ; + }; Notice the tag ``routing.loader``. All services with this *tag* will be marked as potential route loaders and added as specialized route loaders to the diff --git a/session/database.rst b/session/database.rst index 8766ab9f2a8..e01d32c6d79 100644 --- a/session/database.rst +++ b/session/database.rst @@ -217,16 +217,22 @@ first register a new handler service with your database credentials: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - $storageDefinition = $container->autowire(PdoSessionHandler::class) - ->setArguments([ - '%env(DATABASE_URL)%', - // you can also use PDO configuration, but requires passing two arguments: - // 'mysql:dbname=mydatabase; host=myhost; port=myport', - // ['db_username' => 'myuser', 'db_password' => 'mypassword'], - ]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(PdoSessionHandler::class) + ->args([ + '%env(DATABASE_URL)%', + // you can also use PDO configuration, but requires passing two arguments: + // 'mysql:dbname=mydatabase; host=myhost; port=myport', + // ['db_username' => 'myuser', 'db_password' => 'mypassword'], + ]) + ; + }; Next, use the :ref:`handler_id ` configuration option to tell Symfony to use this service as the session handler: @@ -306,15 +312,20 @@ passed to the ``PdoSessionHandler`` service: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - // ... - $container->autowire(PdoSessionHandler::class) - ->setArguments([ - '%env(DATABASE_URL)%', - ['db_table' => 'customer_session', 'db_id_col' => 'guid'], - ]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(PdoSessionHandler::class) + ->args([ + '%env(DATABASE_URL)%', + ['db_table' => 'customer_session', 'db_id_col' => 'guid'], + ]) + ; + }; These are parameters that you can configure: @@ -466,13 +477,19 @@ the MongoDB connection as argument: .. code-block:: php // config/services.php - use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; + namespace Symfony\Component\DependencyInjection\Loader\Configurator; - $storageDefinition = $container->autowire(MongoDbSessionHandler::class) - ->setArguments([ - new Reference('doctrine_mongodb.odm.default_connection'), - ]) - ; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; + + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(MongoDbSessionHandler::class) + ->args([ + service('doctrine_mongodb.odm.default_connection'), + ]) + ; + }; Next, use the :ref:`handler_id ` configuration option to tell Symfony to use this service as the session handler: @@ -569,15 +586,20 @@ configure these values with the second argument passed to the .. code-block:: php // config/services.php - use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; - // ... + namespace Symfony\Component\DependencyInjection\Loader\Configurator; - $container->autowire(MongoDbSessionHandler::class) - ->setArguments([ - '...', - ['id_field' => '_guid', 'expiry_field' => 'eol'], - ]) - ; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; + + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(MongoDbSessionHandler::class) + ->args([ + service('doctrine_mongodb.odm.default_connection'), + ['id_field' => '_guid', 'expiry_field' => 'eol'],, + ]) + ; + }; These are parameters that you can configure: From 295c688499218b75ea40e940e5d55b514509fa7a Mon Sep 17 00:00:00 2001 From: David Buchmann Date: Thu, 24 Sep 2020 10:28:44 +0200 Subject: [PATCH 474/752] simple_preauth was removed in symfony 5.0 https://github.com/symfony/symfony/blob/master/UPGRADE-5.0.md#securitybundle --- reference/configuration/security.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reference/configuration/security.rst b/reference/configuration/security.rst index 9b5be8b387d..b0763e37b59 100644 --- a/reference/configuration/security.rst +++ b/reference/configuration/security.rst @@ -395,8 +395,6 @@ depend on the authentication mechanism, which can be any of these: # ... remote_user: # ... - simple_preauth: - # ... guard: # ... form_login: @@ -405,8 +403,6 @@ depend on the authentication mechanism, which can be any of these: # ... json_login: # ... - simple_form: - # ... http_basic: # ... http_basic_ldap: From 303419c615c39757d07b849aadde377bcff28f2c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Sep 2020 16:36:54 +0200 Subject: [PATCH 475/752] [Messenger] Documented the delete_after_reject option --- messenger.rst | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/messenger.rst b/messenger.rst index 90d8c1c80a6..14cce1c4931 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1149,25 +1149,27 @@ a running Redis server (^5.0). A number of options can be configured via the DSN or via the ``options`` key under the transport in ``messenger.yaml``: -================== ===================================== ========================= - Option Description Default -================== ===================================== ========================= -stream The Redis stream name messages -group The Redis consumer group name symfony -consumer Consumer name used in Redis consumer -auto_setup Create the Redis group automatically? true -auth The Redis password -delete_after_ack If ``true``, messages are deleted false - automatically after processing them -serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` - in Redis (the - ``Redis::OPT_SERIALIZER`` option) -stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") - the stream will be trimmed to. Set - it to a large enough number to - avoid losing pending messages -tls Enable TLS support for the connection false -================== ===================================== ========================= +=================== ===================================== ========================= + Option Description Default +=================== ===================================== ========================= +stream The Redis stream name messages +group The Redis consumer group name symfony +consumer Consumer name used in Redis consumer +auto_setup Create the Redis group automatically? true +auth The Redis password +delete_after_ack If ``true``, messages are deleted false + automatically after processing them +delete_after_reject If ``true``, messages are deleted true + automatically if they are rejected +serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` + in Redis (the + ``Redis::OPT_SERIALIZER`` option) +stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") + the stream will be trimmed to. Set + it to a large enough number to + avoid losing pending messages +tls Enable TLS support for the connection false +=================== ===================================== ========================= .. tip:: @@ -1180,6 +1182,10 @@ tls Enable TLS support for the connection false The ``delete_after_ack`` option was introduced in Symfony 5.1. +.. versionadded:: 5.2 + + The ``delete_after_reject`` option was introduced in Symfony 5.2. + In Memory Transport ~~~~~~~~~~~~~~~~~~~ From 7db3301e3cc1d22bd7df4be39391517c5c900bf5 Mon Sep 17 00:00:00 2001 From: Alexander Menshchikov Date: Wed, 23 Sep 2020 20:31:47 +0300 Subject: [PATCH 476/752] New DI configuration syntax (PHP) instead of "legacy" (cherry picked from commit 42e156e728f59e7fc0b6ef677eb24a22c68016c5) --- controller/argument_value_resolver.rst | 12 +++- controller/upload_file.rst | 11 ++- doctrine/events.rst | 92 ++++++++++++++++---------- routing/custom_route_loader.rst | 12 +++- session/database.rst | 80 ++++++++++++++-------- 5 files changed, 136 insertions(+), 71 deletions(-) diff --git a/controller/argument_value_resolver.rst b/controller/argument_value_resolver.rst index cfd90123e51..00a57bfa0d9 100644 --- a/controller/argument_value_resolver.rst +++ b/controller/argument_value_resolver.rst @@ -226,11 +226,17 @@ and adding a priority. .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\ArgumentResolver\UserValueResolver; - $container->autowire(UserValueResolver::class) - ->addTag('controller.argument_value_resolver', ['priority' => 50]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(UserValueResolver::class) + ->tag('controller.argument_value_resolver', ['priority' => 50]) + ; + }; While adding a priority is optional, it's recommended to add one to make sure the expected value is injected. The built-in ``RequestAttributeValueResolver``, diff --git a/controller/upload_file.rst b/controller/upload_file.rst index 470fbf61dcd..86d2eb72206 100644 --- a/controller/upload_file.rst +++ b/controller/upload_file.rst @@ -317,10 +317,17 @@ Then, define a service for this class: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Service\FileUploader; - $container->autowire(FileUploader::class) - ->setArgument('$targetDirectory', '%brochures_directory%'); + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(FileUploader::class) + ->arg('$targetDirectory', '%brochures_directory%') + ; + }; Now you're ready to use this service in the controller:: diff --git a/doctrine/events.rst b/doctrine/events.rst index b1a1fc8e825..7864b3c22f6 100644 --- a/doctrine/events.rst +++ b/doctrine/events.rst @@ -198,22 +198,28 @@ with the ``doctrine.event_listener`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\SearchIndexer; - // listeners are applied by default to all Doctrine connections - $container->autowire(SearchIndexer::class) - ->addTag('doctrine.event_listener', [ - // this is the only required option for the lifecycle listener tag - 'event' => 'postPersist', + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + // listeners are applied by default to all Doctrine connections + $services->set(SearchIndexer::class) + ->tag('doctrine.event_listener', [ + // this is the only required option for the lifecycle listener tag + 'event' => 'postPersist', - // listeners can define their priority in case multiple listeners are associated - // to the same event (default priority = 0; higher numbers = listener is run earlier) - 'priority' => 500, + // listeners can define their priority in case multiple listeners are associated + // to the same event (default priority = 0; higher numbers = listener is run earlier) + 'priority' => 500, - # you can also restrict listeners to a specific Doctrine connection - 'connection' => 'default', - ]) - ; + # you can also restrict listeners to a specific Doctrine connection + 'connection' => 'default', + ]) + ; + }; .. tip:: @@ -314,29 +320,35 @@ with the ``doctrine.orm.entity_listener`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Entity\User; use App\EventListener\UserChangedNotifier; - $container->autowire(UserChangedNotifier::class) - ->addTag('doctrine.orm.entity_listener', [ - // These are the options required to define the entity listener: - 'event' => 'postUpdate', - 'entity' => User::class, + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(UserChangedNotifier::class) + ->tag('doctrine.orm.entity_listener', [ + // These are the options required to define the entity listener: + 'event' => 'postUpdate', + 'entity' => User::class, - // These are other options that you may define if needed: + // These are other options that you may define if needed: - // set the 'lazy' option to TRUE to only instantiate listeners when they are used - // 'lazy' => true, + // set the 'lazy' option to TRUE to only instantiate listeners when they are used + // 'lazy' => true, - // set the 'entity_manager' option if the listener is not associated to the default manager - // 'entity_manager' => 'custom', + // set the 'entity_manager' option if the listener is not associated to the default manager + // 'entity_manager' => 'custom', - // by default, Symfony looks for a method called after the event (e.g. postUpdate()) - // if it doesn't exist, it tries to execute the '__invoke()' method, but you can - // configure a custom method name with the 'method' option - // 'method' => 'checkUserChanges', - ]) - ; + // by default, Symfony looks for a method called after the event (e.g. postUpdate()) + // if it doesn't exist, it tries to execute the '__invoke()' method, but you can + // configure a custom method name with the 'method' option + // 'method' => 'checkUserChanges', + ]) + ; + }; Doctrine Lifecycle Subscribers ------------------------------ @@ -434,11 +446,17 @@ with the ``doctrine.event_subscriber`` tag: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\DatabaseActivitySubscriber; - $container->autowire(DatabaseActivitySubscriber::class) - ->addTag('doctrine.event_subscriber') - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(DatabaseActivitySubscriber::class) + ->tag('doctrine.event_subscriber') + ; + }; If you need to associate the subscriber with a specific Doctrine connection, you can do it in the service configuration: @@ -473,11 +491,17 @@ can do it in the service configuration: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\DatabaseActivitySubscriber; - $container->autowire(DatabaseActivitySubscriber::class) - ->addTag('doctrine.event_subscriber', ['connection' => 'default']) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(DatabaseActivitySubscriber::class) + ->tag('doctrine.event_subscriber', ['connection' => 'default']) + ; + }; .. tip:: diff --git a/routing/custom_route_loader.rst b/routing/custom_route_loader.rst index 1aa1c882f94..a339ec74f61 100644 --- a/routing/custom_route_loader.rst +++ b/routing/custom_route_loader.rst @@ -327,11 +327,17 @@ Now define a service for the ``ExtraLoader``: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\Routing\ExtraLoader; - $container->autowire(ExtraLoader::class) - ->addTag('routing.loader') - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(ExtraLoader::class) + ->tag('routing.loader') + ; + }; Notice the tag ``routing.loader``. All services with this *tag* will be marked as potential route loaders and added as specialized route loaders to the diff --git a/session/database.rst b/session/database.rst index 8766ab9f2a8..e01d32c6d79 100644 --- a/session/database.rst +++ b/session/database.rst @@ -217,16 +217,22 @@ first register a new handler service with your database credentials: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - $storageDefinition = $container->autowire(PdoSessionHandler::class) - ->setArguments([ - '%env(DATABASE_URL)%', - // you can also use PDO configuration, but requires passing two arguments: - // 'mysql:dbname=mydatabase; host=myhost; port=myport', - // ['db_username' => 'myuser', 'db_password' => 'mypassword'], - ]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(PdoSessionHandler::class) + ->args([ + '%env(DATABASE_URL)%', + // you can also use PDO configuration, but requires passing two arguments: + // 'mysql:dbname=mydatabase; host=myhost; port=myport', + // ['db_username' => 'myuser', 'db_password' => 'mypassword'], + ]) + ; + }; Next, use the :ref:`handler_id ` configuration option to tell Symfony to use this service as the session handler: @@ -306,15 +312,20 @@ passed to the ``PdoSessionHandler`` service: .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; - // ... - $container->autowire(PdoSessionHandler::class) - ->setArguments([ - '%env(DATABASE_URL)%', - ['db_table' => 'customer_session', 'db_id_col' => 'guid'], - ]) - ; + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(PdoSessionHandler::class) + ->args([ + '%env(DATABASE_URL)%', + ['db_table' => 'customer_session', 'db_id_col' => 'guid'], + ]) + ; + }; These are parameters that you can configure: @@ -466,13 +477,19 @@ the MongoDB connection as argument: .. code-block:: php // config/services.php - use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; + namespace Symfony\Component\DependencyInjection\Loader\Configurator; - $storageDefinition = $container->autowire(MongoDbSessionHandler::class) - ->setArguments([ - new Reference('doctrine_mongodb.odm.default_connection'), - ]) - ; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; + + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(MongoDbSessionHandler::class) + ->args([ + service('doctrine_mongodb.odm.default_connection'), + ]) + ; + }; Next, use the :ref:`handler_id ` configuration option to tell Symfony to use this service as the session handler: @@ -569,15 +586,20 @@ configure these values with the second argument passed to the .. code-block:: php // config/services.php - use Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler; - // ... + namespace Symfony\Component\DependencyInjection\Loader\Configurator; - $container->autowire(MongoDbSessionHandler::class) - ->setArguments([ - '...', - ['id_field' => '_guid', 'expiry_field' => 'eol'], - ]) - ; + use Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler; + + return static function (ContainerConfigurator $container) { + $services = $configurator->services(); + + $services->set(MongoDbSessionHandler::class) + ->args([ + service('doctrine_mongodb.odm.default_connection'), + ['id_field' => '_guid', 'expiry_field' => 'eol'],, + ]) + ; + }; These are parameters that you can configure: From 11f45325f49f518244ea669e1ec7327e2397f833 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 24 Sep 2020 17:57:18 +0200 Subject: [PATCH 477/752] User service() instead of ref() --- service_container.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container.rst b/service_container.rst index 95ef942fab6..24fb39dc982 100644 --- a/service_container.rst +++ b/service_container.rst @@ -483,7 +483,7 @@ all their types (string, boolean, array, binary and PHP constant parameters). However, there is another type of parameter related to services. In YAML config, any string which starts with ``@`` is considered as the ID of a service, instead of a regular string. In XML config, use the ``type="service"`` type for the -parameter and in PHP config use the ``ref`` function: +parameter and in PHP config use the ``service()`` function: .. configuration-block:: From a2ad274caafaa4d4bafa5f28e6a4768519c8d0b5 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Mon, 14 Sep 2020 18:16:20 -0400 Subject: [PATCH 478/752] Translatable objects --- reference/twig_reference.rst | 29 ++++++++++++++++++++++++++++- translation.rst | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index 0a6c9db3154..ed02f32d633 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -304,6 +304,27 @@ impersonation_exit_url It's similar to the `impersonation_exit_path`_ function, but it generates absolute URLs instead of relative URLs. +t +~ + +.. code-block:: twig + + {{ t(message, parameters = [], domain = 'messages')|trans }} + +``message`` + **type**: ``string`` +``parameters`` *(optional)* + **type**: ``array`` **default**: ``[]`` +``domain`` *(optional)* + **type**: ``string`` **default**: ``messages`` + +.. versionadded:: 5.2 + + The ``t()`` function was introduced in Symfony 5.2. + +Creates a ``Translatable`` object that can be passed to the +:ref:`trans filter `. + Form Related Functions ~~~~~~~~~~~~~~~~~~~~~~ @@ -341,6 +362,8 @@ Makes a technical name human readable (i.e. replaces underscores by spaces or transforms camelCase text like ``helloWorld`` to ``hello world`` and then capitalizes the string). +.. _reference-twig-filter-trans: + trans ~~~~~ @@ -349,7 +372,7 @@ trans {{ message|trans(arguments = [], domain = null, locale = null) }} ``message`` - **type**: ``string`` + **type**: ``string`` | ``Translatable`` ``arguments`` *(optional)* **type**: ``array`` **default**: ``[]`` ``domain`` *(optional)* @@ -357,6 +380,10 @@ trans ``locale`` *(optional)* **type**: ``string`` **default**: ``null`` +.. versionadded:: 5.2 + + ``message`` accepting ``Translatable`` as a valid type was introduced in Symfony 5.2. + Translates the text into the current language. More information in :ref:`Translation Filters `. diff --git a/translation.rst b/translation.rst index 19525ea38ce..2c7fc7922b6 100644 --- a/translation.rst +++ b/translation.rst @@ -292,6 +292,41 @@ To manage these situations, Symfony follows the `ICU MessageFormat`_ syntax by using PHP's :phpclass:`MessageFormatter` class. Read more about this in :doc:`/translation/message_format`. +Translatable Objects +-------------------- + +.. versionadded:: 5.2 + + Translatable objects were introduced in Symfony 5.2. + +Sometimes you may want to create a message, but at the time of creation aren't +sure how it would be translated. For example, it could be translated multiple +times if intended to be displayed to multiple users. + +Using translatable objects also allows preparing translations without having a +dependency on an entrypoint (such as a router) where the context for performing +the translation is provided. For example, entities could prepare translatable +strings (such as labels) without the need for a translator. + +Instead of translating a string at the time of creation, a ``Translatable`` +object can be created that can then be translated when used. Later this message +can be translated with a translator in either PHP or in Twig. + +PHP:: + + $message = new Translatable('Symfony is great!'); + $message = t('Symfony is great!'); + + Translatable::trans($translator, $message); + +Twig: + +.. code-block:: html+twig + + {% set message = t('Symfony is great!') %} + +

{{ message|trans }}

+ .. _translation-in-templates: Translations in Templates From 5aa74875e52cdaab6bbbe7e1f7967ac07a7c56b2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 12:24:17 +0200 Subject: [PATCH 479/752] Minor rewords --- reference/twig_reference.rst | 2 ++ translation.rst | 40 ++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/reference/twig_reference.rst b/reference/twig_reference.rst index ed02f32d633..b70dbb0e0aa 100644 --- a/reference/twig_reference.rst +++ b/reference/twig_reference.rst @@ -304,6 +304,8 @@ impersonation_exit_url It's similar to the `impersonation_exit_path`_ function, but it generates absolute URLs instead of relative URLs. +.. _reference-twig-function-t: + t ~ diff --git a/translation.rst b/translation.rst index 2c7fc7922b6..1c667e2e3ca 100644 --- a/translation.rst +++ b/translation.rst @@ -299,33 +299,37 @@ Translatable Objects Translatable objects were introduced in Symfony 5.2. -Sometimes you may want to create a message, but at the time of creation aren't -sure how it would be translated. For example, it could be translated multiple -times if intended to be displayed to multiple users. +Sometimes translating contents in templates is cumbersome because you need the +original message, the translation parameters and the translation domain for +each content. Making the translation in the controller or services simplifies +your templates, but requires injecting the translator service in different +parts of your application and mocking it in your tests. -Using translatable objects also allows preparing translations without having a -dependency on an entrypoint (such as a router) where the context for performing -the translation is provided. For example, entities could prepare translatable -strings (such as labels) without the need for a translator. +Instead of translating a string at the time of creation, you can use a +"translatable object", which is an instance of the +:class:`Symfony\\Component\\Translation\\Translatable` class. This object stores +all the information needed to fully translate its contents when needed:: -Instead of translating a string at the time of creation, a ``Translatable`` -object can be created that can then be translated when used. Later this message -can be translated with a translator in either PHP or in Twig. - -PHP:: + use Symfony\Component\Translation\Translatable; + // the first argument is required and it's the original message $message = new Translatable('Symfony is great!'); - $message = t('Symfony is great!'); - - Translatable::trans($translator, $message); + // the optional second argument defines the translation parameters and + // the optional third argument is the translation domain + $status = new Translatable('order.status', ['order' => $order], 'store'); -Twig: +Templates are now much simpler because you can pass translatable objects to the +``trans`` filter: .. code-block:: html+twig - {% set message = t('Symfony is great!') %} -

{{ message|trans }}

+

{{ status|trans }}

+ +.. tip:: + + There's also a :ref:`function called t() `, + available both in Twig and PHP, as a shortcut to create translatable objects. .. _translation-in-templates: From a1e19e2d67b1f92cb444d24c52835f6b18c08a3b Mon Sep 17 00:00:00 2001 From: Yann LUCAS Date: Wed, 23 Sep 2020 14:26:28 +0200 Subject: [PATCH 480/752] [Mailer] Added documentation for Sendinblue bridge --- mailer.rst | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/mailer.rst b/mailer.rst index 7c75e72032b..e2c166af89c 100644 --- a/mailer.rst +++ b/mailer.rst @@ -38,9 +38,9 @@ Using a 3rd Party Transport Instead of using your own SMTP server, you can send emails via a 3rd party provider. Mailer supports several - install whichever you want: -================== ============================================= +================== ============================================== Service Install with -================== ============================================= +================== ============================================== Amazon SES ``composer require symfony/amazon-mailer`` Gmail ``composer require symfony/google-mailer`` MailChimp ``composer require symfony/mailchimp-mailer`` @@ -48,7 +48,8 @@ Mailgun ``composer require symfony/mailgun-mailer`` Mailjet ``composer require symfony/mailjet-mailer`` Postmark ``composer require symfony/postmark-mailer`` SendGrid ``composer require symfony/sendgrid-mailer`` -================== ============================================= +Sendinblue ``composer require symfony/sendinblue-mailer`` +================== ============================================== Each library includes a :ref:`Symfony Flex recipe ` that will add a configuration example to your ``.env`` file. For example, suppose you want to @@ -87,17 +88,18 @@ transport, but you can force to use one: This table shows the full list of available DSN formats for each third party provider: -==================== ============================================= =========================================== ======================================== - Provider SMTP HTTP API -==================== ============================================= =========================================== ======================================== - Amazon SES ses+smtp://ACCESS_KEY:SECRET_KEY@default ses+https://ACCESS_KEY:SECRET_KEY@default ses+api://ACCESS_KEY:SECRET_KEY@default - Google Gmail gmail+smtp://USERNAME:PASSWORD@default n/a n/a - Mailchimp Mandrill mandrill+smtp://USERNAME:PASSWORD@default mandrill+https://KEY@default mandrill+api://KEY@default - Mailgun mailgun+smtp://USERNAME:PASSWORD@default mailgun+https://KEY:DOMAIN@default mailgun+api://KEY:DOMAIN@default - Mailjet mailjet+smtp://ACCESS_KEY:SECRET_KEY@default n/a mailjet+api://ACCESS_KEY:SECRET_KEY@default - Postmark postmark+smtp://ID:ID@default n/a postmark+api://KEY@default - Sendgrid sendgrid+smtp://apikey:KEY@default n/a sendgrid+api://KEY@default -==================== ============================================= =========================================== ======================================== +==================== ==================================================== =========================================== ======================================== + Provider SMTP HTTP API +==================== ==================================================== =========================================== ======================================== + Amazon SES ses+smtp://ACCESS_KEY:SECRET_KEY@default ses+https://ACCESS_KEY:SECRET_KEY@default ses+api://ACCESS_KEY:SECRET_KEY@default + Google Gmail gmail+smtp://USERNAME:PASSWORD@default n/a n/a + Mailchimp Mandrill mandrill+smtp://USERNAME:PASSWORD@default mandrill+https://KEY@default mandrill+api://KEY@default + Mailgun mailgun+smtp://USERNAME:PASSWORD@default mailgun+https://KEY:DOMAIN@default mailgun+api://KEY:DOMAIN@default + Mailjet mailjet+smtp://ACCESS_KEY:SECRET_KEY@default n/a mailjet+api://ACCESS_KEY:SECRET_KEY@default + Postmark postmark+smtp://ID:ID@default n/a postmark+api://KEY@default + Sendgrid sendgrid+smtp://apikey:KEY@default n/a sendgrid+api://KEY@default + Sendinblue sendinblue+smtp://apikey:USERNAME:PASSWORD@default n/a sendinblue+api://KEY@default +==================== ==================================================== =========================================== ======================================== .. caution:: From 6e81b35e4cf3de24228ae227196c593776045165 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 14:17:36 +0200 Subject: [PATCH 481/752] Added the versionadded directive --- mailer.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mailer.rst b/mailer.rst index e2c166af89c..0745bc014de 100644 --- a/mailer.rst +++ b/mailer.rst @@ -51,6 +51,10 @@ SendGrid ``composer require symfony/sendgrid-mailer`` Sendinblue ``composer require symfony/sendinblue-mailer`` ================== ============================================== +.. versionadded:: 5.2 + + The Sendinblue integration was introduced in Symfony 5.2. + Each library includes a :ref:`Symfony Flex recipe ` that will add a configuration example to your ``.env`` file. For example, suppose you want to use SendGrid. First, install it: From 82880aaee60fc0286d67f50a63cb1fe6bd4c485e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 14:50:32 +0200 Subject: [PATCH 482/752] [Validator] Document the invalidDateTimeMessage option --- reference/constraints/Range.rst | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index 4470d26eb07..d5b473362dd 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -6,6 +6,7 @@ Validates that a given number or ``DateTime`` object is *between* some minimum a ========== =================================================================== Applies to :ref:`property or method ` Options - `groups`_ + - `invalidDateTimeMessage`_ - `invalidMessage`_ - `max`_ - `maxMessage`_ @@ -316,13 +317,33 @@ Options .. include:: /reference/constraints/_groups-option.rst.inc +invalidDateTimeMessage +~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``This value should be a valid number.`` + +.. versionadded:: 5.2 + + The ``invalidDateTimeMessage`` option was introduced in Symfony 5.2. + +The message displayed when the ``min`` and ``max`` values are PHP datetimes but +the given value is not. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +=============== ============================================================== + invalidMessage ~~~~~~~~~~~~~~ **type**: ``string`` **default**: ``This value should be a valid number.`` -The message that will be shown if the underlying value is not a number (per -the :phpfunction:`is_numeric` PHP function). +The message displayed when the ``min`` and ``max`` values are numeric (per +the :phpfunction:`is_numeric` PHP function) but the given value is not. You can use the following parameters in this message: From 6c5a809675c7a4cb7ae86969356998ff5ca0aa44 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 15:29:18 +0200 Subject: [PATCH 483/752] Minor tweak --- http_client.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/http_client.rst b/http_client.rst index f7aa8546da9..51cd799fea6 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1462,9 +1462,12 @@ However, using ``MockResponse`` allows simulating chunked responses and timeouts $mockResponse = new MockResponse($body()); -Using the Symfony Framework, if you want to use your callback in functional tests, you can do as follow: +.. versionadded:: 5.2 + + The feature explained below was introduced in Symfony 5.2. -First, create an invokable or iterable class responsible of generating the response:: +Finally, you can also create an invokable or iterable class that generates the +responses and use it as a callback in functional tests:: namespace App\Tests; @@ -1481,7 +1484,7 @@ First, create an invokable or iterable class responsible of generating the respo } } -Then configure the framework to use your callback: +Then configure Symfony to use your callback: .. configuration-block:: @@ -1535,9 +1538,6 @@ Then configure the framework to use your callback: ], ]); - -The ``MockHttpClient`` will now be used in test environment with your callback to generate responses. - .. _`cURL PHP extension`: https://www.php.net/curl .. _`PSR-17`: https://www.php-fig.org/psr/psr-17/ .. _`PSR-18`: https://www.php-fig.org/psr/psr-18/ From 5cb0e366431c938c541a64d5220a0f13c38ba9b6 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 13 Aug 2020 16:59:22 +0200 Subject: [PATCH 484/752] [VarDumper] Document the VAR_DUMPER_FORMAT=server format --- components/var_dumper.rst | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/components/var_dumper.rst b/components/var_dumper.rst index e89c822c21f..44bb21c6304 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -66,7 +66,7 @@ current PHP SAPI: You can also select the output format explicitly defining the ``VAR_DUMPER_FORMAT`` environment variable and setting its value to either - ``html`` or ``cli``. + ``html``, ``cli`` or :ref:`server `. .. note:: @@ -186,6 +186,39 @@ Then you can use the following command to start a server out-of-the-box: $ ./vendor/bin/var-dump-server [OK] Server listening on tcp://127.0.0.1:9912 +.. _var-dumper-dump-server-format: + +Debug any project with the server format +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +There is a way to force the ``VarDumper`` to dump to a server, without the need to configure anything in your +application: by using the ``VAR_DUMPER_FORMAT=server`` environment variable. +It is especially useful to debug any project (as soon as the VarDumper component is installed), +without altering its code by: + +* starting a server: + + .. code-block:: terminal + + $ ./vendor/bin/var-dump-server + +* running your code with the ``VAR_DUMPER_FORMAT=server`` env variable. For instance, for a CLI command: + + .. code-block:: terminal + + $ VAR_DUMPER_FORMAT=server [your-cli-command] + + .. tip:: + + If your project loads environment variables from a dotenv file, you can set the ``VAR_DUMPER_FORMAT=server`` + environment variable in there as well. + +.. note:: + + The host used to contact the server when using the ``server`` format is the one configured by the + ``VAR_DUMPER_SERVER`` var or defaults to ``127.0.0.1:9912``. + But you can configure the host through the ``VAR_DUMPER_FORMAT=tcp://127.0.0.1:1234`` environment variable as well. + DebugBundle and Twig Integration -------------------------------- From 738ed6907167c68d1657a9a6b009ef69caf18d95 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 16:19:01 +0200 Subject: [PATCH 485/752] Reword --- components/var_dumper.rst | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/components/var_dumper.rst b/components/var_dumper.rst index 44bb21c6304..b661bd7a44a 100644 --- a/components/var_dumper.rst +++ b/components/var_dumper.rst @@ -188,36 +188,36 @@ Then you can use the following command to start a server out-of-the-box: .. _var-dumper-dump-server-format: -Debug any project with the server format -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Configuring the Dump Server with Environment Variables +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -There is a way to force the ``VarDumper`` to dump to a server, without the need to configure anything in your -application: by using the ``VAR_DUMPER_FORMAT=server`` environment variable. -It is especially useful to debug any project (as soon as the VarDumper component is installed), -without altering its code by: +.. versionadded:: 5.2 -* starting a server: + The ``VAR_DUMPER_FORMAT=server`` feature was introduced in Symfony 5.2. - .. code-block:: terminal +If you prefer to not modify the application configuration (e.g. to quickly debug +a project given to you) use the ``VAR_DUMPER_FORMAT`` env var. - $ ./vendor/bin/var-dump-server +First, start the server as usual: -* running your code with the ``VAR_DUMPER_FORMAT=server`` env variable. For instance, for a CLI command: +.. code-block:: terminal - .. code-block:: terminal + $ ./vendor/bin/var-dump-server - $ VAR_DUMPER_FORMAT=server [your-cli-command] +Then, run your code with the ``VAR_DUMPER_FORMAT=server`` env var by configuring +this value in the :ref:`.env file of your application `. For +console commands, you can also define this env var as follows: - .. tip:: +.. code-block:: terminal - If your project loads environment variables from a dotenv file, you can set the ``VAR_DUMPER_FORMAT=server`` - environment variable in there as well. + $ VAR_DUMPER_FORMAT=server [your-cli-command] .. note:: - The host used to contact the server when using the ``server`` format is the one configured by the - ``VAR_DUMPER_SERVER`` var or defaults to ``127.0.0.1:9912``. - But you can configure the host through the ``VAR_DUMPER_FORMAT=tcp://127.0.0.1:1234`` environment variable as well. + The host used by the ``server`` format is the one configured in the + ``VAR_DUMPER_SERVER`` env var or ``127.0.0.1:9912`` if none is defined. + If you prefer, you can also configure the host in the ``VAR_DUMPER_FORMAT`` + env var like this: ``VAR_DUMPER_FORMAT=tcp://127.0.0.1:1234``. DebugBundle and Twig Integration -------------------------------- From 03f119a3d156ec7dd137c3a9921d2a06ff7b0f79 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 16:37:42 +0200 Subject: [PATCH 486/752] Tweaks --- event_dispatcher.rst | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 5f299cd2459..466464287b0 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -100,13 +100,17 @@ using a special "tag": .. code-block:: php // config/services.php + namespace Symfony\Component\DependencyInjection\Loader\Configurator; + use App\EventListener\ExceptionListener; - - $services = $containerConfigurator->services(); - $services->set(ExceptionListener::class) - ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) - ; + return function(ContainerConfigurator $configurator) { + $services = $configurator->services(); + + $services->set(ExceptionListener::class) + ->addTag('kernel.event_listener', ['event' => 'kernel.exception']) + ; + }; Symfony follows this logic to decide which method to call inside the event listener class: From 945a879c1d3d0b428d5b0dfb0c2938d80e2b387a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 17:04:47 +0200 Subject: [PATCH 487/752] Fixed CI issue --- http_client.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http_client.rst b/http_client.rst index 51cd799fea6..49d7cc780b4 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1471,8 +1471,8 @@ responses and use it as a callback in functional tests:: namespace App\Tests; - use Symfony\Contracts\HttpClient\ResponseInterface; use Symfony\Component\HttpClient\Response\MockResponse; + use Symfony\Contracts\HttpClient\ResponseInterface; class MockClientCallback { From 84de0dc77713b1448d2fc293f2fa1eb6d8d3fc30 Mon Sep 17 00:00:00 2001 From: Matt Trask Date: Tue, 28 Jul 2020 11:00:29 -0500 Subject: [PATCH 488/752] [Process] Update process.rst --- components/process.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/process.rst b/components/process.rst index c7b286fec71..092009a5b40 100644 --- a/components/process.rst +++ b/components/process.rst @@ -377,10 +377,9 @@ instead:: 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:: +You can run a process by using a prepared command line with double quote variable notation. +This allows you to use placeholders so that only the parameterized values can be changed, +but not the rest of the script: use Symfony\Component\Process\Process; From 43f5af5d13caeb8ecc3c2a6ac538f17138524c09 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 25 Sep 2020 17:35:27 +0200 Subject: [PATCH 489/752] Wrap some long lines --- components/process.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/process.rst b/components/process.rst index 092009a5b40..527214dca62 100644 --- a/components/process.rst +++ b/components/process.rst @@ -377,9 +377,9 @@ instead:: Using a Prepared Command Line ----------------------------- -You can run a process by using a prepared command line with double quote variable notation. -This allows you to use placeholders so that only the parameterized values can be changed, -but not the rest of the script: +You can run a process by using a prepared command line with double quote +variable notation. This allows you to use placeholders so that only the +parameterized values can be changed, but not the rest of the script: use Symfony\Component\Process\Process; From 517cbc0378fd38db07444e6caf7e36c0c4099281 Mon Sep 17 00:00:00 2001 From: Steve Grunwell Date: Fri, 25 Sep 2020 15:23:57 -0400 Subject: [PATCH 490/752] Document the SYMFONY_MAX_PHPUNIT_VERSION environment variable This documentation corresponds with symfony/symfony#38305. --- components/phpunit_bridge.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 2e824973354..dba2d4b9e4e 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -876,6 +876,10 @@ If you have installed the bridge through Composer, you can run it by calling e.g It's also possible to set ``SYMFONY_PHPUNIT_VERSION`` as a real env var (not defined in a :ref:`dotenv file `). + In the same way, ``SYMFONY_MAX_PHPUNIT_VERSION`` will set the maximum version + of PHPUnit to be considered. This is useful when testing a framework that does + not support the latest version(s) of PHPUnit. + .. tip:: If you still need to use ``prophecy`` (but not ``symfony/yaml``), From 24b9aeba8f108a10e2900bbfc18725d85f17e5ce Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Sun, 27 Sep 2020 10:45:10 -0400 Subject: [PATCH 491/752] Change translatable example parameter key --- translation.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translation.rst b/translation.rst index 1c667e2e3ca..238e80ee38c 100644 --- a/translation.rst +++ b/translation.rst @@ -316,7 +316,7 @@ all the information needed to fully translate its contents when needed:: $message = new Translatable('Symfony is great!'); // the optional second argument defines the translation parameters and // the optional third argument is the translation domain - $status = new Translatable('order.status', ['order' => $order], 'store'); + $status = new Translatable('order.status', ['%status%' => $order->getStatus()], 'store'); Templates are now much simpler because you can pass translatable objects to the ``trans`` filter: From bebcc58191dd515e5590bf8c887d53c3a7ed7421 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Mon, 28 Sep 2020 15:47:15 +0200 Subject: [PATCH 492/752] Add documentation about fallback logic in lock --- components/lock.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/lock.rst b/components/lock.rst index c0f20586e6d..245aaa1de65 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -90,6 +90,18 @@ they can be decorated with the ``RetryTillSaveStore`` class:: $lock = $factory->createLock('notification-flush'); $lock->acquire(true); +When the provided store does not implements the +:class:`Symfony\\Component\\Lock\\BlockingStoreInterface` interface, the +``Lock`` class will try in a loop to acquire the lock in a non-blocking way +until the lock is acquired. + +.. deprecated:: 5.2 + + As of Symfony 5.2, you don't need anymore using the ``RetryTillSaveStore`` + class. The ``Lock`` class now provides the default logic to acquire locks in + blocking mode when the store does not implements the ``BlockingStoreInterface`` + interface. + Expiring Locks -------------- @@ -213,6 +225,11 @@ possible to **promote** the lock, and change it to write lock, by calling the In the same way, it's possible to **demote** a write lock, and change it to a read-only lock by calling the ``acquireRead()`` method. +When the provided store does not implements the +:class:`Symfony\\Component\\Lock\\SharedLockStoreInterface` interface, the +``Lock`` class will fallback to a write lock by calling the ``acquire()`` +method. + The Owner of The Lock --------------------- From d8fc70d486f3ca492661dc05c1b368ac82980bc1 Mon Sep 17 00:00:00 2001 From: Romaric Drigon Date: Mon, 28 Sep 2020 17:43:11 +0200 Subject: [PATCH 493/752] [Form] Added documentation for "html5" option of MoneyType and PercentType --- reference/forms/types/money.rst | 16 ++++++++++++++++ reference/forms/types/percent.rst | 14 +++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 9fd1d4a95f4..5952ba77b67 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -17,6 +17,7 @@ how the input and output of the data is handled. | Options | - `currency`_ | | | - `divisor`_ | | | - `grouping`_ | +| | - `html5`_ | | | - `rounding_mode`_ | | | - `scale`_ | +-------------+---------------------------------------------------------------------+ @@ -90,6 +91,21 @@ be set back on your object. .. include:: /reference/forms/types/options/rounding_mode.rst.inc +html5 +~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +.. versionadded:: 5.2 + + This option was introduced in Symfony 5.2. + +If set to true, the HTML input will be rendered as a native HTML5 type="number" form. + +.. caution:: + + As HTML5 number format is normalized, it is incompatible with ``grouping`` option. + scale ~~~~~ diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index ca6c1c2e456..e35d54a022b 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -15,7 +15,8 @@ the input. +-------------+-----------------------------------------------------------------------+ | Rendered as | ``input`` ``text`` field | +-------------+-----------------------------------------------------------------------+ -| Options | - `rounding_mode`_ | +| Options | - `html5`_ | +| | - `rounding_mode`_ | | | - `scale`_ | | | - `symbol`_ | | | - `type`_ | @@ -57,6 +58,17 @@ Field Options The ``rounding_mode`` option was introduced in Symfony 5.1. +html5 +~~~~~ + +**type**: ``boolean`` **default**: ``false`` + +.. versionadded:: 5.2 + + This option was introduced in Symfony 5.2. + +If set to true, the HTML input will be rendered as a native HTML5 type="number" form. + scale ~~~~~ From c0ce045e61b9df49c8ad9ef4cbc90a3737f849e4 Mon Sep 17 00:00:00 2001 From: drixs6o9 Date: Tue, 29 Sep 2020 09:38:40 +0200 Subject: [PATCH 494/752] [Notifier] Added Sendinblue bridge documentation --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 9d0b5148553..ab45707d306 100644 --- a/notifier.rst +++ b/notifier.rst @@ -63,6 +63,7 @@ Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FRO Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` +Sendinblue ``symfony/sendinblue-notifier`` ``sendinblue://API_KEY@default?sender=PHONE`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` @@ -74,7 +75,7 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.2 - The Smsapi, Infobip, Mobyt and Esendex integrations were introduced in Symfony 5.2. + The Smsapi, Infobip, Mobyt, Esendex and Sendinblue integrations were introduced in Symfony 5.2. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 48b4756aa00778a99a009a500faaf17684cec691 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 29 Sep 2020 17:27:00 +0200 Subject: [PATCH 495/752] Tweaks --- components/lock.rst | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index 245aaa1de65..b9044baefca 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -90,17 +90,17 @@ they can be decorated with the ``RetryTillSaveStore`` class:: $lock = $factory->createLock('notification-flush'); $lock->acquire(true); -When the provided store does not implements the +When the provided store does not implement the :class:`Symfony\\Component\\Lock\\BlockingStoreInterface` interface, the -``Lock`` class will try in a loop to acquire the lock in a non-blocking way -until the lock is acquired. +``Lock`` class will retry to acquire the lock in a non-blocking way until the +lock is acquired. .. deprecated:: 5.2 - As of Symfony 5.2, you don't need anymore using the ``RetryTillSaveStore`` - class. The ``Lock`` class now provides the default logic to acquire locks in - blocking mode when the store does not implements the ``BlockingStoreInterface`` - interface. + As of Symfony 5.2, you don't need to use the ``RetryTillSaveStore`` class + anymore. The ``Lock`` class now provides the default logic to acquire locks + in blocking mode when the store does not implement the + ``BlockingStoreInterface`` interface. Expiring Locks -------------- @@ -225,10 +225,9 @@ possible to **promote** the lock, and change it to write lock, by calling the In the same way, it's possible to **demote** a write lock, and change it to a read-only lock by calling the ``acquireRead()`` method. -When the provided store does not implements the +When the provided store does not implement the :class:`Symfony\\Component\\Lock\\SharedLockStoreInterface` interface, the -``Lock`` class will fallback to a write lock by calling the ``acquire()`` -method. +``Lock`` class will fallback to a write lock by calling the ``acquire()`` method. The Owner of The Lock --------------------- From e5aa7615eb7125fa773310e3b9250a6cae73e000 Mon Sep 17 00:00:00 2001 From: Titouan Galopin Date: Sat, 26 Sep 2020 13:55:35 +0200 Subject: [PATCH 496/752] [Webpack Encore] Change default assets directory structure --- frontend/encore/advanced-config.rst | 8 +++---- frontend/encore/bootstrap.rst | 2 +- frontend/encore/code-splitting.rst | 6 ++--- frontend/encore/copy-files.rst | 2 +- frontend/encore/faq.rst | 2 +- frontend/encore/installation.rst | 18 +++++++-------- frontend/encore/shared-entry.rst | 10 ++++----- frontend/encore/simple-example.rst | 34 ++++++++++++++--------------- frontend/encore/split-chunks.rst | 8 +++---- mailer.rst | 8 +++---- 10 files changed, 49 insertions(+), 49 deletions(-) diff --git a/frontend/encore/advanced-config.rst b/frontend/encore/advanced-config.rst index eb77baef504..86bdb812b94 100644 --- a/frontend/encore/advanced-config.rst +++ b/frontend/encore/advanced-config.rst @@ -65,8 +65,8 @@ state of the current configuration to build a new one: Encore .setOutputPath('public/build/first_build/') .setPublicPath('/build/first_build') - .addEntry('app', './assets/js/app.js') - .addStyleEntry('global', './assets/css/global.scss') + .addEntry('app', './assets/app.js') + .addStyleEntry('global', './assets/styles/global.scss') .enableSassLoader() .autoProvidejQuery() .enableSourceMaps(!Encore.isProduction()) @@ -85,8 +85,8 @@ state of the current configuration to build a new one: Encore .setOutputPath('public/build/second_build/') .setPublicPath('/build/second_build') - .addEntry('mobile', './assets/js/mobile.js') - .addStyleEntry('mobile', './assets/css/mobile.less') + .addEntry('mobile', './assets/mobile.js') + .addStyleEntry('mobile', './assets/styles/mobile.less') .enableLessLoader() .enableSourceMaps(!Encore.isProduction()) ; diff --git a/frontend/encore/bootstrap.rst b/frontend/encore/bootstrap.rst index ff281f588ac..f1e28cabc37 100644 --- a/frontend/encore/bootstrap.rst +++ b/frontend/encore/bootstrap.rst @@ -18,7 +18,7 @@ a ``global.scss`` file, import it from there: .. code-block:: scss - // assets/css/global.scss + // assets/styles/global.scss // customize some Bootstrap variables $primary: darken(#428bca, 20%); diff --git a/frontend/encore/code-splitting.rst b/frontend/encore/code-splitting.rst index ffbfe8b4d28..759987e5f0a 100644 --- a/frontend/encore/code-splitting.rst +++ b/frontend/encore/code-splitting.rst @@ -9,7 +9,7 @@ clicked a link: .. code-block:: javascript - // assets/js/app.js + // assets/app.js import $ from 'jquery'; // a fictional "large" module (e.g. it imports video.js internally) @@ -27,13 +27,13 @@ the code via AJAX when it's needed: .. code-block:: javascript - // assets/js/app.js + // assets/app.js import $ from 'jquery'; $('.js-open-video').on('click', function() { // you could start a loading animation here - + // use import() as a function - it returns a Promise import('./components/VideoPlayer').then(({ default: VideoPlayer }) => { // you could stop a loading animation here diff --git a/frontend/encore/copy-files.rst b/frontend/encore/copy-files.rst index bc263ef056a..7ea5a541622 100644 --- a/frontend/encore/copy-files.rst +++ b/frontend/encore/copy-files.rst @@ -12,7 +12,7 @@ To reference an image tag from inside a JavaScript file, *require* the file: .. code-block:: javascript - // assets/js/app.js + // assets/app.js // returns the final, public path to this file // path is relative to this file - e.g. assets/images/logo.png diff --git a/frontend/encore/faq.rst b/frontend/encore/faq.rst index 3c621c3b8d0..c6c6d86c257 100644 --- a/frontend/encore/faq.rst +++ b/frontend/encore/faq.rst @@ -116,7 +116,7 @@ But, instead of working, you see an error: This dependency was not found: - * respond.js in ./assets/js/app.js + * respond.js in ./assets/app.js Typically, a package will "advertise" its "main" file by adding a ``main`` key to its ``package.json``. But sometimes, old libraries won't have this. Instead, you'll diff --git a/frontend/encore/installation.rst b/frontend/encore/installation.rst index 7cf878a1637..8241dbcd0b2 100644 --- a/frontend/encore/installation.rst +++ b/frontend/encore/installation.rst @@ -79,9 +79,9 @@ is the main config file for both Webpack and Webpack Encore: * Each entry will result in one JavaScript file (e.g. app.js) * and one CSS file (e.g. app.css) if your JavaScript imports CSS. */ - .addEntry('app', './assets/js/app.js') - //.addEntry('page1', './assets/js/page1.js') - //.addEntry('page2', './assets/js/page2.js') + .addEntry('app', './assets/app.js') + //.addEntry('page1', './assets/page1.js') + //.addEntry('page2', './assets/page2.js') // When enabled, Webpack "splits" your files into smaller pieces for greater optimization. .splitEntryChunks() @@ -124,17 +124,17 @@ is the main config file for both Webpack and Webpack Encore: // uncomment if you use API Platform Admin (composer require api-admin) //.enableReactPreset() - //.addEntry('admin', './assets/js/admin.js') + //.addEntry('admin', './assets/admin.js') ; module.exports = Encore.getWebpackConfig(); -Next, open the new ``assets/js/app.js`` file which contains some JavaScript code +Next, open the new ``assets/app.js`` file which contains some JavaScript code *and* imports some CSS: .. code-block:: javascript - // assets/js/app.js + // assets/app.js /* * Welcome to your app's main JavaScript file! * @@ -148,13 +148,13 @@ Next, open the new ``assets/js/app.js`` file which contains some JavaScript code // Need jQuery? Install it with "yarn add jquery", then uncomment to import it. // import $ from 'jquery'; - console.log('Hello Webpack Encore! Edit me in assets/js/app.js'); + console.log('Hello Webpack Encore! Edit me in assets/app.js'); -And the new ``assets/css/app.css`` file: +And the new ``assets/styles/app.css`` file: .. code-block:: css - /* assets/css/app.css */ + /* assets/styles/app.css */ body { background-color: lightgray; } diff --git a/frontend/encore/shared-entry.rst b/frontend/encore/shared-entry.rst index 6693b649d8d..a2c2d08ea2a 100644 --- a/frontend/encore/shared-entry.rst +++ b/frontend/encore/shared-entry.rst @@ -18,11 +18,11 @@ Update your code to use ``createSharedEntry()``: Encore // ... - - .addEntry('app', './assets/js/app.js') - + .createSharedEntry('app', './assets/js/app.js') - .addEntry('homepage', './assets/js/homepage.js') - .addEntry('blog', './assets/js/blog.js') - .addEntry('store', './assets/js/store.js') + - .addEntry('app', './assets/app.js') + + .createSharedEntry('app', './assets/app.js') + .addEntry('homepage', './assets/homepage.js') + .addEntry('blog', './assets/blog.js') + .addEntry('store', './assets/store.js') Before making this change, if both ``app.js`` and ``store.js`` require ``jquery``, then ``jquery`` would be packaged into *both* files, which is wasteful. By making diff --git a/frontend/encore/simple-example.rst b/frontend/encore/simple-example.rst index 03c5626ee02..30aa4400d1c 100644 --- a/frontend/encore/simple-example.rst +++ b/frontend/encore/simple-example.rst @@ -4,8 +4,8 @@ Encore: Setting up your Project After :doc:`installing Encore `, your app already has one CSS and one JS file, organized into an ``assets/`` directory: -* ``assets/js/app.js`` -* ``assets/css/app.css`` +* ``assets/app.js`` +* ``assets/styles/app.css`` With Encore, think of your ``app.js`` file like a standalone JavaScript application: it will *require* all of the dependencies it needs (e.g. jQuery or React), @@ -14,7 +14,7 @@ application: it will *require* all of the dependencies it needs (e.g. jQuery or .. code-block:: javascript - // assets/js/app.js + // assets/app.js // ... import '../css/app.css'; @@ -43,14 +43,14 @@ of your project. It already holds the basic config you need: // public path used by the web server to access the output path .setPublicPath('/build') - .addEntry('app', './assets/js/app.js') + .addEntry('app', './assets/app.js') // ... ; // ... -The *key* part is ``addEntry()``: this tells Encore to load the ``assets/js/app.js`` +The *key* part is ``addEntry()``: this tells Encore to load the ``assets/app.js`` file and follow *all* of the ``require()`` statements. It will then package everything together and - thanks to the first ``app`` argument - output final ``app.js`` and ``app.css`` files into the ``public/build`` directory. @@ -115,7 +115,7 @@ can do most of the work for you: .. _encore-entrypointsjson-simple-description: That's it! When you refresh your page, all of the JavaScript from -``assets/js/app.js`` - as well as any other JavaScript files it included - will +``assets/app.js`` - as well as any other JavaScript files it included - will be executed. All the CSS files that were required will also be displayed. The ``encore_entry_link_tags()`` and ``encore_entry_script_tags()`` functions @@ -143,7 +143,7 @@ files. First, create a file that exports a function: .. code-block:: javascript - // assets/js/greet.js + // assets/greet.js module.exports = function(name) { return `Yo yo ${name} - welcome to Encore!`; }; @@ -158,7 +158,7 @@ Great! Use ``require()`` to import ``jquery`` and ``greet.js``: .. code-block:: diff - // assets/js/app.js + // assets/app.js // ... + // loads the jquery package from node_modules @@ -187,7 +187,7 @@ To export values using the alternate syntax, use ``export``: .. code-block:: diff - // assets/js/greet.js + // assets/greet.js - module.exports = function(name) { + export default function(name) { return `Yo yo ${name} - welcome to Encore!`; @@ -197,7 +197,7 @@ To import values, use ``import``: .. code-block:: diff - // assets/js/app.js + // assets/app.js - require('../css/app.css'); + import '../css/app.css'; @@ -219,12 +219,12 @@ etc.). To handle this, create a new "entry" JavaScript file for each page: .. code-block:: javascript - // assets/js/checkout.js + // assets/checkout.js // custom code for your checkout page .. code-block:: javascript - // assets/js/account.js + // assets/account.js // custom code for your account page Next, use ``addEntry()`` to tell Webpack to read these two new files when it builds: @@ -234,9 +234,9 @@ Next, use ``addEntry()`` to tell Webpack to read these two new files when it bui // webpack.config.js Encore // ... - .addEntry('app', './assets/js/app.js') - + .addEntry('checkout', './assets/js/checkout.js') - + .addEntry('account', './assets/js/account.js') + .addEntry('app', './assets/app.js') + + .addEntry('checkout', './assets/checkout.js') + + .addEntry('account', './assets/account.js') // ... And because you just changed the ``webpack.config.js`` file, make sure to stop @@ -285,7 +285,7 @@ file to ``app.scss`` and update the ``import`` statement: .. code-block:: diff - // assets/js/app.js + // assets/app.js - import '../css/app.css'; + import '../css/app.scss'; @@ -336,7 +336,7 @@ If you want to only compile a CSS file, that's possible via ``addStyleEntry()``: Encore // ... - .addStyleEntry('some_page', './assets/css/some_page.css') + .addStyleEntry('some_page', './assets/styles/some_page.css') ; This will output a new ``some_page.css``. diff --git a/frontend/encore/split-chunks.rst b/frontend/encore/split-chunks.rst index ebaa4ee48ce..0205537b7d0 100644 --- a/frontend/encore/split-chunks.rst +++ b/frontend/encore/split-chunks.rst @@ -14,10 +14,10 @@ To enable this, call ``splitEntryChunks()``: // ... // multiple entry files, which probably import the same code - .addEntry('app', './assets/js/app.js') - .addEntry('homepage', './assets/js/homepage.js') - .addEntry('blog', './assets/js/blog.js') - .addEntry('store', './assets/js/store.js') + .addEntry('app', './assets/app.js') + .addEntry('homepage', './assets/homepage.js') + .addEntry('blog', './assets/blog.js') + .addEntry('store', './assets/store.js') + .splitEntryChunks() diff --git a/mailer.rst b/mailer.rst index 2d4838ba4b5..a932050c049 100644 --- a/mailer.rst +++ b/mailer.rst @@ -626,7 +626,7 @@ called ``css`` that points to the directory where ``email.css`` lives: paths: # point this wherever your css files live - '%kernel.project_dir%/assets/css': css + '%kernel.project_dir%/assets/styles': styles .. code-block:: xml @@ -642,7 +642,7 @@ called ``css`` that points to the directory where ``email.css`` lives: - %kernel.project_dir%/assets/css + %kernel.project_dir%/assets/styles @@ -653,7 +653,7 @@ called ``css`` that points to the directory where ``email.css`` lives: // ... 'paths' => [ // point this wherever your css files live - '%kernel.project_dir%/assets/css' => 'css', + '%kernel.project_dir%/assets/styles' => 'styles', ], ]); @@ -741,7 +741,7 @@ You can combine all filters to create complex email messages: This makes use of the :ref:`css Twig namespace ` we created earlier. You could, for example, `download the foundation-emails.css file`_ -directly from GitHub and save it in ``assets/css``. +directly from GitHub and save it in ``assets/styles``. Signing and Encrypting Messages ------------------------------- From f40fd45adda961236f6da8e3f767f8353138b176 Mon Sep 17 00:00:00 2001 From: RiffFred <72142966+RiffFred@users.noreply.github.com> Date: Wed, 30 Sep 2020 15:54:02 +0200 Subject: [PATCH 497/752] typo fix for the Signing Messages chapter fixes the syntax highlighting for the SMimeSigner code example fixes the DKIM wikipedia link --- mailer.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mailer.rst b/mailer.rst index 4f2ec4718a0..e257869b94d 100644 --- a/mailer.rst +++ b/mailer.rst @@ -798,7 +798,7 @@ S/MIME Signer ............. `S/MIME`_ is a standard for public key encryption and signing of MIME data. It -requires using both a certificate and a private key: +requires using both a certificate and a private key:: use Symfony\Component\Mime\Crypto\SMimeSigner; use Symfony\Component\Mime\Email; @@ -1168,7 +1168,7 @@ a specific address, instead of the *real* address: .. _`Markdown syntax`: https://commonmark.org/ .. _`Inky`: https://get.foundation/emails/docs/inky.html .. _`S/MIME`: https://en.wikipedia.org/wiki/S/MIME -.. _`DKIM`: `https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail +.. _`DKIM`: https://en.wikipedia.org/wiki/DomainKeys_Identified_Mail .. _`OpenSSL PHP extension`: https://www.php.net/manual/en/book.openssl.php .. _`PEM encoded`: https://en.wikipedia.org/wiki/Privacy-Enhanced_Mail .. _`default_socket_timeout`: https://www.php.net/manual/en/filesystem.configuration.php#ini.default-socket-timeout From 9fcc215a9f045f206cc776a2c4b87e7173d4e9dc Mon Sep 17 00:00:00 2001 From: Henri Larget <1727893+decima@users.noreply.github.com> Date: Thu, 1 Oct 2020 14:31:21 +0200 Subject: [PATCH 498/752] Update mailer.rst This is the signature of the method: ``` public function __construct(string $pk, string $domainName, string $selector, array $defaultOptions = [], string $passphrase = '') ``` --- mailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index e257869b94d..352e3613fea 100644 --- a/mailer.rst +++ b/mailer.rst @@ -841,7 +841,7 @@ key but not a certificate:: // second and third arguments: the domain name and "selector" used to perform a DNS lookup // (the selector is a string used to point to a specific DKIM public key record in your DNS) $signer = new DkimSigner('file:///path/to/private-key.key', 'example.com', 'sf'); - // if the private key has a passphrase, pass it as the fourth argument + // if the private key has a passphrase, pass it as the fifth argument // new DkimSigner('file:///path/to/private-key.key', 'example.com', 'sf', [], 'the-passphrase'); $signedEmail = $signer->sign($email); From 7f0e8d8e8005db4420e7c0d854d76b4c08c19f43 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 2 Oct 2020 12:45:46 +0200 Subject: [PATCH 499/752] Tweaks and rewords --- http_client.rst | 25 ++++++++----- reference/configuration/framework.rst | 52 ++++++++++++++++++++------- 2 files changed, 56 insertions(+), 21 deletions(-) diff --git a/http_client.rst b/http_client.rst index 53e58bdcf39..7f44141a6dc 100644 --- a/http_client.rst +++ b/http_client.rst @@ -658,10 +658,23 @@ making a request. Use the ``max_redirects`` setting to configure this behavior Retry Failed Requests ~~~~~~~~~~~~~~~~~~~~~ -Some times, requests failed because of temporary issue in the server or -because network issue. You can use the -:class:`Symfony\\Component\\HttpClient\\RetryableHttpClient` -client to automatically retry the request when it fails.:: +.. versionadded:: 5.2 + + The feature to retry failed HTTP requests was introduced in Symfony 5.2. + +Sometimes, requests fail because of network issues or temporary server errors. +Symfony's HttpClient allows to retry failed requests automatically using the +:ref:`retry_failed option `. When enabled, +each failed request with an HTTP status of ``423``, ``425``, ``429``, ``500``, +``502``, ``503``, ``504``, ``507``, or ``510`` is retried up to 3 times, with an +exponential delay between retries (first retry = 1 second; third retry: 4 seconds). + +Check out the full list of configurable :ref:`retry_failed options ` +to learn how to tweak each of them to fit your application needs. + +When using the HttpClient outside of a Symfony application, use the +:class:`Symfony\\Component\\HttpClient\\RetryableHttpClient` class to wrap your +original HTTP client:: use Symfony\Component\HttpClient\RetryableHttpClient; @@ -673,10 +686,6 @@ decide if the request should be retried, and a :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface` to define the waiting time between each retry. -By default, it retries until 3 attemps, the requests responding with a -status code in (423, 425, 429, 500, 502, 503, 504, 507 or 510) and wait -expentially from 1 second for the first retry, to 4 seconds at the 3rd attempt. - HTTP Proxies ~~~~~~~~~~~~ diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 1501f5a1540..c1c189d1f5a 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -792,6 +792,10 @@ will automaticaly retry failed HTTP requests. retry_failed: max_retries: 4 +.. versionadded:: 5.2 + + The ``retry_failed`` option was introduced in Symfony 5.2. + auth_basic .......... @@ -824,13 +828,15 @@ backoff_service **type**: ``string`` +.. versionadded:: 5.2 + + The ``backoff_service`` option was introduced in Symfony 5.2. + The service id used to compute the time to wait between retries. By default, it uses an instance of :class:`Symfony\\Component\\HttpClient\\Retry\\ExponentialBackOff` configured with ``delay``, ``max_delay`` and ``multiplier`` options. This class has to implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`. -This options cannot be used along `delay`_, `max_delay`_ or `multiplier`_ -options. base_uri ........ @@ -905,20 +911,26 @@ decider_service **type**: ``string`` +.. versionadded:: 5.2 + + The ``decider_service`` option was introduced in Symfony 5.2. + The service id used to decide if a request should be retried. By default, it uses an instance of :class:`Symfony\\Component\\HttpClient\\Retry\\HttpStatusCodeDecider` configured -with ``http_codes`` options. This class has to -implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`. -This options cannot be used along `http_codes`_ option. +with the ``http_codes`` option. This class has to implement +:class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`. delay ..... **type**: ``integer`` **default**: ``1000`` -The initial delay in milliseconds used to compute the waiting time between -retries. This options cannot be used along `backoff_service`_ option. +.. versionadded:: 5.2 + + The ``delay`` option was introduced in Symfony 5.2. + +The initial delay in milliseconds used to compute the waiting time between retries. .. _reference-http-client-retry-enabled: @@ -943,8 +955,11 @@ http_codes **type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]`` +.. versionadded:: 5.2 + + The ``http_codes`` option was introduced in Symfony 5.2. + The list of HTTP status codes that triggers a retry of the request. -This options cannot be used along `decider_service`_ option. http_version ............ @@ -976,9 +991,12 @@ max_delay **type**: ``integer`` **default**: ``0`` +.. versionadded:: 5.2 + + The ``max_delay`` option was introduced in Symfony 5.2. + The maximum amount of milliseconds initial to wait between retries. Use ``0`` to not limit the duration. -This options cannot be used along `backoff_service`_ option. max_duration ............ @@ -1011,16 +1029,24 @@ max_retries **type**: ``integer`` **default**: ``3`` -The maximum number of retries before aborting. When the maximum is reach, the -client returns the last received responses. +.. versionadded:: 5.2 + + The ``max_retries`` option was introduced in Symfony 5.2. + +The maximum number of retries for failing requests. When the maximum is reached, +the client returns the last received response. multiplier .......... **type**: ``float`` **default**: ``2`` -Multiplier to apply to the delay each time a retry occurs. -This options cannot be used along `backoff_service`_ option. +.. versionadded:: 5.2 + + The ``multiplier`` option was introduced in Symfony 5.2. + +This value is multiplied to the delay each time a retry occurs, to distribute +retries in time instead of making all of them sequentially. no_proxy ........ From b86e003aef789ad9ac5746ec12e7e67c9cac3001 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 2 Oct 2020 15:24:55 +0200 Subject: [PATCH 500/752] Tweak --- reference/forms/types/money.rst | 3 ++- reference/forms/types/percent.rst | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index 5952ba77b67..bb91d0b08da 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -100,7 +100,8 @@ html5 This option was introduced in Symfony 5.2. -If set to true, the HTML input will be rendered as a native HTML5 type="number" form. +If set to ``true``, the HTML input will be rendered as a native HTML5 +```` element. .. caution:: diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index e35d54a022b..4b21f1f2856 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -67,7 +67,8 @@ html5 This option was introduced in Symfony 5.2. -If set to true, the HTML input will be rendered as a native HTML5 type="number" form. +If set to ``true``, the HTML input will be rendered as a native HTML5 +```` element. scale ~~~~~ From fd03b5ef92db7ad6f38059713d97fa88e30e4aea Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 3 Oct 2020 10:12:27 +0200 Subject: [PATCH 501/752] Adding docs about Request::toArray() --- components/http_foundation.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index c4662198bdb..27842974496 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -188,9 +188,16 @@ Finally, the raw data sent with the request body can be accessed using $content = $request->getContent(); -For instance, this may be useful to process a JSON string sent to the +For instance, this may be useful to process a XML string sent to the application by a remote service using the HTTP POST method. +.. versionadded:: 5.2 + + If the request body is a JSON string, it can be accessed using + :method:`Symfony\\Component\\HttpFoundation\\Request::toArray`:: + + $data = $request->toArray(); + Identifying a Request ~~~~~~~~~~~~~~~~~~~~~ From b5156615f019e6974abe14d7f0f66d28460e7959 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 3 Oct 2020 15:12:38 +0200 Subject: [PATCH 502/752] [#14325] Moved contents out of versionadded directive --- components/http_foundation.rst | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 27842974496..62815a98a8b 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -191,12 +191,14 @@ Finally, the raw data sent with the request body can be accessed using For instance, this may be useful to process a XML string sent to the application by a remote service using the HTTP POST method. -.. versionadded:: 5.2 +If the request body is a JSON string, it can be accessed using +:method:`Symfony\\Component\\HttpFoundation\\Request::toArray`:: + + $data = $request->toArray(); - If the request body is a JSON string, it can be accessed using - :method:`Symfony\\Component\\HttpFoundation\\Request::toArray`:: +.. versionadded:: 5.2 - $data = $request->toArray(); + The ``toArray()`` method was introduced in Symfony 5.2. Identifying a Request ~~~~~~~~~~~~~~~~~~~~~ From 14d9473720bf374cf02166d6f121db9947b07643 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 3 Oct 2020 15:40:46 +0200 Subject: [PATCH 503/752] [#14219] Merged the two IPs examples --- security/access_control.rst | 111 ++++++++++++++---------------------- 1 file changed, 42 insertions(+), 69 deletions(-) diff --git a/security/access_control.rst b/security/access_control.rst index 6bc661ce540..225687c02f6 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -25,7 +25,7 @@ access control should be used on this request. The following ``access_control`` options are used for matching: * ``path``: a regular expression (without delimiters) -* ``ip`` or ``ips``: netmasks are also supported +* ``ip`` or ``ips``: netmasks are also supported (can be a comma-separated string) * ``port``: an integer * ``host``: a regular expression * ``methods``: one or many methods @@ -37,6 +37,9 @@ Take the following ``access_control`` entries as an example: .. code-block:: yaml # config/packages/security.yaml + parameters: + env(TRUSTED_IPS): '10.0.0.1, 10.0.0.2' + security: # ... access_control: @@ -45,6 +48,10 @@ Take the following ``access_control`` entries as an example: - { path: '^/admin', roles: ROLE_USER_HOST, host: symfony\.com$ } - { path: '^/admin', roles: ROLE_USER_METHOD, methods: [POST, PUT] } + # ips can be comma-separated, which is especially useful when using env variables + - { path: '^/admin', roles: ROLE_USER_IP, ips: '%env(TRUSTED_IPS)%' } + - { path: '^/admin', roles: ROLE_USER_IP, ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] } + .. code-block:: xml @@ -57,18 +64,31 @@ Take the following ``access_control`` entries as an example: http://symfony.com/schema/dic/security https://symfony.com/schema/dic/security/security-1.0.xsd"> + + 10.0.0.1, 10.0.0.2 + + + + + + + 127.0.0.1 + ::1 + %env(TRUSTED_IPS)% + .. code-block:: php // config/packages/security.php + $container->setParameter('env(TRUSTED_IPS)', '10.0.0.1, 10.0.0.2'); $container->loadFromExtension('security', [ // ... 'access_control' => [ @@ -92,10 +112,30 @@ Take the following ``access_control`` entries as an example: 'path' => '^/admin', 'roles' => 'ROLE_USER_METHOD', 'methods' => 'POST, PUT', - ] + ], + + // ips can be comma-separated, which is especially useful when using env variables + [ + 'path' => '^/admin', + 'roles' => 'ROLE_USER_IP', + 'ips' => '%env(TRUSTED_IPS)%', + ], + [ + 'path' => '^/admin', + 'roles' => 'ROLE_USER_IP', + 'ips' => [ + '127.0.0.1', + '::1', + '%env(TRUSTED_IPS)%', + ], + ], ], ]); +.. versionadded:: 5.2 + + Support for comma-separated IP addresses was introduced in Symfony 5.2. + For each incoming request, Symfony will decide which ``access_control`` to use based on the URI, the client's IP address, the incoming host name, and the request method. Remember, the first rule that matches is used, and @@ -133,73 +173,6 @@ if ``ip``, ``port``, ``host`` or ``method`` are not specified for an entry, that :ref:`Deny access in PHP code ` if you want to disallow access based on ``$_GET`` parameter values. -.. versionadded:: 5.2 - - Environment variables can be used to pass comma separated ip addresses - (as a single value or as one of array values): - - .. configuration-block:: - - .. code-block:: yaml - - # config/packages/security.yaml - parameters: - env(TRUSTED_IPS): '10.0.0.1, 10.0.0.2' - security: - # ... - access_control: - - { path: '^/admin', ips: '%env(TRUSTED_IPS)%' } - - { path: '^/admin', ips: [127.0.0.1, ::1, '%env(TRUSTED_IPS)%'] } - - .. code-block:: xml - - - - - - - 10.0.0.1, 10.0.0.2 - - - - - - - 127.0.0.1 - ::1 - %env(TRUSTED_IPS)% - - - - - .. code-block:: php - - // config/packages/security.php - $container->setParameter('env(TRUSTED_IPS)', '10.0.0.1, 10.0.0.2'); - $container->loadFromExtension('security', [ - // ... - 'access_control' => [ - [ - 'path' => '^/admin', - 'ips' => '%env(TRUSTED_IPS)%', - ], - [ - 'path' => '^/admin', - 'ips' => [ - '127.0.0.1', - '::1', - '%env(TRUSTED_IPS)%', - ], - ], - ], - ]); - .. _security-access-control-enforcement-options: 2. Access Enforcement From f853c9a5b2a9ac46f890bd5bc00d79a1c1f2ccdf Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 3 Oct 2020 15:58:06 +0200 Subject: [PATCH 504/752] [#14286] Added versionadded directive --- components/phpunit_bridge.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index dba2d4b9e4e..04d080d974f 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -877,9 +877,14 @@ If you have installed the bridge through Composer, you can run it by calling e.g (not defined in a :ref:`dotenv file `). In the same way, ``SYMFONY_MAX_PHPUNIT_VERSION`` will set the maximum version - of PHPUnit to be considered. This is useful when testing a framework that does + of PHPUnit to be considered. This is useful when testing a framework that does not support the latest version(s) of PHPUnit. +.. versionadded:: 5.2 + + The ``SYMFONY_MAX_PHPUNIT_VERSION`` env variable was introduced in + Symfony 5.2. + .. tip:: If you still need to use ``prophecy`` (but not ``symfony/yaml``), From 64886940917ddbf0bc918c16c48cb04137f56afc Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 3 Oct 2020 23:20:52 +0200 Subject: [PATCH 505/752] Removed versionadded 4.4 directives --- components/serializer.rst | 4 ---- service_container/tags.rst | 4 ---- 2 files changed, 8 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index e109b883993..8fa9a5484fd 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -1256,10 +1256,6 @@ These are the options available: ``output_utf8_bom`` Outputs special `UTF-8 BOM`_ along with encoded data (default: ``false``). -.. versionadded:: 4.4 - - The ``output_utf8_bom`` option was introduced in Symfony 4.4. - Handling Constructor Arguments ------------------------------ diff --git a/service_container/tags.rst b/service_container/tags.rst index 8793048211b..9e394fc75d7 100644 --- a/service_container/tags.rst +++ b/service_container/tags.rst @@ -588,10 +588,6 @@ application handlers:: Tagged Services with Priority ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. versionadded:: 4.4 - - The ability to prioritize tagged services was introduced in Symfony 4.4. - The tagged services can be prioritized using the ``priority`` attribute, thus providing a way to inject a sorted collection of services: From ce94f893ae8453861d76d98287804a929da392db Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 4 Oct 2020 14:30:41 +0200 Subject: [PATCH 506/752] Removed versionadded 4.4 directives --- configuration.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/configuration.rst b/configuration.rst index b84e1b0e90e..5d4354d562b 100644 --- a/configuration.rst +++ b/configuration.rst @@ -144,10 +144,6 @@ configuration files, even if they use a different format: // ... -.. versionadded:: 4.4 - - The ``not_found`` option value for ``ignore_errors`` was introduced in Symfony 4.4. - .. _config-parameter-intro: .. _config-parameters-yml: .. _configuration-parameters: From 1a56331bee4daf037f09b1a0e991f9ef9c5d539c Mon Sep 17 00:00:00 2001 From: HypeMC Date: Sun, 4 Oct 2020 18:34:50 +0200 Subject: [PATCH 507/752] Add alternative FormDataPart array structure --- http_client.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/http_client.rst b/http_client.rst index 7f44141a6dc..240d28d1e73 100644 --- a/http_client.rst +++ b/http_client.rst @@ -619,6 +619,35 @@ according to the ``multipart/form-data`` content-type. The 'body' => $formData->bodyToIterable(), ]); +.. tip:: + + When using multidimensional arrays the :class:`Symfony\\Component\\Mime\\Part\\Multipart\\FormDataPart` + automatically appends ``[key]`` to the name of the field:: + + $formData = new FormDataPart([ + 'array_field' => [ + 'some value', + 'other value', + ], + ]); + + $formData->getParts(); // Returns two instances of TextPart + // with the names "array_field[0]" and "array_field[1]" + + This behavior can be bypassed by using the following array structure:: + + $formData = new FormDataPart([ + ['array_field' => 'some value'], + ['array_field' => 'other value'], + ]); + + $formData->getParts(); // Returns two instances of TextPart both + // with the name "array_field" + + .. versionadded:: 5.2 + + The alternative array structure was introduced in Symfony 5.2. + By default, HttpClient streams the body contents when uploading them. This might not work with all servers, resulting in HTTP status code 411 ("Length Required") because there is no ``Content-Length`` header. The solution is to turn the body From bf310c1ecb2c3289a3517c60965732db17fb207d Mon Sep 17 00:00:00 2001 From: Johan Date: Sun, 4 Oct 2020 15:49:59 +0200 Subject: [PATCH 508/752] 14300 Update support for Uuid 6 --- reference/constraints/Uuid.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index 6e9794b8b5d..3b81433d28a 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -124,9 +124,9 @@ will allow alternate input formats like: ``versions`` ~~~~~~~~~~~~ -**type**: ``int[]`` **default**: ``[1,2,3,4,5]`` +**type**: ``int[]`` **default**: ``[1,2,3,4,5,6]`` -This option can be used to only allow specific `UUID versions`_. Valid versions are 1 - 5. +This option can be used to only allow specific `UUID versions`_. Valid versions are 1 - 6. The following PHP constants can also be used: * ``Uuid::V1_MAC`` @@ -134,8 +134,9 @@ The following PHP constants can also be used: * ``Uuid::V3_MD5`` * ``Uuid::V4_RANDOM`` * ``Uuid::V5_SHA1`` +* ``Uuid::V6_SORTABLE`` -All five versions are allowed by default. +All six versions are allowed by default. .. _`Universally unique identifier (UUID)`: https://en.wikipedia.org/wiki/Universally_unique_identifier .. _`RFC 4122`: https://tools.ietf.org/html/rfc4122 From 0017158c805d9fadbc66bfbc04ba02901d726d23 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 5 Oct 2020 12:24:09 +0200 Subject: [PATCH 509/752] Added versionadded directive --- reference/constraints/Uuid.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index 3b81433d28a..427a373f788 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -138,6 +138,10 @@ The following PHP constants can also be used: All six versions are allowed by default. +.. versionadded:: 5.2 + + The UUID 6 version support was introduced in Symfony 5.2. + .. _`Universally unique identifier (UUID)`: https://en.wikipedia.org/wiki/Universally_unique_identifier .. _`RFC 4122`: https://tools.ietf.org/html/rfc4122 .. _`UUID versions`: https://en.wikipedia.org/wiki/Universally_unique_identifier#Versions From 4ff6a1a97b130a40f98ffc91740ec9e9c09d3547 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 6 Oct 2020 13:40:45 +0200 Subject: [PATCH 510/752] Minor: Fix build --- reference/constraints/Sequentially.rst | 2 +- validation/custom_constraint.rst | 2 +- validation/sequence_provider.rst | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reference/constraints/Sequentially.rst b/reference/constraints/Sequentially.rst index a8e7c6be298..39424a6c523 100644 --- a/reference/constraints/Sequentially.rst +++ b/reference/constraints/Sequentially.rst @@ -5,7 +5,7 @@ This constraint allows you to apply a set of rules that should be validated step-by-step, allowing to interrupt the validation once the first violation is raised. As an alternative in situations ``Sequentially`` cannot solve, you may consider -using :doc:`GroupSequence` which allows more control. +using :doc:`GroupSequence ` which allows more control. .. versionadded:: 5.1 diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index 5d5ae9fa22c..5e727fa97c1 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -185,7 +185,7 @@ Create a Reusable Set of Constraints ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In case you need to apply some common set of constraints in different places -consistently across your application, you can extend the :doc:`Compound constraint`. +consistently across your application, you can extend the :doc:`Compound constraint `. .. versionadded:: 5.1 diff --git a/validation/sequence_provider.rst b/validation/sequence_provider.rst index ad59e529839..52cf0940460 100644 --- a/validation/sequence_provider.rst +++ b/validation/sequence_provider.rst @@ -360,7 +360,7 @@ How to Sequentially Apply Constraints on a Single Property ---------------------------------------------------------- Sometimes, you may want to apply constraints sequentially on a single -property. The :doc:`Sequentially constraint` +property. The :doc:`Sequentially constraint ` can solve this for you in a more straightforward way than using a ``GroupSequence``. .. versionadded:: 5.1 From b37ca011beccd17893b4e7a0ec81686ae418b276 Mon Sep 17 00:00:00 2001 From: laurent35240 Date: Mon, 5 Oct 2020 22:10:40 +0200 Subject: [PATCH 511/752] [Validator] Add documention for ULID validator --- reference/constraints/Ulid.rst | 107 ++++++++++++++++++++++++++++++ reference/constraints/map.rst.inc | 1 + 2 files changed, 108 insertions(+) create mode 100644 reference/constraints/Ulid.rst diff --git a/reference/constraints/Ulid.rst b/reference/constraints/Ulid.rst new file mode 100644 index 00000000000..7bcae08e961 --- /dev/null +++ b/reference/constraints/Ulid.rst @@ -0,0 +1,107 @@ +ULID +==== + +.. versionadded:: 5.2 + + The ULID validator was introduced in Symfony 5.2. + +Validates that a value is a valid `Universally Unique Lexicographically Sortable Identifier (ULID)`_. + +========== =================================================================== +Applies to :ref:`property or method ` +Options - `groups`_ + - `message`_ + - `normalizer`_ + - `payload`_ +Class :class:`Symfony\\Component\\Validator\\Constraints\\Ulid` +Validator :class:`Symfony\\Component\\Validator\\Constraints\\UlidValidator` +========== =================================================================== + +Basic Usage +----------- + +.. configuration-block:: + + .. code-block:: php-annotations + + // src/Entity/File.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class File + { + /** + * @Assert\Ulid + */ + protected $identifier; + } + + .. code-block:: yaml + + # config/validator/validation.yaml + App\Entity\File: + properties: + identifier: + - Ulid: ~ + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // src/Entity/File.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Mapping\ClassMetadata; + + class File + { + public static function loadValidatorMetadata(ClassMetadata $metadata) + { + $metadata->addPropertyConstraint('identifier', new Assert\Ulid()); + } + } + +.. include:: /reference/constraints/_empty-values-are-valid.rst.inc + +Options +------- + +.. include:: /reference/constraints/_groups-option.rst.inc + +``message`` +~~~~~~~~~~~ + +**type**: ``string`` **default**: ``This is not a valid ULID.`` + +This message is shown if the string is not a valid ULID. + +You can use the following parameters in this message: + +=============== ============================================================== +Parameter Description +=============== ============================================================== +``{{ value }}`` The current (invalid) value +``{{ label }}`` Corresponding form field label +=============== ============================================================== + +.. include:: /reference/constraints/_normalizer-option.rst.inc + +.. include:: /reference/constraints/_payload-option.rst.inc + + +.. _`Universally Unique Lexicographically Sortable Identifier (ULID)`: https://github.com/ulid/spec diff --git a/reference/constraints/map.rst.inc b/reference/constraints/map.rst.inc index f9bf67e80f6..020e84cde65 100644 --- a/reference/constraints/map.rst.inc +++ b/reference/constraints/map.rst.inc @@ -24,6 +24,7 @@ String Constraints * :doc:`Ip ` * :doc:`Json ` * :doc:`Uuid ` +* :doc:`Ulid ` * :doc:`UserPassword ` * :doc:`NotCompromisedPassword ` From 3facbc530c0aaae1f7687671a4d239d0702a3539 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 6 Oct 2020 14:19:34 +0200 Subject: [PATCH 512/752] Fix: Build --- reference/constraints.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/reference/constraints.rst b/reference/constraints.rst index b0ca049124f..56acb087114 100644 --- a/reference/constraints.rst +++ b/reference/constraints.rst @@ -21,6 +21,7 @@ Validation Constraints Reference constraints/Hostname constraints/Ip constraints/Uuid + constraints/Ulid constraints/Json constraints/EqualTo From 921e09654c3729303f129609f325d85e88269079 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 6 Oct 2020 14:37:27 +0200 Subject: [PATCH 513/752] Minor --- http_client.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http_client.rst b/http_client.rst index 240d28d1e73..7ef133d339e 100644 --- a/http_client.rst +++ b/http_client.rst @@ -622,7 +622,7 @@ according to the ``multipart/form-data`` content-type. The .. tip:: When using multidimensional arrays the :class:`Symfony\\Component\\Mime\\Part\\Multipart\\FormDataPart` - automatically appends ``[key]`` to the name of the field:: + class automatically appends ``[key]`` to the name of the field:: $formData = new FormDataPart([ 'array_field' => [ From 3df4d9ea244b4e4f9273cea465fb51e347bc92e2 Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Tue, 6 Oct 2020 17:57:30 +0200 Subject: [PATCH 514/752] Document usage of Symfony Mailer for error email Related to https://github.com/symfony/monolog-bundle/pull/354 --- logging/monolog_email.rst | 49 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git a/logging/monolog_email.rst b/logging/monolog_email.rst index 5d172ca0428..cfa2730265f 100644 --- a/logging/monolog_email.rst +++ b/logging/monolog_email.rst @@ -4,10 +4,9 @@ How to Configure Monolog to Email Errors ======================================== -.. caution:: +.. versionadded:: 3.6.0 - This feature is not compatible yet with the new :doc:`Symfony mailer `, - so it requires using SwiftMailer. + Support for emailing errors using :doc:`Symfony mailer ` was added in MonologBundle 3.6.0. `Monolog`_ can be configured to send an email when an error occurs within an application. The configuration for this requires a few nested handlers @@ -33,9 +32,9 @@ it is broken down. handler: deduplicated deduplicated: type: deduplication - handler: swift - swift: - type: swift_mailer + handler: symfony_mailer + symfony_mailer: + type: symfony_mailer from_email: 'error@example.com' to_email: 'error@example.com' # or list of recipients @@ -73,11 +72,11 @@ it is broken down. [ 'type' => 'deduplication', - 'handler' => 'swift', + 'handler' => 'symfony_mailer', ], - 'swift' => [ - 'type' => 'swift_mailer', + 'symfony_mailer' => [ + 'type' => 'symfony_mailer', 'from_email' => 'error@example.com', 'to_email' => 'error@example.com', // or a list of recipients @@ -162,7 +161,7 @@ You can adjust the time period using the ``time`` option: type: deduplication # the time in seconds during which duplicate entries are discarded (default: 60) time: 10 - handler: swift + handler: symfony_mailer .. code-block:: xml @@ -172,7 +171,7 @@ You can adjust the time period using the ``time`` option: + handler="symfony_mailer"/> .. code-block:: php @@ -184,12 +183,12 @@ You can adjust the time period using the ``time`` option: 'type' => 'deduplication', // the time in seconds during which duplicate entries are discarded (default: 60) 'time' => 10, - 'handler' => 'swift', + 'handler' => 'symfony_mailer', ], ], ]); -The messages are then passed to the ``swift`` handler. This is the handler that +The messages are then passed to the ``symfony_mailer`` handler. This is the handler that actually deals with emailing you the error. The settings for this are straightforward, the to and from addresses, the formatter, the content type and the subject. @@ -217,9 +216,9 @@ get logged on the server as well as the emails being sent: level: debug deduplicated: type: deduplication - handler: swift - swift: - type: swift_mailer + handler: symfony_mailer + symfony_mailer: + type: symfony_mailer from_email: 'error@example.com' to_email: 'error@example.com' subject: 'An Error Occurred! %%message%%' @@ -259,11 +258,11 @@ get logged on the server as well as the emails being sent: [ 'type' => 'deduplication', - 'handler' => 'swift', + 'handler' => 'symfony_mailer', ], - 'swift' => [ - 'type' => 'swift_mailer', + 'symfony_mailer' => [ + 'type' => 'symfony_mailer', 'from_email' => 'error@example.com', 'to_email' => 'error@example.com', // or a list of recipients From 922932f6c1b32580a19937ab06211e04100cd8fc Mon Sep 17 00:00:00 2001 From: Antoine Makdessi Date: Tue, 6 Oct 2020 18:09:46 +0200 Subject: [PATCH 515/752] Makes DOCtor-RST happy Error: You are not allowed to use version "3.6.0". Only major version "5" is allowed. Error: Please only provide ".. versionadded::" if the version is greater/equal "5.0" --- logging/monolog_email.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging/monolog_email.rst b/logging/monolog_email.rst index cfa2730265f..225bcd923c8 100644 --- a/logging/monolog_email.rst +++ b/logging/monolog_email.rst @@ -4,7 +4,7 @@ How to Configure Monolog to Email Errors ======================================== -.. versionadded:: 3.6.0 +.. versionadded:: 3.6 Support for emailing errors using :doc:`Symfony mailer ` was added in MonologBundle 3.6.0. From d20f07c2e560ffca6790ff3ef54793decb2f637d Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 7 Oct 2020 08:13:14 +0200 Subject: [PATCH 516/752] Fix: DOXtor-RST --- .doctor-rst.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index f3ac893b0cd..3051b9325f4 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -92,3 +92,4 @@ whitelist: - '.. versionadded:: 0.2' # MercureBundle - 'provides a ``loginUser()`` method to simulate logging in in your functional' - '.. code-block:: twig' + - '.. versionadded:: 3.6' # MonologBundle From 202b9e6834df02d151fb87349e71597973d5e0a1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Wed, 7 Oct 2020 08:13:50 +0200 Subject: [PATCH 517/752] Update message --- logging/monolog_email.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/logging/monolog_email.rst b/logging/monolog_email.rst index 225bcd923c8..2a07a08f706 100644 --- a/logging/monolog_email.rst +++ b/logging/monolog_email.rst @@ -6,7 +6,7 @@ How to Configure Monolog to Email Errors .. versionadded:: 3.6 - Support for emailing errors using :doc:`Symfony mailer ` was added in MonologBundle 3.6.0. + Support for emailing errors using :doc:`Symfony mailer ` was added in MonologBundle 3.6. `Monolog`_ can be configured to send an email when an error occurs within an application. The configuration for this requires a few nested handlers From 5ddd135bc3669aa61278fd57c71b32b16999c37a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 7 Oct 2020 09:24:48 +0200 Subject: [PATCH 518/752] Tweaks --- components/semaphore.rst | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/components/semaphore.rst b/components/semaphore.rst index 4677b0627ba..5f26c781164 100644 --- a/components/semaphore.rst +++ b/components/semaphore.rst @@ -24,10 +24,14 @@ Installation Usage ----- -Semaphore are used to guarantee exclusive access to some shared resource. +In computer science, a semaphore is a variable or abstract data type used to +control access to a common resource by multiple processes in a concurrent +system such as a multitasking operating system. The main difference +with :doc:`locks ` is that semaphores allow more than one process to +access a resource, whereas locks only allow one process. -Semaphore are created using a :class:`Symfony\\Component\\Semaphore\\SemaphoreFactory` class, -which in turn requires another class to manage the storage of Semaphore:: +Create semaphores with the :class:`Symfony\\Component\\Semaphore\\SemaphoreFactory` +class, which in turn requires another class to manage the storage:: use Symfony\Component\Semaphore\SemaphoreFactory; use Symfony\Component\Semaphore\Store\RedisStore; @@ -38,13 +42,12 @@ which in turn requires another class to manage the storage of Semaphore:: $store = new RedisStore($redis); $factory = new SemaphoreFactory($store); - The semaphore is created by calling the :method:`Symfony\\Component\\Semaphore\\SemaphoreFactory::createSemaphore` method. Its first argument is an arbitrary string that represents the locked -resource. Its second argument is the number of process allowed. Then, a call to -the :method:`Symfony\\Component\\Semaphore\\SemaphoreInterface::acquire` method -will try to acquire the semaphore:: +resource. Its second argument is the maximum number of process allowed. Then, a +call to the :method:`Symfony\\Component\\Semaphore\\SemaphoreInterface::acquire` +method will try to acquire the semaphore:: // ... $semaphore = $factory->createSemaphore('pdf-invoice-generation', 2); @@ -62,7 +65,7 @@ already acquired. .. note:: - Unlike other implementations, the Semaphore Component distinguishes + Unlike other implementations, the Semaphore component distinguishes semaphores instances even when they are created for the same resource. If a semaphore has to be used by several services, they should share the same ``Semaphore`` instance returned by the ``SemaphoreFactory::createSemaphore`` @@ -73,7 +76,6 @@ already acquired. If you don't release the semaphore explicitly, it will be released automatically on instance destruction. In some cases, it can be useful to lock a resource across several requests. To disable the automatic release - behavior, set the last argument of the ``createLock()`` method to - ``false``. + behavior, set the fifth argument of the ``createLock()`` method to ``false``. .. _`semaphores`: https://en.wikipedia.org/wiki/Semaphore_(programming) From 2bad79552545666d5032e6aece2fb1109b6c1bba Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 7 Oct 2020 13:19:59 +0200 Subject: [PATCH 519/752] Wrap long lines --- logging/monolog_email.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/logging/monolog_email.rst b/logging/monolog_email.rst index 2a07a08f706..22ed4d08928 100644 --- a/logging/monolog_email.rst +++ b/logging/monolog_email.rst @@ -6,7 +6,8 @@ How to Configure Monolog to Email Errors .. versionadded:: 3.6 - Support for emailing errors using :doc:`Symfony mailer ` was added in MonologBundle 3.6. + Support for emailing errors using :doc:`Symfony mailer ` was added + in MonologBundle 3.6. `Monolog`_ can be configured to send an email when an error occurs within an application. The configuration for this requires a few nested handlers From 3914a0649a51503fd6de039679a360d457764415 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 7 Oct 2020 15:54:25 +0200 Subject: [PATCH 520/752] Add jitter documentation --- reference/configuration/framework.rst | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index efaff7afcd6..2a02171ff83 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -148,6 +148,7 @@ Configuration * `max_delay`_ * `max_retries`_ * `multiplier`_ + * `jitter`_ * `timeout`_ * `max_duration`_ @@ -164,6 +165,7 @@ Configuration * `max_delay`_ * `max_retries`_ * `multiplier`_ + * `jitter`_ * `http_method_override`_ * `ide`_ @@ -784,7 +786,8 @@ will automaticaly retry failed HTTP requests. max_retries: 2 delay: 1000 multiplier: 3 - max_delay: 500 + max_delay: 5000 + jitter: 0.3 scoped_clients: my_api.client: @@ -835,8 +838,8 @@ backoff_service The service id used to compute the time to wait between retries. By default, it uses an instance of :class:`Symfony\\Component\\HttpClient\\Retry\\ExponentialBackOff` configured -with ``delay``, ``max_delay`` and ``multiplier`` options. This class has to -implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`. +with ``delay``, ``max_delay``, ``multiplier`` and ``jitter`` options. This +class has to implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`. base_uri ........ @@ -969,6 +972,18 @@ http_version The HTTP version to use, typically ``'1.1'`` or ``'2.0'``. Leave it to ``null`` to let Symfony select the best version automatically. +jitter +...... + +**type**: ``float`` **default**: ``0.1`` + +.. versionadded:: 5.2 + + The ``jitter`` option was introduced in Symfony 5.2. + +The probability (expressed with a float between ``0.0`` and ``1.0``) of +randomness to apply to the delay to wait between retries. + local_cert .......... From f4f5eb9b66b2226838f9c62b413c2edfd54ce130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 7 Oct 2020 11:18:17 +0200 Subject: [PATCH 521/752] Various fixes --- components/lock.rst | 5 ++--- lock.rst | 28 ++++++++++++++++------------ 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index 3dfda5c4f07..0e6cd64f036 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -276,8 +276,6 @@ support blocking, and expects a TTL to avoid stalled locks:: Memcached does not support TTL lower than 1 second. -.. _lock-store-pdo: - .. _lock-store-mongodb: MongoDbStore @@ -339,6 +337,7 @@ MongoDB Connection String: The ``collection`` querystring parameter is not part of the `MongoDB Connection String`_ definition. It is used to allow constructing a ``MongoDbStore`` using a `Data Source Name (DSN)`_ without ``$options``. +.. _lock-store-pdo: PdoStore ~~~~~~~~ @@ -350,7 +349,7 @@ support blocking, and expects a TTL to avoid stalled locks:: use Symfony\Component\Lock\Store\PdoStore; // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO - $databaseConnectionOrDSN = 'mysql:host=127.0.0.1;dbname=lock'; + $databaseConnectionOrDSN = 'mysql:host=127.0.0.1;dbname=app'; $store = new PdoStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']); .. note:: diff --git a/lock.rst b/lock.rst index 72fb36dc779..1eb5ce95c64 100644 --- a/lock.rst +++ b/lock.rst @@ -56,10 +56,11 @@ this behavior by using the ``lock`` key like: lock: 'zookeeper://z1.docker' lock: 'zookeeper://z1.docker,z2.docker' lock: 'sqlite:///%kernel.project_dir%/var/lock.db' - lock: 'mysql:host=127.0.0.1;dbname=lock' - lock: 'pgsql:host=127.0.0.1;dbname=lock' - lock: 'sqlsrv:server=localhost;Database=test' - lock: 'oci:host=localhost;dbname=test' + lock: 'mysql:host=127.0.0.1;dbname=app' + lock: 'pgsql:host=127.0.0.1;dbname=app' + lock: 'sqlsrv:server=127.0.0.1;Database=app' + lock: 'oci:host=127.0.0.1;dbname=app' + lock: 'mongodb://127.0.0.1/app?collection=lock' lock: '%env(LOCK_DSN)%' # named locks @@ -102,13 +103,15 @@ this behavior by using the ``lock`` key like: sqlite:///%kernel.project_dir%/var/lock.db - mysql:host=127.0.0.1;dbname=lock + mysql:host=127.0.0.1;dbname=app - pgsql:host=127.0.0.1;dbname=lock + pgsql:host=127.0.0.1;dbname=app - sqlsrv:server=localhost;Database=test + sqlsrv:server=127.0.0.1;Database=app - oci:host=localhost;dbname=test + oci:host=127.0.0.1;dbname=app + + mongodb://127.0.0.1/app?collection=lock %env(LOCK_DSN)% @@ -135,10 +138,11 @@ this behavior by using the ``lock`` key like: 'lock' => 'zookeeper://z1.docker', 'lock' => 'zookeeper://z1.docker,z2.docker', 'lock' => 'sqlite:///%kernel.project_dir%/var/lock.db', - 'lock' => 'mysql:host=127.0.0.1;dbname=lock', - 'lock' => 'pgsql:host=127.0.0.1;dbname=lock', - 'lock' => 'sqlsrv:server=localhost;Database=test', - 'lock' => 'oci:host=localhost;dbname=test', + 'lock' => 'mysql:host=127.0.0.1;dbname=app', + 'lock' => 'pgsql:host=127.0.0.1;dbname=app', + 'lock' => 'sqlsrv:server=127.0.0.1;Database=app', + 'lock' => 'oci:host=127.0.0.1;dbname=app', + 'lock' => 'mongodb://127.0.0.1/app?collection=lock', 'lock' => '%env(LOCK_DSN)%', // named locks From 8909cde0a7f8c69b371ff56f77e4a76efe0a1e57 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 7 Oct 2020 16:56:04 +0200 Subject: [PATCH 522/752] Reword --- reference/configuration/framework.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 2a02171ff83..be472a8fe41 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -975,14 +975,16 @@ to let Symfony select the best version automatically. jitter ...... -**type**: ``float`` **default**: ``0.1`` +**type**: ``float`` **default**: ``0.1`` (must be between 0.0 and 1.0) .. versionadded:: 5.2 The ``jitter`` option was introduced in Symfony 5.2. -The probability (expressed with a float between ``0.0`` and ``1.0``) of -randomness to apply to the delay to wait between retries. +This option adds some randomness to the delay. It's useful to avoid sending +multiple requests to the server at the exact same time. The randomness is +calculated as ``delay * jitter``. For example: if delay is ``1000ms`` and jitter +is ``0.2``, the actual delay will be a number between ``800`` and ``1200`` (1000 +/- 20%). local_cert .......... From cc7ba8020df045225526c3343100a0e959b1f149 Mon Sep 17 00:00:00 2001 From: Nate Wiebe Date: Wed, 7 Oct 2020 17:23:08 -0400 Subject: [PATCH 523/752] Rename the translatable class --- translation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translation.rst b/translation.rst index 238e80ee38c..fbf08ba14a1 100644 --- a/translation.rst +++ b/translation.rst @@ -307,16 +307,16 @@ parts of your application and mocking it in your tests. Instead of translating a string at the time of creation, you can use a "translatable object", which is an instance of the -:class:`Symfony\\Component\\Translation\\Translatable` class. This object stores +:class:`Symfony\\Component\\Translation\\TranslatableMessage` class. This object stores all the information needed to fully translate its contents when needed:: - use Symfony\Component\Translation\Translatable; + use Symfony\Component\Translation\TranslatableMessage; // the first argument is required and it's the original message - $message = new Translatable('Symfony is great!'); + $message = new TranslatableMessage('Symfony is great!'); // the optional second argument defines the translation parameters and // the optional third argument is the translation domain - $status = new Translatable('order.status', ['%status%' => $order->getStatus()], 'store'); + $status = new TranslatableMessage('order.status', ['%status%' => $order->getStatus()], 'store'); Templates are now much simpler because you can pass translatable objects to the ``trans`` filter: From 496ea825b3a9c54f819b0cc1dc6b2f29cc652aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 7 Oct 2020 10:55:55 +0200 Subject: [PATCH 524/752] Add documentation for Postgresql --- components/lock.rst | 40 ++++++++++++++++++++++++++++++++++++++++ lock.rst | 4 ++++ 2 files changed, 44 insertions(+) diff --git a/components/lock.rst b/components/lock.rst index 18b50f9aa46..b159f09f9ae 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -319,6 +319,7 @@ Store Scope Blocking Expiring Sharing :ref:`MemcachedStore ` remote no yes no :ref:`MongoDbStore ` remote no yes no :ref:`PdoStore ` remote no yes no +:ref:`PostgreSqlStore ` remote yes yes yes :ref:`RedisStore ` remote no yes yes :ref:`SemaphoreStore ` local yes no no :ref:`ZookeeperStore ` remote no no no @@ -452,6 +453,29 @@ You can also create this table explicitly by calling the :method:`Symfony\\Component\\Lock\\Store\\PdoStore::createTable` method in your code. +.. _lock-store-pgsql: + +PostgreSqlStore +~~~~~~~~~~~~~~~ + +The PostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL. It requires a +`PDO`_ connection, a `Doctrine DBAL Connection`_, or a +`Data Source Name (DSN)`_. it nativly supports blocking, as weel as sharing +locks. + + use Symfony\Component\Lock\Store\PostgreSqlStore; + + // a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO + $databaseConnectionOrDSN = 'postgresql://myuser:mypassword@localhost:5634/lock'; + $store = new PostgreSqlStore($databaseConnectionOrDSN); + +In opposite to the ``PdoStore``, the ``PostgreSqlStore`` does not need a table to +stores locks and does not expires. + +.. versionadded:: 5.2 + + PostgreSqlStore were introduced in Symfony 5.2. + .. _lock-store-redis: RedisStore @@ -551,6 +575,7 @@ Remote Stores Remote stores (:ref:`MemcachedStore `, :ref:`MongoDbStore `, :ref:`PdoStore `, +:ref:`PostgreSqlStore `, :ref:`RedisStore ` and :ref:`ZookeeperStore `) use a unique token to recognize the true owner of the lock. This token is stored in the @@ -760,6 +785,20 @@ have synchronized clocks. To ensure locks don't expire prematurely; the TTLs should be set with enough extra time to account for any clock drift between nodes. +PostgreSqlStore +~~~~~~~~~~~~~~~ + +The PdoStore relies on the `Advisory Locks`_ properties of the PostgreSQL +database. That means that by using :ref:`PostgreSqlStore ` +the locks will be automatically released at the end of the session in case the +client cannot unlock for any reason. + +If the PostgreSQL service or the machine hosting it restarts, every lock would +be lost without notifying the running processes. + +If the TCP connection is lost, the PostgreSQL may release locks without +notifying the application. + RedisStore ~~~~~~~~~~ @@ -864,6 +903,7 @@ are still running. .. _`a maximum of 1024 bytes in length`: https://docs.mongodb.com/manual/reference/limits/#Index-Key-Limit .. _`ACID`: https://en.wikipedia.org/wiki/ACID +.. _`Advisory Locks`: https://www.postgresql.org/docs/current/explicit-locking.html .. _`Data Source Name (DSN)`: https://en.wikipedia.org/wiki/Data_source_name .. _`Doctrine DBAL Connection`: https://github.com/doctrine/dbal/blob/master/src/Connection.php .. _`Expire Data from Collections by Setting TTL`: https://docs.mongodb.com/manual/tutorial/expire-data/ diff --git a/lock.rst b/lock.rst index 1eb5ce95c64..c3d5cb365e5 100644 --- a/lock.rst +++ b/lock.rst @@ -58,6 +58,7 @@ this behavior by using the ``lock`` key like: lock: 'sqlite:///%kernel.project_dir%/var/lock.db' lock: 'mysql:host=127.0.0.1;dbname=app' lock: 'pgsql:host=127.0.0.1;dbname=app' + lock: 'pgsql+advisory:host=127.0.0.1;dbname=lock' lock: 'sqlsrv:server=127.0.0.1;Database=app' lock: 'oci:host=127.0.0.1;dbname=app' lock: 'mongodb://127.0.0.1/app?collection=lock' @@ -107,6 +108,8 @@ this behavior by using the ``lock`` key like: pgsql:host=127.0.0.1;dbname=app + pgsql+advisory:host=127.0.0.1;dbname=lock + sqlsrv:server=127.0.0.1;Database=app oci:host=127.0.0.1;dbname=app @@ -140,6 +143,7 @@ this behavior by using the ``lock`` key like: 'lock' => 'sqlite:///%kernel.project_dir%/var/lock.db', 'lock' => 'mysql:host=127.0.0.1;dbname=app', 'lock' => 'pgsql:host=127.0.0.1;dbname=app', + 'lock' => 'pgsql+advisory:host=127.0.0.1;dbname=lock', 'lock' => 'sqlsrv:server=127.0.0.1;Database=app', 'lock' => 'oci:host=127.0.0.1;dbname=app', 'lock' => 'mongodb://127.0.0.1/app?collection=lock', From 62a39bce24081a2fa505cfc6014ae985e654398e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 8 Oct 2020 17:31:22 +0200 Subject: [PATCH 525/752] Tweaks --- components/lock.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/lock.rst b/components/lock.rst index b159f09f9ae..d34908c2777 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -460,8 +460,7 @@ PostgreSqlStore The PostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL. It requires a `PDO`_ connection, a `Doctrine DBAL Connection`_, or a -`Data Source Name (DSN)`_. it nativly supports blocking, as weel as sharing -locks. +`Data Source Name (DSN)`_. It supports native blocking, as well as sharing locks. use Symfony\Component\Lock\Store\PostgreSqlStore; @@ -470,11 +469,11 @@ locks. $store = new PostgreSqlStore($databaseConnectionOrDSN); In opposite to the ``PdoStore``, the ``PostgreSqlStore`` does not need a table to -stores locks and does not expires. +store locks and does not expire. .. versionadded:: 5.2 - PostgreSqlStore were introduced in Symfony 5.2. + The ``PostgreSqlStore`` was introduced in Symfony 5.2. .. _lock-store-redis: From d90991e30b62aba571592c10aae522840fb562b8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 7 Oct 2020 16:26:51 +0200 Subject: [PATCH 526/752] [RateLimiter] Added the docs for the new component --- index.rst | 1 + rate_limiter.rst | 195 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 196 insertions(+) create mode 100644 rate_limiter.rst diff --git a/index.rst b/index.rst index 52614d4d9b8..a4f512151f5 100644 --- a/index.rst +++ b/index.rst @@ -52,6 +52,7 @@ Topics notifier performance profiler + rate_limiter routing security session diff --git a/rate_limiter.rst b/rate_limiter.rst new file mode 100644 index 00000000000..358a1d62c00 --- /dev/null +++ b/rate_limiter.rst @@ -0,0 +1,195 @@ +Rate Limiter +============ + +.. versionadded:: 5.2 + + The RateLimiter component was introduced in Symfony 5.2 as an + :doc:`experimental feature `. + +A "rate limiter" controls how frequently some event (e.g. an HTTP request or a +login attempt) is allowed to happen. Rate limiting is commonly used as a +defensive measure to protect services from excessive use (intended or not) and +maintain their availability. It's also useful to control your internal or +outbound processes (e.g. limit the number of simultaneously processed messages). + +Symfony uses these rate limiters in built-in features like "login throttling", +which limits how many failed login attempts a user can make in a given period of +time, but you can use them for your own features too. + +Rate Limiting Strategies +------------------------ + +Symfony's rate limiter implements two of the most common strategies to enforce +rate limits: **fixed window** and **token bucket**. + +Fixed Window Rate Limiter +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is the simplest technique and it's based on setting a limit for a given +interval of time. For example: 5,000 requests per hour or 3 login attempts +every 15 minutes. + +Its main drawback is that resource usage is not evenly distributed in time and +it can overload the server at the window edges. In the previous example, a user +could make the 4,999 requests in the last minute of some hour and another 5,000 +requests during the first minute of the next hour, making 9,999 requests in +total in two minutes and possibly overloading the server. + +Token Bucket Rate Limiter +~~~~~~~~~~~~~~~~~~~~~~~~~ + +This technique implements the `token bucket algorithm`_, which defines a +continuously updating budget of resource usage. It roughly works like this: + +* A bucket is created with an initial set of tokens; +* A new token is added to the bucket with a predefined frequency (e.g. every second); +* Allowing an event consumes one or more tokens; +* If the bucket still contains tokens, the event is allowed; otherwise, it's denied; +* If the bucket is at full capacity, new tokens are discarded. + +Installation +------------ + +Before using a rate limiter for the first time, run the following command to +install the associated Symfony Component in your application: + +.. code-block:: terminal + + $ composer require symfony/rate-limiter + +Configuration +------------- + +The following example creates two different rate limiters for an API service, to +enforce different levels of service (free or paid): + +.. code-block:: yaml + + # config/packages/rate_limiter.yaml + framework: + rate_limiter: + anonymous_api: + strategy: fixed_window + limit: 100 + interval: '60 minutes' + authenticated_api: + strategy: token_bucket + limit: 5000 + rate: { interval: '15 minutes', amount: 500 } + +.. note:: + + The value of the ``interval`` option must be a number followed by any of the + units accepted by the `PHP date relative formats`_ (e.g. ``3 seconds``, + ``10 hours``, ``1 day``, etc.) + +In the ``anonymous_api`` limiter, after making the first HTTP request, you can +make up to 100 requests in the next 60 minutes. After that time, the counter +resets and you have another 100 requests for the following 60 minutes. + +In the ``authenticated_api`` limiter, after making the first HTTP request you +are allowed to make up to 5,000 HTTP requests in total, and this number grows +at a rate of another 500 requests every 15 minutes. If you don't make that +number of requests, the unused ones don't accumulate (the ``limit`` option +prevents that number from being higher than 5,000). + +Rate Limiting in Action +----------------------- + +After having installed and configured the rate limiter, inject it in any service +or controller and call the ``consume()`` method to try to consume a given number +of tokens. For example, this controller uses the previous rate limiter to control +the number of requests to the API:: + + // src/Controller/ApiController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; + use Symfony\Component\RateLimiter\Limiter; + + class ApiController extends AbstractController + { + // the variable name must be: "rate limiter name" + "limiter" suffix + public function index(Limiter $anonymousApiLimiter) + { + // create a limiter based on a unique identifier of the client + // (e.g. the client's IP address, a username/email, an API key, etc.) + $limiter = $anonymousApiLimiter->create($request->getClientIp()); + + // the argument of consume() is the number of tokens to consume + // and returns an object of type Limit + if (false === $anonymous_api_limiter->consume(1)->isAccepted()) { + throw new TooManyRequestsHttpException(); + } + + // you can also use the ensureAccepted() method - which throws a + // RateLimitExceededException if the limit has been reached + // $limiter->consume(1)->ensureAccepted(); + + // ... + } + + // ... + } + +.. note:: + + In a real application, instead of checking the rate limiter in all the API + controller methods, create an :doc:`event listener or subscriber ` + for the :ref:`kernel.request event ` + and check the rate limiter once for all requests. + +In other scenarios you may want instead to wait as long as needed until a new +token is available. In those cases, use the ``wait()`` method:: + + // src/Controller/ApiController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\RateLimiter\Limiter; + + class ApiController extends AbstractController + { + public function registerUser(Request $request, Limiter $authenticatedApiLimiter) + { + $apiKey = $request->headers->get('apikey'); + $limiter = $authenticatedApiLimiter->create($apiKey); + + // this blocks the application until the given number of tokens can be consumed + do { + $limit = $limiter->consume(1); + $limit->wait(); + } while (!$limit->isAccepted()); + + // ... + } + + // ... + } + +Rate Limiter Storage and Locking +-------------------------------- + +Rate limiters use the default cache and locking mechanisms defined in your +Symfony application. If you prefer to change that, use the ``lock`` and +``storage`` options: + +.. code-block:: yaml + + # config/packages/rate_limiter.yaml + framework: + rate_limiter: + anonymous_api_limiter: + # ... + # the value is the name of any cache pool defined in your application + cache_pool: 'app.redis_cache' + # or define a service implementing StorageInterface to use a different + # mechanism to store the limiter information + storage: 'App\RateLimiter\CustomRedisStorage' + # the value is the name of any lock defined in your application + lock: 'app.rate_limiter_lock' + +.. _`token bucket algorithm`: https://en.wikipedia.org/wiki/Token_bucket +.. _`PHP date relative formats`: https://www.php.net/datetime.formats.relative From 4919af7a2d2b0329a67ddcbd1f71e24001cf53c3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 9 Oct 2020 09:31:37 +0200 Subject: [PATCH 527/752] Add Crawler assert functions --- testing/functional_tests_assertions.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 1f3b13d9763..4da642bc6dd 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -81,6 +81,10 @@ Crawler - ``assertPageTitleContains()`` - ``assertInputValueSame()`` - ``assertInputValueNotSame()`` +- ``assertCheckboxChecked()`` +- ``assertCheckboxNotChecked()`` +- ``assertFormValue()`` +- ``assertNoFormValue()`` Mailer ~~~~~~ From a3fcdd0eee777e2d409b3344e7925a172a4957cd Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 9 Oct 2020 13:01:03 +0200 Subject: [PATCH 528/752] Added the versionadded directive --- testing/functional_tests_assertions.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 4da642bc6dd..457d8c39021 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -86,6 +86,12 @@ Crawler - ``assertFormValue()`` - ``assertNoFormValue()`` +.. versionadded:: 5.2 + + The ``assertCheckboxChecked()``, ``assertCheckboxNotChecked()``, + ``assertFormValue()`` and ``assertNoFormValue()`` methods were introduced + in Symfony 5.2. + Mailer ~~~~~~ From f8449f5c8cb67c5b043525d57c7ff6eec45ba257 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 9 Oct 2020 09:48:36 +0200 Subject: [PATCH 529/752] Document Kernel::getBuildDir() --- reference/configuration/kernel.rst | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 5f52cd155e7..e0f83d71250 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -84,6 +84,7 @@ method to return the right project directory:: } } + Cache Directory ~~~~~~~~~~~~~~~ @@ -91,13 +92,35 @@ Cache Directory This returns the absolute path of the cache directory of your Symfony project. It's calculated automatically based on the current -:ref:`environment `. +:ref:`environment `. Data might be written to this path +at runtime. This value is exposed via the ``kernel.cache_dir`` configuration parameter and the :method:`Symfony\\Component\\HttpKernel\\Kernel::getCacheDir` method. To -change this setting, override the ``getCacheDir()`` method to return the right +change this setting, override the ``getCacheDir()`` method to return the correct cache directory. +Build Directory +~~~~~~~~~~~~~~~ + +**type**: ``string`` **default**: ``$this->getCacheDir()`` + +.. versionadded:: 5.2 + + The build directory feature was introduced in Symfony 5.2. + +This returns the absolute path of a build directory of your Symfony project. This +directory can be used to separate read-only cache (i.e. the compiled container) +from read-write cache (i.e. cache pools). Specify a non-default value when the +application is deployed in a read-only filesystem like a Docker container or AWS +Lambda. + +This value is exposed via the ``kernel.build_dir`` configuration parameter and +the :method:`Symfony\\Component\\HttpKernel\\Kernel::getBuildDir` method. To +change this setting, override the ``getBuildDir()`` method to return the correct +build directory. + + Log Directory ~~~~~~~~~~~~~ From ffcc05d030dfef0cec7bc4832c1ff6d380b7dbec Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 9 Oct 2020 13:06:03 +0200 Subject: [PATCH 530/752] Tweaks --- reference/configuration/kernel.rst | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/reference/configuration/kernel.rst b/reference/configuration/kernel.rst index 740a8df17fd..27707807ed4 100644 --- a/reference/configuration/kernel.rst +++ b/reference/configuration/kernel.rst @@ -88,7 +88,6 @@ method to return the right project directory:: } } - Cache Directory ~~~~~~~~~~~~~~~ @@ -96,8 +95,8 @@ Cache Directory This returns the absolute path of the cache directory of your Symfony project. It's calculated automatically based on the current -:ref:`environment `. Data might be written to this path -at runtime. +:ref:`environment `. Data might be written to this +path at runtime. This value is exposed via the ``kernel.cache_dir`` configuration parameter and the :method:`Symfony\\Component\\HttpKernel\\Kernel::getCacheDir` method. To @@ -115,9 +114,9 @@ Build Directory This returns the absolute path of a build directory of your Symfony project. This directory can be used to separate read-only cache (i.e. the compiled container) -from read-write cache (i.e. cache pools). Specify a non-default value when the -application is deployed in a read-only filesystem like a Docker container or AWS -Lambda. +from read-write cache (i.e. :doc:`cache pools `). Specify a non-default +value when the application is deployed in a read-only filesystem like a Docker +container or AWS Lambda. This value is exposed via the ``kernel.build_dir`` configuration parameter and the :method:`Symfony\\Component\\HttpKernel\\Kernel::getBuildDir` method. To From 79f5dd6eedf3f24726d4bcae2776568c9fb92154 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 10:15:10 +0200 Subject: [PATCH 531/752] Added docs about default_lifetime This will fix #14347 --- reference/configuration/framework.rst | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index f6f11d7bd8f..f79160be10c 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2847,9 +2847,14 @@ Can also be the service id of another cache pool where tags will be stored. default_lifetime """""""""""""""" -**type**: ``integer`` +**type**: ``integer`` | ``string`` -Default lifetime of your cache items in seconds. +Default lifetime of your cache items. Given an integer value to set the default +lifetime in seconds. A string value could be ISO 8601 time interval, like ``"PT5M"`` +or a PHP date expression that is accepted by ``strtotime()``, like ``"5 minutes"``. + +If no value is provided, the cache adapter will fallback to the default value on +the actual cache storage. provider """""""" From eb962cf77f79f1f24791a125176bd4eea6a1cb86 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 11 Oct 2020 12:45:45 +0200 Subject: [PATCH 532/752] Typo --- reference/configuration/framework.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index f79160be10c..0e09a21c5cf 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2849,7 +2849,7 @@ default_lifetime **type**: ``integer`` | ``string`` -Default lifetime of your cache items. Given an integer value to set the default +Default lifetime of your cache items. Give an integer value to set the default lifetime in seconds. A string value could be ISO 8601 time interval, like ``"PT5M"`` or a PHP date expression that is accepted by ``strtotime()``, like ``"5 minutes"``. From 3d01373f664c97ecd52ce11d88fdd10fcc3217af Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 11 Oct 2020 13:11:00 +0200 Subject: [PATCH 533/752] [Monolog] Mention the SwitchUserTokenProcessor --- logging/processors.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/logging/processors.rst b/logging/processors.rst index e8ecf96593b..605c571b244 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -171,6 +171,14 @@ Symfony's MonologBridge provides processors that can be registered inside your a Adds information from the current user's token to the record namely username, roles and whether the user is authenticated. +:class:`Symfony\\Bridge\\Monolog\\Processor\\SwitchUserTokenProcessor` + Adds information about the user who is impersonating the logged in user, + namely username, roles and whether the user is authenticated. + + .. versionadded:: 5.2 + + The ``SwitchUserTokenProcessor`` was introduced in Symfony 5.2. + :class:`Symfony\\Bridge\\Monolog\\Processor\\WebProcessor` Overrides data from the request using the data inside Symfony's request object. From 4ca794e0e535f9347e05fb4999a93f179092a6a3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 12 Sep 2020 00:54:28 +0200 Subject: [PATCH 534/752] [Routing] Document the Route attribute --- _build/conf.py | 1 + best_practices.rst | 11 +- contributing/documentation/format.rst | 1 + routing.rst | 483 +++++++++++++++++++++++--- 4 files changed, 446 insertions(+), 50 deletions(-) diff --git a/_build/conf.py b/_build/conf.py index 49cc12581ad..071991c5411 100644 --- a/_build/conf.py +++ b/_build/conf.py @@ -111,6 +111,7 @@ lexers['markdown'] = TextLexer() lexers['php'] = PhpLexer(startinline=True) lexers['php-annotations'] = PhpLexer(startinline=True) +lexers['php-attributes'] = PhpLexer(startinline=True) lexers['php-standalone'] = PhpLexer(startinline=True) lexers['php-symfony'] = PhpLexer(startinline=True) lexers['rst'] = RstLexer() diff --git a/best_practices.rst b/best_practices.rst index 02434a7c812..f43d4798452 100644 --- a/best_practices.rst +++ b/best_practices.rst @@ -223,12 +223,13 @@ important parts of your application. .. _best-practice-controller-annotations: -Use Annotations to Configure Routing, Caching and Security -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Use Attributes or Annotations to Configure Routing, Caching and Security +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Using annotations for routing, caching and security simplifies configuration. -You don't need to browse several files created with different formats (YAML, XML, -PHP): all the configuration is just where you need it and it only uses one format. +Using attributes or annotations for routing, caching and security simplifies +configuration. You don't need to browse several files created with different +formats (YAML, XML, PHP): all the configuration is just where you need it and +it only uses one format. Don't Use Annotations to Configure the Controller Template ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/contributing/documentation/format.rst b/contributing/documentation/format.rst index 733e9e6f21f..2c465096f0b 100644 --- a/contributing/documentation/format.rst +++ b/contributing/documentation/format.rst @@ -104,6 +104,7 @@ Markup Format Use It to Display ``html+php`` PHP code blended with HTML ``ini`` INI ``php-annotations`` PHP Annotations +``php-attributes`` PHP Attributes =================== ====================================== Adding Links diff --git a/routing.rst b/routing.rst index 214b57574ae..832b5df2c53 100644 --- a/routing.rst +++ b/routing.rst @@ -15,22 +15,33 @@ provides other useful features, like generating SEO-friendly URLs (e.g. Creating Routes --------------- -Routes can be configured in YAML, XML, PHP or using annotations. All formats -provide the same features and performance, so choose your favorite. -:ref:`Symfony recommends annotations ` +Routes can be configured in YAML, XML, PHP or using either attributes or +annotations. All formats provide the same features and performance, so choose +your favorite. +:ref:`Symfony recommends attributes ` because it's convenient to put the route and controller in the same place. -Creating Routes as Annotations -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Creating Routes as Attributes or Annotations +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +On PHP 8, you can use native attributes to configure routes right away. On +PHP 7, where attributes are not available, you can use annotations instead, +provided by the Doctrine Annotations library. -Run this command once in your application to add support for annotations: +In case you want to use annotations instead of attributes, run this command +once in your application to enable them: .. code-block:: terminal $ composer require annotations -In addition to installing the needed dependencies, this command creates the -following configuration file: +.. versionadded:: 5.2 + + The ability to use PHP attributes to configure routes was introduced in + Symfony 5.2. Prior to this, Doctrine Annotations were the only way to + annotate controller actions with routing configuration. + +This command also creates the following configuration file: .. code-block:: yaml @@ -49,22 +60,43 @@ any PHP class stored in the ``src/Controller/`` directory. Suppose you want to define a route for the ``/blog`` URL in your application. To do so, create a :doc:`controller class ` like the following:: - // src/Controller/BlogController.php - namespace App\Controller; +.. configuration-block:: - use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + .. code-block:: php-annotations - class BlogController extends AbstractController - { - /** - * @Route("/blog", name="blog_list") - */ - public function list() + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController { - // ... + /** + * @Route("/blog", name="blog_list") + */ + public function list() + { + // ... + } + } + + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + #[Route('/blog', name: 'blog_list')] + public function list() + { + // ... + } } - } This configuration defines a route called ``blog_list`` that matches when the user requests the ``/blog`` URL. When the match occurs, the application runs @@ -182,6 +214,28 @@ Use the ``methods`` option to restrict the verbs each route should respond to: } } + .. code-block:: php-attributes + + // src/Controller/BlogApiController.php + namespace App\Controller; + + // ... + + class BlogApiController extends AbstractController + { + #[Route('/api/posts/{id}', methods: ['GET', 'HEAD'])] + public function show(int $id) + { + // ... return a JSON response with the post + } + + #[Route('/api/posts/{id}', methods: ['PUT'])] + public function edit(int $id) + { + // ... edit a post + } + } + .. code-block:: yaml # config/routes.yaml @@ -274,6 +328,29 @@ arbitrary matching logic: } } + .. code-block:: php-attributes + + // src/Controller/DefaultController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class DefaultController extends AbstractController + { + #[Route( + '/contact', + name: 'contact', + condition: "context.getMethod() in ['GET', 'HEAD'] and request.headers.get('User-Agent') matches '/firefox/i'", + )] + // expressions can also include config parameters: + // condition: "request.headers.get('User-Agent') matches '%app.allowed_browsers%'" + public function contact() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -424,6 +501,28 @@ defined as ``/blog/{slug}``: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + // ... + + #[Route('/blog/{slug}', name: 'blog_show')] + public function show(string $slug) + { + // $slug will equal the dynamic part of the URL + // e.g. at /blog/yay-routing, then $slug='yay-routing' + + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -507,6 +606,29 @@ the ``{page}`` parameter using the ``requirements`` option: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + #[Route('/blog/{page}', name: 'blog_list', requirements: ['page' => '\d+'])] + public function list(int $page) + { + // ... + } + + #[Route('/blog/{slug}', name: 'blog_show')] + public function show($slug) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -610,6 +732,23 @@ concise, but it can decrease route readability when requirements are complex: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + #[Route('/blog/{page<\d+>}', name: 'blog_list')] + public function list(int $page) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -678,6 +817,23 @@ other configuration formats they are defined with the ``defaults`` option: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + #[Route('/blog/{page}', name: 'blog_list', requirements: ['page' => '\d+'])] + public function list(int $page = 1) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -764,6 +920,23 @@ parameter: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController + { + #[Route('/blog/{page<\d+>?1}', name: 'blog_list')] + public function list(int $page) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -816,36 +989,67 @@ matched. A ``priority`` optional parameter is available in order to let you choose the order of your routes, and it is only available when using annotations. -.. code-block:: php-annotations +.. configuration-block:: - // src/Controller/BlogController.php - namespace App\Controller; + .. code-block:: php-annotations - use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Routing\Annotation\Route; + // src/Controller/BlogController.php + namespace App\Controller; - class BlogController extends AbstractController - { - /** - * This route has a greedy pattern and is defined first. - * - * @Route("/blog/{slug}", name="blog_show") - */ - public function show(string $slug) + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController { - // ... + /** + * This route has a greedy pattern and is defined first. + * + * @Route("/blog/{slug}", name="blog_show") + */ + public function show(string $slug) + { + // ... + } + + /** + * This route could not be matched without defining a higher priority than 0. + * + * @Route("/blog/list", name="blog_list", priority=2) + */ + public function list() + { + // ... + } } - /** - * This route could not be matched without defining a higher priority than 0. - * - * @Route("/blog/list", name="blog_list", priority=2) - */ - public function list() + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class BlogController extends AbstractController { - // ... + /** + * This route has a greedy pattern and is defined first. + */ + #[Route('/blog/{slug}', name: 'blog_show')] + public function show(string $slug) + { + // ... + } + + /** + * This route could not be matched without defining a higher priority than 0. + */ + #[Route('/blog/list', name: 'blog_list', priority: 2)] + public function list() + { + // ... + } } - } The priority parameter expects an integer value. Routes with higher priority are sorted before routes with lower priority. The default value when it is not @@ -955,6 +1159,28 @@ and in route imports. Symfony defines some special attributes with the same name } } + .. code-block:: php-attributes + + // src/Controller/ArticleController.php + namespace App\Controller; + + // ... + class ArticleController extends AbstractController + { + #[Route( + path: '/articles/{_locale}/search.{_format}', + locale: 'en', + format: 'html', + requirements: [ + '_locale' => 'en|fr', + '_format' => 'html|xml', + ], + )] + public function search() + { + } + } + .. code-block:: yaml # config/routes.yaml @@ -1034,6 +1260,22 @@ the controllers of the routes: } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Component\Routing\Annotation\Route; + + class BlogController + { + #[Route('/blog/{page}', name: 'blog_index', defaults: ['page' => 1, 'title' => 'Hello world!'])] + public function index(int $page, string $title) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -1107,6 +1349,22 @@ A possible solution is to change the parameter requirements to be more permissiv } } + .. code-block:: php-attributes + + // src/Controller/DefaultController.php + namespace App\Controller; + + use Symfony\Component\Routing\Annotation\Route; + + class DefaultController + { + #[Route('/share/{token}', name: 'share', requirements: ['token' => '.+'])] + public function share($token) + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -1171,9 +1429,10 @@ It's common for a group of routes to share some options (e.g. all routes related to the blog start with ``/blog``) That's why Symfony includes a feature to share route configuration. -When defining routes as annotations, put the common configuration in the -``@Route`` annotation of the controller class. In other routing formats, define -the common configuration using options when importing the routes. +When defining routes as attributes or annotations, put the common configuration +in the ``#[Route]`` attribute (or ``@Route`` annotation) of the controller +class. In other routing formats, define the common configuration using options +when importing the routes. .. configuration-block:: @@ -1206,6 +1465,29 @@ the common configuration using options when importing the routes. } } + .. code-block:: php-attributes + + // src/Controller/BlogController.php + namespace App\Controller; + + use Symfony\Component\Routing\Annotation\Route; + + #[Route('/blog', requirements: ['_locale' => 'en|es|fr'], name: 'blog_')] + class BlogController + { + #[Route('/{_locale}', name: 'index')] + public function index() + { + // ... + } + + #[Route('/{_locale}/posts/{slug}', name: 'show')] + public function show(Post $post) + { + // ... + } + } + .. code-block:: yaml # config/routes/annotations.yaml @@ -1515,6 +1797,29 @@ host name: } } + .. code-block:: php-attributes + + // src/Controller/MainController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class MainController extends AbstractController + { + #[Route('/', name: 'mobile_homepage', host: 'm.example.com')] + public function mobileHomepage() + { + // ... + } + + #[Route('/', name: 'homepage')] + public function homepage() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -1600,6 +1905,35 @@ multi-tenant applications) and these parameters can be validated too with } } + .. code-block:: php-attributes + + // src/Controller/MainController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class MainController extends AbstractController + { + #[Route( + '/', + name: 'mobile_homepage', + host: '{subdomain}.example.com', + defaults: ['subdomain' => 'm'], + requirements: ['subdomain' => 'm|mobile'], + )] + public function mobileHomepage() + { + // ... + } + + #[Route('/', name: 'homepage')] + public function homepage() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -1715,6 +2049,26 @@ avoids the need for duplicating routes, which also reduces the potential bugs: } } + .. code-block:: php-attributes + + // src/Controller/CompanyController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class CompanyController extends AbstractController + { + #[Route(path: [ + 'en' => '/about-us', + 'nl' => '/over-ons' + ], name: 'about_us')] + public function about() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -1754,6 +2108,11 @@ avoids the need for duplicating routes, which also reduces the potential bugs: ; }; +.. note:: + + When using PHP attributes for localized routes, you have to use the `path` + named parameter to specify the array of paths. + When a localized route is matched, Symfony uses the same locale automatically during the entire request. @@ -1849,6 +2208,23 @@ session shouldn't be used when matching a request: } } + .. code-block:: php-attributes + + // src/Controller/MainController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class MainController extends AbstractController + { + #[Route('/', name: 'homepage', stateless: true)] + public function homepage() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml @@ -2224,6 +2600,23 @@ each route explicitly: } } + .. code-block:: php-attributes + + // src/Controller/SecurityController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class SecurityController extends AbstractController + { + #[Route('/login', name: 'login', schemes: ['https'])] + public function login() + { + // ... + } + } + .. code-block:: yaml # config/routes.yaml From 8eccfeaa8192932bce9ecdbd607bad7c44d696e2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 12 Oct 2020 13:31:43 +0200 Subject: [PATCH 535/752] [RateLimiter] Minor fixes --- rate_limiter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 358a1d62c00..f7112373ff3 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -119,7 +119,7 @@ the number of requests to the API:: // the argument of consume() is the number of tokens to consume // and returns an object of type Limit - if (false === $anonymous_api_limiter->consume(1)->isAccepted()) { + if (false === $limiter->consume(1)->isAccepted()) { throw new TooManyRequestsHttpException(); } From 77625191c5c1f558a0ea7e3cfdb4ccb9381d758c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 13 Oct 2020 10:57:06 +0200 Subject: [PATCH 536/752] fix markup --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index 832b5df2c53..e8107a51eaf 100644 --- a/routing.rst +++ b/routing.rst @@ -2110,7 +2110,7 @@ avoids the need for duplicating routes, which also reduces the potential bugs: .. note:: - When using PHP attributes for localized routes, you have to use the `path` + When using PHP attributes for localized routes, you have to use the ``path`` named parameter to specify the array of paths. When a localized route is matched, Symfony uses the same locale automatically From 9dd75a90d0ea067eadae91b8844ec44dcfcbb1ee Mon Sep 17 00:00:00 2001 From: Hamza Amrouche Date: Tue, 10 Mar 2020 17:01:41 +0100 Subject: [PATCH 537/752] feat: add amazon sqs to docs --- messenger.rst | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/messenger.rst b/messenger.rst index 6107fcec87b..e22e2f02e21 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1151,6 +1151,35 @@ during a request:: :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase` or :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase`. +Amazon SQS +~~~~~~~~~~ + +.. versionadded:: 5.1 + + The Amazon SQS transport has been added in Symfony 5.1 + Install it by running: + + .. code-block:: terminal + + $ composer require symfony/amazon-sqs-messenger + +The ``SQS`` transport configuration looks like this: + +.. code-block:: bash + + # .env + MESSENGER_TRANSPORT_DSN=sqs://guest:guest@sqs.eu-west-3.amazonaws.com/test?region=eu-west-3 + + +.. note:: + + By default, the transport will automatically create queue that are needed. That can be disabled. + +The transport has a number of other options, including ways to configure +the exchange, queues binding keys and more. See the documentation on +:class:`Symfony\\Component\\Messenger\\Transport\\AmazonSqs\\Connection`. + + Serializing Messages ~~~~~~~~~~~~~~~~~~~~ From 47dbe33f5f0c5565d67686cf02c02845b8fcf4a5 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 22:36:05 +0200 Subject: [PATCH 538/752] Added SQS Messenger docs --- messenger.rst | 52 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/messenger.rst b/messenger.rst index e22e2f02e21..0c71adc23c5 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1168,17 +1168,54 @@ The ``SQS`` transport configuration looks like this: .. code-block:: bash # .env - MESSENGER_TRANSPORT_DSN=sqs://guest:guest@sqs.eu-west-3.amazonaws.com/test?region=eu-west-3 + MESSENGER_TRANSPORT_DSN=sqs://AKIAIOSFODNN7EXAMPLE:j17M97ffSVoKI0briFoo9a@sqs.eu-west-3.amazonaws.com/messages + #MESSENGER_TRANSPORT_DSN=sqs://localhost:9494/messages?sslmode=disable +.. note:: + + The transport will automatically create queues that are needed. This + can be disabled setting the "auto_setup" option to ``false``. + +A number of options can be configured via the DSN or via the ``options`` key +under the transport in ``messenger.yaml``: + +================== ===================================== ====================== + Option Description Default +================== ===================================== ====================== +endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com +region Name of the AWS region eu-west-1 +queue_name Name of the queue messages +account Identifier of the AWS account The owner of the credentials +access_key AWS access key +secret_key AWS secret key +buffer_size Number of messages to prefetch 9 +wait_time `Long polling`_ duration in seconds 20 +poll_timeout Wait for new message duration in 0.1 + seconds +visibility_timeout Amount of seconds the message will Queue's configuration + not be visible (`Visibility Timeout`_) +auto_setup Whether the table should be created true + automatically during send / get. +================== ===================================== ====================== .. note:: - By default, the transport will automatically create queue that are needed. That can be disabled. - -The transport has a number of other options, including ways to configure -the exchange, queues binding keys and more. See the documentation on -:class:`Symfony\\Component\\Messenger\\Transport\\AmazonSqs\\Connection`. + The ``wait_time`` parameter define the maximum duration Amazon SQS should + wait until a message is available in a queue before sending a response. + It helps reducing the cost of using Amazon SQS by eliminating the number + of empty responses. + + The ``poll_timeout`` parameter define the duration the receiver should wait + before returning null. It avoids blocking other receivers from being called. + +.. note:: + + If the queue name is suffixed by ``.fifo``, AWS will creates a `FIFO queue`_ + Use the stamp :class:`Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsFifoStamp` + to define the ``Message group ID`` and the ``Message deduplication ID``. + FIFO queues don't support setting a delay per message, a value of ``delay: 0`` + is required in the retry strategy settings. Serializing Messages ~~~~~~~~~~~~~~~~~~~~ @@ -1753,3 +1790,6 @@ Learn more .. _`streams`: https://redis.io/topics/streams-intro .. _`Supervisor docs`: http://supervisord.org/ .. _`SymfonyCasts' message serializer tutorial`: https://symfonycasts.com/screencast/messenger/transport-serializer +.. _`Long polling`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html +.. _`Visibility Timeout`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html +.. _`FIFO queue': https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html From 689df8cf1142d0c00ffc5e8fdd5acb82e7fe3d37 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 22:40:43 +0200 Subject: [PATCH 539/752] cs --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 0c71adc23c5..c0c7b72477f 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1211,7 +1211,7 @@ auto_setup Whether the table should be created true .. note:: If the queue name is suffixed by ``.fifo``, AWS will creates a `FIFO queue`_ - Use the stamp :class:`Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsFifoStamp` + Use the stamp :class:`Symfony\\Component\\Messenger\\Bridge\\AmazonSqs\\Transport\\AmazonSqsFifoStamp` to define the ``Message group ID`` and the ``Message deduplication ID``. FIFO queues don't support setting a delay per message, a value of ``delay: 0`` From d2fdd03de2aa6ae6ee1eb4ff6d223a6be16442a2 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 22:50:38 +0200 Subject: [PATCH 540/752] syntax --- messenger.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/messenger.rst b/messenger.rst index c0c7b72477f..b8ff1bcb795 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1176,27 +1176,27 @@ The ``SQS`` transport configuration looks like this: The transport will automatically create queues that are needed. This can be disabled setting the "auto_setup" option to ``false``. -A number of options can be configured via the DSN or via the ``options`` key +A numbeXr of options can be configured via the DSN or via the ``options`` key under the transport in ``messenger.yaml``: -================== ===================================== ====================== - Option Description Default -================== ===================================== ====================== -endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com -region Name of the AWS region eu-west-1 -queue_name Name of the queue messages -account Identifier of the AWS account The owner of the credentials +================== ====================================== ====================== + Option Description Default +================== ====================================== ====================== +endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com +region Name of the AWS region eu-west-1 +queue_name Name of the queue messages +account Identifier of the AWS account The owner of the credentials access_key AWS access key secret_key AWS secret key -buffer_size Number of messages to prefetch 9 -wait_time `Long polling`_ duration in seconds 20 -poll_timeout Wait for new message duration in 0.1 +buffer_size Number of messages to prefetch 9 +wait_time `Long polling`_ duration in seconds 20 +poll_timeout Wait for new message duration in 0.1 seconds -visibility_timeout Amount of seconds the message will Queue's configuration +visibility_timeout Amount of seconds the message will Queue's configuration not be visible (`Visibility Timeout`_) -auto_setup Whether the table should be created true +auto_setup Whether the table should be created true automatically during send / get. -================== ===================================== ====================== +================== ====================================== ====================== .. note:: @@ -1210,7 +1210,7 @@ auto_setup Whether the table should be created true .. note:: - If the queue name is suffixed by ``.fifo``, AWS will creates a `FIFO queue`_ + If the queue name is suffixed by ``.fifo``, AWS will creates a `FIFO queue`_. Use the stamp :class:`Symfony\\Component\\Messenger\\Bridge\\AmazonSqs\\Transport\\AmazonSqsFifoStamp` to define the ``Message group ID`` and the ``Message deduplication ID``. From f56ddd3270f7c32538679ab3d4cba79672874448 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 22:52:48 +0200 Subject: [PATCH 541/752] Syntax fix --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index b8ff1bcb795..d80edfd273d 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1792,4 +1792,4 @@ Learn more .. _`SymfonyCasts' message serializer tutorial`: https://symfonycasts.com/screencast/messenger/transport-serializer .. _`Long polling`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-short-and-long-polling.html .. _`Visibility Timeout`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html -.. _`FIFO queue': https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html +.. _`FIFO queue`: https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html From 5fa1465dfeba211eff941a13184196c3d0b74c6c Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 11 Oct 2020 23:15:28 +0200 Subject: [PATCH 542/752] Typo --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index d80edfd273d..416f52c10a2 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1176,7 +1176,7 @@ The ``SQS`` transport configuration looks like this: The transport will automatically create queues that are needed. This can be disabled setting the "auto_setup" option to ``false``. -A numbeXr of options can be configured via the DSN or via the ``options`` key +A number of options can be configured via the DSN or via the ``options`` key under the transport in ``messenger.yaml``: ================== ====================================== ====================== From d198bb747ef0750ffe3c111a6d76fa89db4b1dbe Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 12 Oct 2020 08:21:55 +0200 Subject: [PATCH 543/752] minor --- messenger.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/messenger.rst b/messenger.rst index 416f52c10a2..5949732cdab 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1360,7 +1360,6 @@ by tagging the handler service with ``messenger.message_handler`` 'handles' => SmsNotification::class, ]); - Possible options to configure with tags are: * ``bus`` @@ -1661,7 +1660,6 @@ middleware and *only* include your own: ], ]); - .. note:: If a middleware service is abstract, a different instance of the service will From 7d530ac7227041614eea94ea347cfc3b397f65f6 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 12 Oct 2020 13:51:13 +0200 Subject: [PATCH 544/752] Typos --- messenger.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/messenger.rst b/messenger.rst index 5949732cdab..bbd1015903f 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1200,17 +1200,17 @@ auto_setup Whether the table should be created true .. note:: - The ``wait_time`` parameter define the maximum duration Amazon SQS should + The ``wait_time`` parameter defines the maximum duration Amazon SQS should wait until a message is available in a queue before sending a response. It helps reducing the cost of using Amazon SQS by eliminating the number of empty responses. - The ``poll_timeout`` parameter define the duration the receiver should wait + The ``poll_timeout`` parameter defines the duration the receiver should wait before returning null. It avoids blocking other receivers from being called. .. note:: - If the queue name is suffixed by ``.fifo``, AWS will creates a `FIFO queue`_. + If the queue name is suffixed by ``.fifo``, AWS will create a `FIFO queue`_. Use the stamp :class:`Symfony\\Component\\Messenger\\Bridge\\AmazonSqs\\Transport\\AmazonSqsFifoStamp` to define the ``Message group ID`` and the ``Message deduplication ID``. From cf4331b1d395aac5b81b637b064acde39e728059 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 12 Oct 2020 17:42:42 +0200 Subject: [PATCH 545/752] Sort alphabetically --- messenger.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/messenger.rst b/messenger.rst index bbd1015903f..387c99bd47f 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1182,20 +1182,20 @@ under the transport in ``messenger.yaml``: ================== ====================================== ====================== Option Description Default ================== ====================================== ====================== -endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com -region Name of the AWS region eu-west-1 -queue_name Name of the queue messages -account Identifier of the AWS account The owner of the credentials access_key AWS access key -secret_key AWS secret key +account Identifier of the AWS account The owner of the credentials +auto_setup Whether the table should be created true + automatically during send / get. buffer_size Number of messages to prefetch 9 -wait_time `Long polling`_ duration in seconds 20 +endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com poll_timeout Wait for new message duration in 0.1 seconds +queue_name Name of the queue messages +region Name of the AWS region eu-west-1 +secret_key AWS secret key visibility_timeout Amount of seconds the message will Queue's configuration not be visible (`Visibility Timeout`_) -auto_setup Whether the table should be created true - automatically during send / get. +wait_time `Long polling`_ duration in seconds 20 ================== ====================================== ====================== .. note:: From 23fd9b401c6b6014551e7ce423d694809b456ecd Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 13 Oct 2020 18:37:18 +0200 Subject: [PATCH 546/752] [#14391] Minor (mostly formatting) improvements --- messenger.rst | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/messenger.rst b/messenger.rst index 387c99bd47f..a5ee804a567 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1156,16 +1156,17 @@ Amazon SQS .. versionadded:: 5.1 - The Amazon SQS transport has been added in Symfony 5.1 - Install it by running: + The Amazon SQS transport as introduced in Symfony 5.1. - .. code-block:: terminal +Install Amazon SQS transport by running: - $ composer require symfony/amazon-sqs-messenger +.. code-block:: terminal + + $ composer require symfony/amazon-sqs-messenger The ``SQS`` transport configuration looks like this: -.. code-block:: bash +.. code-block:: env # .env MESSENGER_TRANSPORT_DSN=sqs://AKIAIOSFODNN7EXAMPLE:j17M97ffSVoKI0briFoo9a@sqs.eu-west-3.amazonaws.com/messages @@ -1174,29 +1175,29 @@ The ``SQS`` transport configuration looks like this: .. note:: The transport will automatically create queues that are needed. This - can be disabled setting the "auto_setup" option to ``false``. + can be disabled setting the ``auto_setup`` option to ``false``. A number of options can be configured via the DSN or via the ``options`` key under the transport in ``messenger.yaml``: -================== ====================================== ====================== - Option Description Default -================== ====================================== ====================== -access_key AWS access key -account Identifier of the AWS account The owner of the credentials -auto_setup Whether the table should be created true - automatically during send / get. -buffer_size Number of messages to prefetch 9 -endpoint Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com -poll_timeout Wait for new message duration in 0.1 - seconds -queue_name Name of the queue messages -region Name of the AWS region eu-west-1 -secret_key AWS secret key -visibility_timeout Amount of seconds the message will Queue's configuration - not be visible (`Visibility Timeout`_) -wait_time `Long polling`_ duration in seconds 20 -================== ====================================== ====================== +====================== ====================================== =================================== + Option Description Default +====================== ====================================== =================================== +``access_key`` AWS access key +``account`` Identifier of the AWS account The owner of the credentials +``auto_setup`` Whether the table should be created ``true`` + automatically during send / get. +``buffer_size`` Number of messages to prefetch 9 +``endpoint`` Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com +``poll_timeout`` Wait for new message duration in 0.1 + seconds +``queue_name`` Name of the queue messages +``region`` Name of the AWS region eu-west-1 +``secret_key`` AWS secret key +``visibility_timeout`` Amount of seconds the message will Queue's configuration + not be visible (`Visibility Timeout`_) +``wait_time`` `Long polling`_ duration in seconds 20 +====================== ====================================== =================================== .. note:: From 3c0372a0133b29b0fabb537bba15cc22a2cee1a3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Tue, 13 Oct 2020 21:14:17 +0200 Subject: [PATCH 547/752] Use updated dependencies --- _build/.requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_build/.requirements.txt b/_build/.requirements.txt index 47f076e9403..26a019bfa6b 100644 --- a/_build/.requirements.txt +++ b/_build/.requirements.txt @@ -1,6 +1,6 @@ docutils==0.13.1 Pygments==2.2.0 sphinx==1.8.5 -git+https://github.com/fabpot/sphinx-php.git@v2.0.0#egg_name=sphinx-php +git+https://github.com/fabpot/sphinx-php.git@v2.0.2#egg_name=sphinx-php jsx-lexer===0.0.8 sphinx_rtd_theme==0.5.0 From d243017fc697e6a4a3f5cca557f6cac3051ba175 Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Tue, 13 Oct 2020 21:35:31 +0200 Subject: [PATCH 548/752] Fix link to acquireRead Should target SharedLockInterface instead of LockInterface --- components/lock.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lock.rst b/components/lock.rst index d34908c2777..518a01c9375 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -221,7 +221,7 @@ but an exclusive lock is needed for writing or modifying data. They are used for example for data structures that cannot be updated atomically and are invalid until the update is complete. -Use the :method:`Symfony\\Component\\Lock\\LockInterface::acquireRead` method +Use the :method:`Symfony\\Component\\Lock\\SharedLockInterface::acquireRead` method to acquire a read-only lock, and the existing :method:`Symfony\\Component\\Lock\\LockInterface::acquire` method to acquire a write lock:: From 41b79833f70e2fe75bbc63a0249d23142f7452b7 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Tue, 13 Oct 2020 10:55:37 +0200 Subject: [PATCH 549/752] [Routing] Better use of composer require --- routing.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/routing.rst b/routing.rst index 832b5df2c53..a051e446612 100644 --- a/routing.rst +++ b/routing.rst @@ -33,7 +33,7 @@ once in your application to enable them: .. code-block:: terminal - $ composer require annotations + $ composer require doctrine/annotations .. versionadded:: 5.2 @@ -1063,12 +1063,11 @@ integer acting as the user ID) into another value (e.g. the object that represents the user). This feature is called "param converter" and is only available when using annotations to define routes. -In case you didn't run this command before, run it now to add support for -annotations and "param converters": +To add support for "param converters" we need SensioFrameworkExtraBundle: .. code-block:: terminal - $ composer require annotations + $ composer require sensio/framework-extra-bundle Now, keep the previous route configuration, but change the arguments of the controller action. Instead of ``string $slug``, add ``BlogPost $post``:: From 701f704a73403ef5207c5df1bcfd6b9cec8550b3 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Mon, 12 Oct 2020 22:07:45 +0200 Subject: [PATCH 550/752] [DependencyInjection] Document the Required attribute. --- service_container/autowiring.rst | 111 +++++++++++++++++++++++-------- service_container/calls.rst | 2 +- 2 files changed, 85 insertions(+), 28 deletions(-) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 9c855152a9a..56a117f7b16 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -544,50 +544,107 @@ Autowiring other Methods (e.g. Setters and Public Typed Properties) When autowiring is enabled for a service, you can *also* configure the container to call methods on your class when it's instantiated. For example, suppose you want -to inject the ``logger`` service, and decide to use setter-injection:: +to inject the ``logger`` service, and decide to use setter-injection: - // src/Util/Rot13Transformer.php - namespace App\Util; +.. configuration-block:: - class Rot13Transformer - { - private $logger; + .. code-block:: php-annotations - /** - * @required - */ - public function setLogger(LoggerInterface $logger) + // src/Util/Rot13Transformer.php + namespace App\Util; + + class Rot13Transformer { - $this->logger = $logger; + private $logger; + + /** + * @required + */ + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + public function transform($value) + { + $this->logger->info('Transforming '.$value); + // ... + } } - public function transform($value) + .. code-block:: php-attributes + + // src/Util/Rot13Transformer.php + namespace App\Util; + + use Symfony\Contracts\Service\Attribute\Required; + + class Rot13Transformer { - $this->logger->info('Transforming '.$value); - // ... + private $logger; + + #[Required] + public function setLogger(LoggerInterface $logger) + { + $this->logger = $logger; + } + + public function transform($value) + { + $this->logger->info('Transforming '.$value); + // ... + } } - } -Autowiring will automatically call *any* method with the ``@required`` annotation +Autowiring will automatically call *any* method with the ``#[Required]`` attribute above it, autowiring each argument. If you need to manually wire some of the arguments to a method, you can always explicitly :doc:`configure the method call `. -Despite property injection has some :ref:`drawbacks `, autowiring with ``@required`` annotation -can also be applied to public typed properties:: +If you need to stay compatible with PHP 7 and thus cannot use attributes, you can use +the ``@required`` annotation instead. - namespace App\Util; +.. versionadded:: 5.2 - class Rot13Transformer - { - /** @required */ - public LoggerInterface $logger; + The ``#[Required]`` attribute was introduced in Symfony 5.2. - public function transform($value) +Despite property injection has some :ref:`drawbacks `, autowiring with ``#[Required]`` +or ``@required`` can also be applied to public typed properties:: + +.. configuration-block:: + + .. code-block:: php-annotations + + namespace App\Util; + + class Rot13Transformer { - $this->logger->info('Transforming '.$value); - // ... + /** @required */ + public LoggerInterface $logger; + + public function transform($value) + { + $this->logger->info('Transforming '.$value); + // ... + } + } + + .. code-block:: php-attributes + + namespace App\Util; + + use Symfony\Contracts\Service\Attribute\Required; + + class Rot13Transformer + { + #[Required] + public LoggerInterface $logger; + + public function transform($value) + { + $this->logger->info('Transforming '.$value); + // ... + } } - } .. versionadded:: 5.1 diff --git a/service_container/calls.rst b/service_container/calls.rst index 11dea241613..df33cecc989 100644 --- a/service_container/calls.rst +++ b/service_container/calls.rst @@ -6,7 +6,7 @@ Service Method Calls and Setter Injection .. tip:: - If you're using autowiring, you can use ``@required`` to + If you're using autowiring, you can use ``#[Required]`` or ``@required`` to :ref:`automatically configure method calls `. Usually, you'll want to inject your dependencies via the constructor. But sometimes, From 0605be9875bda451c5d6cba839f695f1586f9094 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Wed, 14 Oct 2020 19:31:24 -0400 Subject: [PATCH 551/752] Add info() method sample --- components/options_resolver.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 075b42937a9..74569b9123e 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -811,7 +811,9 @@ method:: $resolver->define('host') ->required() ->default('smtp.example.org') - ->allowedTypes('string'); + ->allowedTypes('string') + ->info('The IP address or hostname'); + $resolver->define('transport') ->required() ->default('transport') From 2380052f6c33b21f41e0f0fcecc9f998b1cf7efe Mon Sep 17 00:00:00 2001 From: Nyholm Date: Thu, 15 Oct 2020 09:30:05 +0200 Subject: [PATCH 552/752] Adding docs for rate limit sliding window --- rate_limiter.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index f7112373ff3..2abc25a1a5c 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -19,8 +19,8 @@ time, but you can use them for your own features too. Rate Limiting Strategies ------------------------ -Symfony's rate limiter implements two of the most common strategies to enforce -rate limits: **fixed window** and **token bucket**. +Symfony's rate limiter implements some of the most common strategies to enforce +rate limits: **fixed window**, **sliding window** and **token bucket**. Fixed Window Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -35,6 +35,22 @@ could make the 4,999 requests in the last minute of some hour and another 5,000 requests during the first minute of the next hour, making 9,999 requests in total in two minutes and possibly overloading the server. +Sliding Window Rate Limiter +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The sliding window algorithm is gracefully handling the drawback from the fixed +window algorithm. To reduce bursts requests the rate limit is calculated based on +the current window and the previous window. + +For example: The limit is 5,000 requests per hour. If a user made 4,000 requests +the previous hour and 500 requests this hour. 15 minutes in to the current hour +(25% of the window) the hit count would be calculated as: 75% * 4,000 + 500 = 3,500. +At this point in time the user can only do 1,500 more requests. + +The math shows that the closer the last window is, the more will the hit count +of the last window effect the current limit. This will make sure that a user can +do 5.000 requests per hour but only if they are spread out evenly. + Token Bucket Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~ From 91a834dc86a31c2ec12a2b52c56da22a22bff029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sapone?= Date: Fri, 16 Oct 2020 11:12:01 +0200 Subject: [PATCH 553/752] [UID] Fix wrong use statement for generators --- components/uid.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index f1c569df97d..287789ac368 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -146,7 +146,7 @@ There's also a Doctrine generator to help autogenerate UUID values for the entity primary keys:: // there are generators for UUID V1 and V6 too - use Symfony\Bridge\Doctrine\Types\UuidV4Generator; + use Symfony\Bridge\Doctrine\IdGenerator\UuidV4Generator; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -261,7 +261,7 @@ special Doctrine types which convert to/from ULID objects automatically:: There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: - use Symfony\Bridge\Doctrine\Types\UlidGenerator; + use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") From 81d6877f020ab1e9f291dd7108082344366f0bcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Fri, 16 Oct 2020 09:28:32 +0200 Subject: [PATCH 554/752] Replace LockInterface by LockFactory in DI --- lock.rst | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/lock.rst b/lock.rst index c3d5cb365e5..bacebc544b2 100644 --- a/lock.rst +++ b/lock.rst @@ -159,22 +159,23 @@ this behavior by using the ``lock`` key like: Locking a Resource ------------------ -To lock the default resource, autowire the lock using -:class:`Symfony\\Component\\Lock\\LockInterface` (service id ``lock``):: +To lock the default resource, autowire the lock factory using +:class:`Symfony\\Component\\Lock\\LockFactory` (service id ``lock.factory``):: // src/Controller/PdfController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; - use Symfony\Component\Lock\LockInterface; + use Symfony\Component\Lock\LockFactory; class PdfController extends AbstractController { /** * @Route("/download/terms-of-use.pdf") */ - public function downloadPdf(LockInterface $lock, MyPdfGeneratorService $pdf) + public function downloadPdf(LockFactory $factory, MyPdfGeneratorService $pdf) { + $lock = $factory->createLock('pdf-creation'); $lock->acquire(true); // heavy computation @@ -273,18 +274,12 @@ provides :ref:`named lock `:: ], ]); -Each name becomes a service where the service id suffixed by the name of the -lock (e.g. ``lock.invoice``). An autowiring alias is also created for each lock -using the camel case version of its name suffixed by ``Lock`` - e.g. ``invoice`` -can be injected automatically by naming the argument ``$invoiceLock`` and -type-hinting it with :class:`Symfony\\Component\\Lock\\LockInterface`. - -Symfony also provide a corresponding factory and store following the same rules -(e.g. ``invoice`` generates a ``lock.invoice.factory`` and -``lock.invoice.store``, both can be injected automatically by naming -respectively ``$invoiceLockFactory`` and ``$invoiceLockStore`` and type-hinted -with :class:`Symfony\\Component\\Lock\\LockFactory` and -:class:`Symfony\\Component\\Lock\\PersistingStoreInterface`) +Each name becomes a service where the service id is part of the name of the +lock (e.g. ``lock.invoice.factory``). An autowiring alias is also created for +each lock using the camel case version of its name suffixed by ``LockFactory`` +- e.g. ``invoice`` can be injected automatically by naming the argument +``$invoiceLockFactory`` and type-hinting it with +:class:`Symfony\\Component\\Lock\\LockFactory`. Blocking Store -------------- From b513c1593b6e43c52b218d906ea2e06127d2d14d Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 17 Oct 2020 09:10:59 +0200 Subject: [PATCH 555/752] Fixed use statement --- reference/constraints/Compound.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/constraints/Compound.rst b/reference/constraints/Compound.rst index 8552058708c..6e0ab5db139 100644 --- a/reference/constraints/Compound.rst +++ b/reference/constraints/Compound.rst @@ -26,7 +26,7 @@ you can create your own named set or requirements to be reused consistently ever // src/Validator/Constraints/PasswordRequirements.php namespace App\Validator\Constraints; - use Symfony\Component\Validator\Compound; + use Symfony\Component\Validator\Constraints\Compound; use Symfony\Component\Validator\Constraints as Assert; /** From 48c5e90049fedbabaa7bab6622a02c76723fe684 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 16 Oct 2020 19:19:34 +0200 Subject: [PATCH 556/752] Fixed broken use statements --- migration.rst | 2 +- reference/constraints/Traverse.rst | 4 ++-- routing.rst | 2 +- translation.rst | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/migration.rst b/migration.rst index 6b71a07670b..fa8c2bfc24b 100644 --- a/migration.rst +++ b/migration.rst @@ -238,7 +238,7 @@ could look something like this:: // public/index.php use App\Kernel; use App\LegacyBridge; - use Symfony\Component\Debug\Debug; + use Symfony\Component\ErrorHandler\Debug; use Symfony\Component\HttpFoundation\Request; require dirname(__DIR__).'/vendor/autoload.php'; diff --git a/reference/constraints/Traverse.rst b/reference/constraints/Traverse.rst index 852f17cdd01..fd329bd38a3 100644 --- a/reference/constraints/Traverse.rst +++ b/reference/constraints/Traverse.rst @@ -26,8 +26,8 @@ that all have constraints on their properties. // src/Entity/BookCollection.php namespace App\Entity; - use Doctrine\Collections\ArrayCollection; - use Doctrine\Collections\Collection + use Doctrine\Common\Collections\ArrayCollection; + use Doctrine\Common\Collections\Collection use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; diff --git a/routing.rst b/routing.rst index c1c8a65e702..b4054a3137c 100644 --- a/routing.rst +++ b/routing.rst @@ -2247,7 +2247,7 @@ session shouldn't be used when matching a request: // config/routes.php use App\Controller\MainController; - use Symfony\Bundle\FrameworkBundle\Routing\Loader\Configurator\RoutingConfigurator; + use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; return function (RoutingConfigurator $routes) { $routes->add('homepage', '/') diff --git a/translation.rst b/translation.rst index fbf08ba14a1..1d6bdf5b7e2 100644 --- a/translation.rst +++ b/translation.rst @@ -307,10 +307,10 @@ parts of your application and mocking it in your tests. Instead of translating a string at the time of creation, you can use a "translatable object", which is an instance of the -:class:`Symfony\\Component\\Translation\\TranslatableMessage` class. This object stores +:class:`Symfony\\Component\\Translation\\Translatable` class. This object stores all the information needed to fully translate its contents when needed:: - use Symfony\Component\Translation\TranslatableMessage; + use Symfony\Component\Translation\Translatable; // the first argument is required and it's the original message $message = new TranslatableMessage('Symfony is great!'); From 0434fbbb582a11c7012522b2840000f18d7013b1 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 13:07:01 +0200 Subject: [PATCH 557/752] Tweaks --- rate_limiter.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 2abc25a1a5c..f0a16e9493e 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -33,23 +33,24 @@ Its main drawback is that resource usage is not evenly distributed in time and it can overload the server at the window edges. In the previous example, a user could make the 4,999 requests in the last minute of some hour and another 5,000 requests during the first minute of the next hour, making 9,999 requests in -total in two minutes and possibly overloading the server. +total in two minutes and possibly overloading the server. These periods of +excessive usage are called "bursts". Sliding Window Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The sliding window algorithm is gracefully handling the drawback from the fixed -window algorithm. To reduce bursts requests the rate limit is calculated based on +The sliding window algorithm is an alternative to the fixed window algorithm +designed to reduce bursts. To do that, the rate limit is calculated based on the current window and the previous window. -For example: The limit is 5,000 requests per hour. If a user made 4,000 requests +For example: the limit is 5,000 requests per hour; a user made 4,000 requests the previous hour and 500 requests this hour. 15 minutes in to the current hour (25% of the window) the hit count would be calculated as: 75% * 4,000 + 500 = 3,500. At this point in time the user can only do 1,500 more requests. The math shows that the closer the last window is, the more will the hit count of the last window effect the current limit. This will make sure that a user can -do 5.000 requests per hour but only if they are spread out evenly. +do 5,000 requests per hour but only if they are spread out evenly. Token Bucket Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -85,11 +86,12 @@ enforce different levels of service (free or paid): framework: rate_limiter: anonymous_api: - strategy: fixed_window + # use 'sliding_window' if you prefer that strategy + strategy: 'fixed_window' limit: 100 interval: '60 minutes' authenticated_api: - strategy: token_bucket + strategy: 'token_bucket' limit: 5000 rate: { interval: '15 minutes', amount: 500 } From 72ff90333cec11a25275b09c591e95560b3c00a7 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 17 Oct 2020 15:15:20 +0200 Subject: [PATCH 558/752] Document reserve() method and rename to RateLimiter --- rate_limiter.rst | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index f0a16e9493e..3849a502858 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -124,12 +124,13 @@ the number of requests to the API:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; - use Symfony\Component\RateLimiter\Limiter; + use Symfony\Component\RateLimiter\RateLimiter; class ApiController extends AbstractController { // the variable name must be: "rate limiter name" + "limiter" suffix - public function index(Limiter $anonymousApiLimiter) + // if you're using autowiring for your services + public function index(RateLimiter $anonymousApiLimiter) { // create a limiter based on a unique identifier of the client // (e.g. the client's IP address, a username/email, an API key, etc.) @@ -158,28 +159,33 @@ the number of requests to the API:: for the :ref:`kernel.request event ` and check the rate limiter once for all requests. -In other scenarios you may want instead to wait as long as needed until a new -token is available. In those cases, use the ``wait()`` method:: +Wait until a Token is Available +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Instead of dropping a request or process when the limit has been reached, +you might want to wait until a new token is available. This can be achieved +using the ``reserve()`` method:: // src/Controller/ApiController.php namespace App\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\RateLimiter\Limiter; + use Symfony\Component\RateLimiter\RateLimiter; class ApiController extends AbstractController { - public function registerUser(Request $request, Limiter $authenticatedApiLimiter) + public function registerUser(Request $request, RateLimiter $authenticatedApiLimiter) { $apiKey = $request->headers->get('apikey'); $limiter = $authenticatedApiLimiter->create($apiKey); // this blocks the application until the given number of tokens can be consumed - do { - $limit = $limiter->consume(1); - $limit->wait(); - } while (!$limit->isAccepted()); + $limiter->reserve(1)->wait(); + + // optional, pass a maximum wait time (in seconds), a MaxWaitDurationExceededException + // is thrown if the process has to wait longer. E.g. to wait at most 20 seconds: + //$limiter->reserve(1, 20)->wait(); // ... } @@ -187,6 +193,25 @@ token is available. In those cases, use the ``wait()`` method:: // ... } +The ``reserve()`` method is able to reserve a token in the future. Only use +this method if you're planning to wait, otherwise you will block other +processes by reserving unused tokens. + +.. note:: + + Not all strategies allow reservering tokens in the future. These + strategies may throw an ``ReserveNotSupportedException`` when calling + ``reserve()``. + + In these cases, you can use ``consume()`` together with ``wait()``, but + there is no guarantee that a token is available after the wait:: + + // ... + do { + $limit = $limiter->consume(1); + $limit->wait(); + } while (!$limit->isAccepted()); + Rate Limiter Storage and Locking -------------------------------- From 8ed09166a92302078a684c4c6d9e2d0dd06e3ef7 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 11 Oct 2020 13:47:27 +0200 Subject: [PATCH 559/752] Added login link documentation --- _images/security/login_link_email.png | Bin 0 -> 4301 bytes security/experimental_authenticators.rst | 2 + security/login_link.rst | 652 +++++++++++++++++++++++ 3 files changed, 654 insertions(+) create mode 100644 _images/security/login_link_email.png create mode 100644 security/login_link.rst diff --git a/_images/security/login_link_email.png b/_images/security/login_link_email.png new file mode 100644 index 0000000000000000000000000000000000000000..8331b878f68376279fc5f672eb3e3826761b5202 GIT binary patch literal 4301 zcmdUzeOQwB8pof^ms+Ki>zFQ_tJB(MwG}Z_6kJnjZs|&c`2wyyib-l_fQm@0H?|z@ z<+#f-@3v$F6Jp_qp!pzVF}n zzMuPdf1Xc2OhB)AA?O7F09L%WD`qbMct`+X(T*kF;FEOY<1zq%{PVq-can?G8#V8L z^>ZBA>&IZ-mX0O#X>Z;nO`W7g?>2>=o{{AteCg7(q!`FuK^Mq?k@tt@^}-?31so_*4I?S`J7 z{ehr}k53Am=|4}H7`b*@K4(m?gUJHAH~KTZv}rps^RjPAxkT){s@05QC2DyxKRgtI z?NPR$_So93TltF(F|UC!J1H879^N`8e^k^PeWS=PltKOnN0vGSQ!Y8?_J=aD^riaX z#AdSl5+8+LnCk9b8Jx9DtW3JmOAAv7>Wt8t#kwkU^p&uw&t7NDYDg$z zmmnL<4`42mZUDVg?Q?;7BpZ!PmDAJ%SfMw@8L=L6R{!8@o&bgzHO)y!sc|8AT-~{% zMPE!#gY81y^hNT{yM1@FTRNd{%6X8^Z4;($rAjGt#vT8$-bbr%L-!)n3J9KB{SAuZ zc=Yna8DBDrx0fxI$b2Pq(A!gSDJ`N$TuR2+xutIX4TP?+r%hz?*|i?>W;)hoojAxS zwkf&&Ydp19>yx$4dM~Ziv7=}$SiyEr?MZ{DR^}(EbfUr`G8QTdLTPdZQmr!!D(a$D zv7TD9+3o%$u;iw(_yTG(#H{A9=ExS8zT=$BF&sTVBbEz_CdxZI7CsZAi2Q{cbQ}Iy zj7Q;gHD&B`*8bMbjJ5()wy7(vY8BI<9Lw{gG_C~Tg^XfLR;Obx-}47)v|8R9PhCG| z4j%g;FWHb|Rp%mbnH(HPAeEY2diA?tEy53YOxx`b&K$O6g+II4=&i*n`Q_!q_9+T% z=H(Pwf2z!qWOQnZNAJ^xijJMudy%4E^;TBDi%T7Dw-HSHdR@T5b&Ct_B!05GsYP(a z#WKG!z6N(!K4-dervITRH)s0^Q?-sIfJNxerBNUal%Z4KpQyK{tUox~v`YI%ipy>njE zW?qQwaL$(duVjXv77CssFNDNR&@o+zk0XwxQw-iLO6l~ zkLmKWev-N_Z}V#{iLWhT%vQt2nKg-P&V*+)eTJRY|WhW|5xSqKQIlaqZ*)_=)jvb5Bw%{F8W1*vunjbuWk0C9>g0 zP$PkPf zrG)B9+59+SUMm@+ZfLyOXU7@f2)BHCDl$}#k|`edrOJk-eVw7sj(1~1@SXf;ACB$o zuJoDRwFipJI4Dqq0nxq>MYd7n0FPALP9g8cCy7BWkzO?hI>2@ClZ4FC0QyCOA zS9Zxaj*}#STX+c(cEc8Hga})g$u-I2(<(_-;Yxu44g(`s@Ra(LCwh0z{Ww|HB{HiA zp*H1i#w?Zi`{Z2ymYaFi7Jej8$k8*JEVw|*C62yI`jHM=ggaP3+N2?lkh~-8-|uzH z%Q3k*_MoPUdgr-;!hC6iQq_)?QPIZ67GbkkzJOH}T-Nj#ON&|e8_|R&3g?Gh4N0DP zGWy2hV{s!_S>uzA%7A-08S>MX55`0j53J21XL=}HWqtPK$^{l&)WE_JFFG6XDMM`d z@bty`6Q#It0b9nA(>N((=V-W+S4k~Sa4ZzwtGJLEmCcET!3Tv>jrF5fAYu7aB5i8P z$CTBoK9azX*`H3if6cI=W9H=Wwab;&53S!DQ%6)pDX$LaH>+v~LxjS&JMK+J+$AW8 zSx9UY9b>0u(+D<_Mb#!sIP2ixzCI_2oT)%Y5MfsFUI9#YoK@P$Tq2Rj8efxelugL* z31<#n=Bs=Z{Xt-?akYtLnj}0HQ;OWG1azkqnT*g=u+Sz&j6J2Z`7(hxDTkHlQjm3c zdd--~D%Q^lI?ONwLcllksQccRlL1Q zA5`iW6G<5uP`6c@xt;1g>tTM^D1MWbo#$y+$irq{L~7HgtbkhuR8s72nc~OQgt>}R zc8Zx>i-J1wI8Z=iX~I3z?f!+%pk9vKsTW8W2tBj)@l>3l>{3!sHEO?13L?ZmXgu=jS!GpNp%qku`y` zT`xg}&2>D?h^849`~-agv_%Y}VS7b?|Nni^@;+PTJ5e=dP! zaX@tq+iL5a1Zj3wSGF`0R9rDO8QeH5J(LEMeG*T@I5RXgP(xu)N{WUPPuqv&Dx8x= z`)%RFudIW-yx9>yz(WFv9?`RJ%ixz);%vv-PWN?UTu+j#tTzIyi#Vb=v|Fku6`soO zg&{bmsPvL&0v^Hccx&qn z+3H%?{B_I|G16o4$O$%)s&}mTT&XsWSd@@B+j7GyRbK7R^8} zxQ6h$FpGf0;BbC46F&l_m6e9@cyWEO;a zVl`t{&c7b2B%eMA9P{; ziDo5p(R0oL69%Cs4$Kuqoh6cAxCSH}kapICOaL;_|MybClA~zl=qtzY&{JLqfJX_Q z+THt2`TH%tnGi4@Vihys_`^O5q2hfoVAXm^n9p5U&r{D|6V%=bxgKq?9_I$AsvP=SWyOv6py_3J8I9Qm}UVc=HQ2+Xlm-fkTVeW*4J=64A*?FK2 z!1(jj^Z))aMt!w)GblyHN@kd6$Cqz88rZm>NdL)WMO0Ss^OV3WYfjwy?yXIrDP` +in your configuration to use this feature. + +Using the Login Link Authenticator +---------------------------------- + +This guide assumes you have setup security and have created a user object +in your application. Follow :doc:`the main security guide ` if +this is not yet the case. + +1) Configure the Login Link Authenticator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The login link authenticator is configured using the ``login_link`` option +under the firewall. You must configure a ``check_route`` and +``signature_properties`` when enabling this authenticator: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + login_link: + check_route: login_check + signature_properties: ['id'] + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + 'firewalls' => [ + 'main' => [ + 'login_link' => [ + 'check_route' => 'login_check', + ], + ], + ], + ]); + +The ``signature_properties`` are used to create a signed URL. This must +contain at least one property of your ``User`` object that uniquely +identifies this user (e.g. the user ID). Read more about this setting +:ref:`further down below `. + +The ``check_route`` must be an existing route and it will be used to +generate the login link that will authenticate the user. You don't need a +controller (or it can be empty) because the login link authenticator will +intercept requests to this route: + +.. configuration-block:: + + .. code-block:: php-annotations + + // src/Controller/SecurityController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\Routing\Annotation\Route; + + class SecurityController extends AbstractController + { + /** + * @Route("/login_check", name="login_check") + */ + public function check() + { + throw new \LogicException('This code should never be reached'); + } + } + + .. code-block:: yaml + + # config/routes.yaml + + # ... + login_check: + path: /login_check + + .. code-block:: xml + + + + + + + + + + .. code-block:: php + + // config/routes.php + use App\Controller\DefaultController; + use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator; + + return function (RoutingConfigurator $routes) { + // ... + $routes->add('login_check', '/login_check'); + }; + +2) Generate the Login Link +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Now that the authenticator is able to check the login links, you must +create a page where a user can request a login link and log in to your +website. + +The login link can be generated using the +:class:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkHandlerInterface`. +The correct login link handler is autowired for you when type-hinting for +this interface:: + + // src/Controller/SecurityController.php + namespace App\Controller; + + use App\Repository\UserRepository; + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Request; + use Symfony\Component\Routing\Annotation\Route; + use Symfony\Component\Security\Http\LoginLink\LoginLinkHandlerInterface; + + class SecurityController extends AbstractController + { + /** + * @Route("/login", name="login") + */ + public function requestLoginLink(LoginLinkHandlerInterface $loginLinkHandler, UserRepository $userRepository, Request $request) + { + // check if login form is submitted + if ($request->isMethod('POST')) { + // load the user in some way (e.g. using the form input) + $email = $request->request->get('email'); + $user = $userRepository->findOneBy(['email' => $email]); + + // create a login link for $user this returns an instance + // of LoginLinkDetails + $loginLinkDetails = $loginLinkHandler->createLoginLink($user); + $loginLink = $loginLinkDetails->getUrl(); + + // ... send the link and return a response (see next section) + } + + // if it's not submitted, render the "login" form + return $this->render('security/login.html.twig'); + } + + // ... + } + +.. code-block:: html+twig + + {# templates/security/login.html.twig #} + {% extends 'base.html.twig' %} + + {% block body %} +
+ + +
+ {% endblock %} + +In this controller, the user is submitting their e-mail address to the +controller. Based on this property, the correct user is loaded and a login +link is created using +:method:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkHandlerInterface::createLoginLink`. + +.. caution:: + + It is important to send this link to the user and **not show it directly**, + as that would allow anyone to login. For instance, use the + :doc:`mailer ` component to mail the login link to the user. + Or use the component to send an SMS to the + user's device. + +3) Send the Login Link to the User +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Now the link is created, it needs to be send to the user. Anyone with the +link is able to login as this user, so you need to make sure to send it to +a known device of them (e.g. using e-mail or SMS). + +You can send the link using any library or method. However the login link +authenticator provides integration with the :doc:`Notifier component `. +Use the special :class:`Symfony\\Component\\Security\\Http\\LoginLink\\LoginLinkNotification` +to create a notification and send it to the user's email address or phone +number:: + + // src/Controller/SecurityController.php + + // ... + use Symfony\Component\Notifier\NotifierInterface; + use Symfony\Component\Notifier\Recipient\Recipient; + use Symfony\Component\Security\Http\LoginLink\LoginLinkNotification; + + class SecurityController extends AbstractController + { + /** + * @Route("/login", name="login") + */ + public function requestLoginLink(NotifierInterface $notifier, LoginLinkHandlerInterface $loginLinkHandler, UserRepository $userRepository, Request $request) + { + if ($request->isMethod('POST')) { + $email = $request->request->get('email'); + $user = $userRepository->findOneBy(['email' => $email]); + + $loginLinkDetails = $loginLinkHandler->createLoginLink($user); + + // create a notification based on the login link details + $notification = new LoginLinkNotification( + $loginLinkDetails, + 'Welcome to MY WEBSITE!' // email subject + ); + // create a recipient for this user + $recipient = (new Recipient())->email($user->getEmail()); + + // send the notification to the user + $notifier->send($notification, $recipient); + + // render a "Login link is sent!" page + return $this->render('security/login_link_sent.html.twig'); + } + + return $this->render('security/login.html.twig'); + } + + // ... + } + +.. note:: + + This integration requires the :doc:`Notifier ` and + :doc:`Mailer ` components to be installed and configured. + Install all required packages using: + + .. code-block:: terminal + + $ composer require symfony/mailer symfony/notifier \ + symfony/twig-bundle twig/extra-bundle \ + twig/cssinliner-extra twig/inky-extra + +This will send an email like this to the user: + +.. image:: /_images/security/login_link_email.png + :align: center + +.. tip:: + + You can customize this e-mail template by extending the + ``LoginLinkNotification`` and configuring another ``htmlTemplate``:: + + // src/Notifier/CustomLoginLinkNotification + namespace App\Notifier; + + use Symfony\Component\Security\Http\LoginLink\LoginLinkNotification; + + class CustomLoginLinkNotification extends LoginLinkNotification + { + public function asEmailMessage(EmailRecipientInterface $recipient, string $transport = null): ?EmailMessage + { + $emailMessage = parent::asEmailMessage($recipient, $transport); + + // get the NotificationEmail object and override the template + $email = $emailMessage->getMessage(); + $email->htmlTemplate('emails/custom_login_link_email.html.twig'); + + return $emailMessage; + } + } + + Then, use this new ``CustomLoginLinkNotification`` in the controller + instead. + +Important Considerations +------------------------ + +Login links are a convenient way of authenticating users, but it is also +considered less secure than a traditional username and password form. It is +not recommended to use login links in security critical applications. + +However, the implementation in Symfony does have a couple extension points +to make the login links more secure. In this section, the most important +configuration decisions are discussed: + +* `Limit Login Link Lifetime`_ +* `Invalidate Login Links`_ +* `Only allow a Link to be used Once`_ + +Limit Login Link Lifetime +~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is important for login links to have a limited lifetime. This reduces +the risk that someone can intercept the link and use it to login as +somebody else. By default, Symfony defines a lifetime of 10 minutes (600 +seconds). You can customize this using the ``lifetime`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + login_link: + check_route: login_check + # lifetime in seconds + lifetime: 300 + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + 'firewalls' => [ + 'main' => [ + 'login_link' => [ + 'check_route' => 'login_check', + // lifetime in seconds + 'lifetime' => 300, + ], + ], + ], + ]); + +.. _security-login-link-signature: + +Invalidate Login Links +~~~~~~~~~~~~~~~~~~~~~~ + +Symfony uses signed URLs to implement login links. The advantage of this is +that valid links do not have to be stored in a database. The signed URLs +allow Symfony to still invalidate already sent login links when important +information changes (e.g. a user's email address). + +The signed URL contains 3 parameters: + +``expires`` + The UNIX timestamp when the link expires. + +``user`` + The value returned from ``$user->getUsername()`` for this user. + +``hash`` + A hash of ``expires``, ``user`` and any configured signature + properties. Whenever these change, the hash changes and previous login + links are invalidated. + +You can add more properties to the ``hash`` by using the +``signature_properties`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + login_link: + check_route: login_check + signature_properties: [id, email] + + .. code-block:: xml + + + + + + + + + id + email + + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + 'firewalls' => [ + 'main' => [ + 'login_link' => [ + 'check_route' => 'login_check', + 'signature_properties' => ['id', 'email'], + ], + ], + ], + ]); + +The properties are fetched from the user object using the +:doc:`PropertyAccess component ` (e.g. using +``getEmail()`` or a public ``$email`` property in this example). + +.. tip:: + + You can also use the signature properties to add very advanced + invalidating logic to your login links. For instance, if you store a + ``$lastLinkRequestedAt`` property on your users that you update in the + ``requestLoginLink()`` controller, you can invalidate all login links + whenever a user requests a new link. + +Configure a Maximum Use of a Link +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +It is a common characteristic of login links to limit the number of times +it can be used. Symfony can support this by storing used login links in the +cache. Enable this support by setting the ``max_uses`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + login_link: + check_route: login_check + # only allow the link to be used 3 times + max_uses: 3 + + # optionally, configure the cache pool + #used_link_cache: 'cache.redis' + + .. code-block:: xml + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + 'firewalls' => [ + 'main' => [ + 'login_link' => [ + 'check_route' => 'login_check', + // only allow the link to be used 3 times + 'max_uses' => 3, + + // optionally, configure the cache pool + //'used_link_cache' => 'cache.redis', + ], + ], + ], + ]); + +Make sure there is enough space left in the cache, otherwise invalid links +can no longer be stored (and thus become valid again). Expired invalid +links are automatically removed from the cache. + +The cache pools are not cleared by the ``cache:clear`` command, but +removing ``var/cache/`` manually may remove the cache if the cache +component is configured to store its cache in that location. Read the +:doc:`/cache` guide for more information. + +Allow a Link to only be Used Once +................................. + +When setting ``max_uses`` to ``1``, you must take extra precautions to +make it work as expected. Email providers and browsers often load a +preview of the links, meaning that the link is already invalidated by +the preview loader. + +In order to solve this issue, first set the ``check_post_only`` option let +the authenticator only handle HTTP POST methods: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/security.yaml + security: + firewalls: + main: + login_link: + check_route: login_check + check_post_only: true + max_uses: 1 + + .. code-block:: xml + + + + + + + + + + + + + .. code-block:: php + + // config/packages/security.php + $container->loadFromExtension('security', [ + 'firewalls' => [ + 'main' => [ + 'login_link' => [ + 'check_route' => 'login_check', + 'check_post_only' => true, + 'max_uses' => 1, + ], + ], + ], + ]); + +Then, use the ``check_route`` controller to render a page that lets the +user create this POST request (e.g. by clicking a button):: + + // src/Controller/SecurityController.php + namespace App\Controller; + + // ... + use Symfony\Component\Routing\Generator\UrlGeneratorInterface; + + class SecurityController extends AbstractController + { + /** + * @Route("/login_check", name="login_check") + */ + public function check() + { + // get the login link query parameters + $expires = $request->query->get('expires'); + $username = $request->query->get('user'); + $hash = $request->query->get('hash'); + + // and render a template with the button + return $this->render('security/process_login_link.html.twig', [ + 'expires' => $expires, + 'user' => $username, + 'hash' => $hash, + ]); + } + } + +.. code-block:: html+twig + + {# templates/security/process_login_link.html.twig #} + {% extends 'base.html.twig' %} + + {% block body %} +

Hi! You are about to login to ...

+ + +
+ + + + + +
+ {% endblock %} From 2c8e1b940976cc4300aec04b8e50d498944dd3db Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 16:53:25 +0200 Subject: [PATCH 560/752] Tweaks --- rate_limiter.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 3849a502858..6fa7192945f 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -128,8 +128,8 @@ the number of requests to the API:: class ApiController extends AbstractController { - // the variable name must be: "rate limiter name" + "limiter" suffix - // if you're using autowiring for your services + // if you're using service autowiring, the variable name must be: + // "rate limiter name" (in camelCase) + "limiter" suffix public function index(RateLimiter $anonymousApiLimiter) { // create a limiter based on a unique identifier of the client @@ -199,8 +199,8 @@ processes by reserving unused tokens. .. note:: - Not all strategies allow reservering tokens in the future. These - strategies may throw an ``ReserveNotSupportedException`` when calling + Not all strategies allow reserving tokens in the future. These + strategies may throw a ``ReserveNotSupportedException`` when calling ``reserve()``. In these cases, you can use ``consume()`` together with ``wait()``, but From b8653ebb1ee6eb03ce18d42fc1eded0e2f950b59 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 18:49:15 +0200 Subject: [PATCH 561/752] Reword the intro --- security/login_link.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/security/login_link.rst b/security/login_link.rst index 929091184de..b980dea5790 100644 --- a/security/login_link.rst +++ b/security/login_link.rst @@ -5,10 +5,14 @@ How to use Passwordless Login Link Authentication ================================================= -Login links, also called "magic links", allow users to log in without -passwords. Whenever a user wants to login, a login link is generated and -sent to the user (e.g. using an email). The user is logged in as soon as -they visit that link. +Login links, also called "magic links", are a passwordless authentication +mechanism. Whenever a user wants to login, a new link is generated and sent to +them (e.g. using an email). The link fully authenticates the user in the +application when clicking on it. + +This authentication method can help you eliminate most of the customer support +related to authentication (e.g. I forgot my password, how can I change or reset +my password, etc.) Login links are supported by Symfony when using the experimental authenticator system. You must From 0c6a78285c2cf275a3769203ab94518a9706be1d Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 19:20:31 +0200 Subject: [PATCH 562/752] Added the versionadded directive --- components/options_resolver.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/options_resolver.rst b/components/options_resolver.rst index 74569b9123e..941d61de6c7 100644 --- a/components/options_resolver.rst +++ b/components/options_resolver.rst @@ -823,8 +823,7 @@ method:: .. versionadded:: 5.1 - The :method:`Symfony\\Component\\OptionsResolver\\OptionsResolver::define` method - was introduced in Symfony 5.1. + The ``define()`` and ``info()`` methods were introduced in Symfony 5.1. Performance Tweaks ~~~~~~~~~~~~~~~~~~ From f012726a03907a7d26536f293d4baeeb92db9164 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 19:27:01 +0200 Subject: [PATCH 563/752] Fixed a broken reference --- security/login_link.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/login_link.rst b/security/login_link.rst index b980dea5790..3db4f34f8eb 100644 --- a/security/login_link.rst +++ b/security/login_link.rst @@ -325,7 +325,7 @@ configuration decisions are discussed: * `Limit Login Link Lifetime`_ * `Invalidate Login Links`_ -* `Only allow a Link to be used Once`_ +* `Allow a Link to only be Used Once`_ Limit Login Link Lifetime ~~~~~~~~~~~~~~~~~~~~~~~~~ From a93da4e4ff1cd4d0863ced455fb1848fb3c27f26 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Tue, 13 Oct 2020 20:17:10 +0200 Subject: [PATCH 564/752] Made all messenger transport look the same --- messenger.rst | 290 +++++++++++++++++++++++++------------------------- 1 file changed, 147 insertions(+), 143 deletions(-) diff --git a/messenger.rst b/messenger.rst index 5eb11cba839..04f0716f982 100644 --- a/messenger.rst +++ b/messenger.rst @@ -123,7 +123,7 @@ is capable of sending messages (e.g. to a queueing system) and then A transport is registered using a "DSN". Thanks to Messenger's Flex recipe, your ``.env`` file already has a few examples. -.. code-block:: bash +.. code-block:: env # MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages # MESSENGER_TRANSPORT_DSN=doctrine://default @@ -839,11 +839,71 @@ Transport Configuration ----------------------- Messenger supports a number of different transport types, each with their own -options. +options. Options can be passed to the transport via a DSN string or configuration. + +.. code-block:: env + + # .env + MESSENGER_TRANSPORT_DSN=amqp://localhost/%2f/messages?auto_setup=false + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/messenger.yaml + framework: + messenger: + transports: + my_transport: + dsn: "%env(MESSENGER_TRANSPORT_DSN)%" + options: + auto_setup: false + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/messenger.php + $container->loadFromExtension('framework', [ + 'messenger' => [ + 'transports' => [ + 'my_transport' => [ + 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%', + 'options' => [ + 'auto_setup' => false, + ] + ], + ], + ], + ]); + +Options defined under ``options`` take precedence over ones defined in the DSN. AMQP Transport ~~~~~~~~~~~~~~ +The AMQP transport uses the AMQP PHP extension to send messages to queues like +RabbitMQ. + .. versionadded:: 5.1 Starting from Symfony 5.1, the AMQP transport has moved to a separate package. @@ -853,9 +913,9 @@ AMQP Transport $ composer require symfony/amqp-messenger -The ``amqp`` transport configuration looks like this: +The AMQP transport DSN may looks like this: -.. code-block:: bash +.. code-block:: env # .env MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages @@ -867,7 +927,6 @@ The ``amqp`` transport configuration looks like this: The AMQPS protocol support was introduced in Symfony 5.2. -To use Symfony's built-in AMQP transport, you need the AMQP PHP extension. If you want to use TLS/SSL encrypted AMQP, you must also provide a CA certificate. Define the certificate path in the ``amqp.cacert`` PHP.ini setting (e.g. ``amqp.cacert = /etc/ssl/certs``) or in the ``cacert`` parameter of the @@ -886,6 +945,66 @@ The transport has a number of other options, including ways to configure the exchange, queues binding keys and more. See the documentation on :class:`Symfony\\Component\\Messenger\\Bridge\\Amqp\\Transport\\Connection`. +The transport has a number of options: + +============================================ ================================================= =================================== + Option Description Default +============================================ ================================================= =================================== +``auto_setup`` Whether the table should be created ``true`` + automatically during send / get. +``cacert`` Path to the CA cert file in PEM format. +``cert`` Path to the client certificate in PEM format. +``channel_max`` Specifies highest channel number that the server + permits. 0 means standard extension limit +``confirm_timeout`` Timeout in seconds for confirmation, if none + specified transport will not wait for message + confirmation. Note: 0 or greater seconds. May be + fractional. +``connect_timeout`` Connection timeout. Note: 0 or greater seconds. + May be fractional. +``frame_max`` The largest frame size that the server proposes + for the connection, including frame header and + end-byte. 0 means standard extension limit + (depends on librabbimq default frame size limit) +``heartbeat`` The delay, in seconds, of the connection + heartbeat that the server wants. 0 means the + server does not want a heartbeat. Note, + librabbitmq has limited heartbeat support, which + means heartbeats checked only during blocking + calls. +``host`` Hostname of the AMQP service +``key`` Path to the client key in PEM format. +``password`` Password to use to connect to the AMQP service +``persistent`` ``'false'`` +``port`` Port of the AMQP service +``prefetch_count`` +``read_timeout`` Timeout in for income activity. Note: 0 or + greater seconds. May be fractional. +``retry`` +``sasl_method`` +``user`` Username to use to connect the AMQP service +``verify`` Enable or disable peer verification. If peer + verification is enabled then the common name in + the server certificate must match the server + name. Peer verification is enabled by default. +``vhost`` Virtual Host to use with the AMQP service +``write_timeout`` Timeout in for outcome activity. Note: 0 or + greater seconds. May be fractional. +``delay[queue_name_pattern]`` Pattern to use to create the queues ``delay_%exchange_name%_%routing_key%_%delay%`` +``delay[exchange_name]`` Name of the exchange to be used for the ``delays`` + delayed/retried messages +``queues[name][arguments]`` Extra arguments +``queues[name][binding_arguments]`` Arguments to be used while binding the queue. +``queues[name][binding_keys]`` The binding keys (if any) to bind to this queue +``queues[name][flags]`` Queue flags ``AMQP_DURABLE`` +``exchange[arguments]`` +``exchange[default_publish_routing_key]`` Routing key to use when publishing, if none is + specified on the message +``exchange[flags]`` Exchange flags ``AMQP_DURABLE`` +``exchange[name]`` Name of the exchange +``exchange[type]`` Type of exchange ``fanout`` +============================================ ================================================= =================================== + You can also configure AMQP-specific settings on your message by adding :class:`Symfony\\Component\\Messenger\\Bridge\\Amqp\\Transport\\AmqpStamp` to your Envelope:: @@ -912,6 +1031,8 @@ your Envelope:: Doctrine Transport ~~~~~~~~~~~~~~~~~~ +The Doctrine transport can be used to store messages in a database table. + .. versionadded:: 5.1 Starting from Symfony 5.1, the Doctrine transport has moved to a separate package. @@ -921,9 +1042,9 @@ Doctrine Transport $ composer require symfony/doctrine-messenger -The Doctrine transport can be used to store messages in a database table. +The Doctrine transport DSN may looks like this: -.. code-block:: bash +.. code-block:: env # .env MESSENGER_TRANSPORT_DSN=doctrine://default @@ -942,65 +1063,6 @@ Or, to create the table yourself, set the ``auto_setup`` option to ``false`` and The transport has a number of options: -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/messenger.yaml - framework: - messenger: - transports: - async_priority_high: "%env(MESSENGER_TRANSPORT_DSN)%?queue_name=high_priority" - async_normal: - dsn: "%env(MESSENGER_TRANSPORT_DSN)%" - options: - queue_name: normal_priority - - .. code-block:: xml - - - - - - - - - - - - normal_priority - - - - - - - - .. code-block:: php - - // config/packages/messenger.php - $container->loadFromExtension('framework', [ - 'messenger' => [ - 'transports' => [ - 'async_priority_high' => '%env(MESSENGER_TRANSPORT_DSN)%?queue_name=high_priority', - 'async_priority_low' => [ - 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%', - 'options' => [ - 'queue_name' => 'normal_priority' - ] - ], - ], - ], - ]); - -Options defined under ``options`` take precedence over ones defined in the DSN. - ================== ===================================== ====================== Option Description Default ================== ===================================== ====================== @@ -1025,82 +1087,25 @@ Beanstalkd Transport The Beanstalkd transport was introduced in Symfony 5.2. -Install it by running: +The Beanstalkd transports sends messages directly to a Beanstalkd work queue. Install +it by running: .. code-block:: terminal $ composer require symfony/beanstalkd-messenger -.. code-block:: bash +The Beanstalkd transport DSN may looks like this: - # .env - MESSENGER_TRANSPORT_DSN=beanstalkd://localhost +.. code-block:: env -The format is ``beanstalkd://:?tube_name=&timeout=&ttr=``. + # .env + MESSENGER_TRANSPORT_DSN=beanstalkd://localhost:11300?tube_name=foo&timeout=4&ttr=120 -The ``port`` setting is optional and defaults to ``11300`` if not set. + # If no port, it will default to 11300 + MESSENGER_TRANSPORT_DSN=beanstalkd://localhost The transport has a number of options: -.. configuration-block:: - - .. code-block:: yaml - - # config/packages/messenger.yaml - framework: - messenger: - transports: - async_priority_high: "%env(MESSENGER_TRANSPORT_DSN)%?tube_name=high_priority" - async_normal: - dsn: "%env(MESSENGER_TRANSPORT_DSN)%" - options: - tube_name: normal_priority - - .. code-block:: xml - - - - - - - - - - - - normal_priority - - - - - - - - .. code-block:: php - - // config/packages/messenger.php - $container->loadFromExtension('framework', [ - 'messenger' => [ - 'transports' => [ - 'async_priority_high' => '%env(MESSENGER_TRANSPORT_DSN)%?tube_name=high_priority', - 'async_priority_low' => [ - 'dsn' => '%env(MESSENGER_TRANSPORT_DSN)%', - 'options' => [ - 'tube_name' => 'normal_priority' - ] - ], - ], - ], - ]); - -Options defined under ``options`` take precedence over ones defined in the DSN. - ================== =================================== ====================== Option Description Default ================== =================================== ====================== @@ -1119,6 +1124,9 @@ ttr The message time to run before it Redis Transport ~~~~~~~~~~~~~~~ +The Redis transport uses `streams`_ to queue messages. This transport requires +the Redis PHP extension (>=4.3) and a running Redis server (^5.0). + .. versionadded:: 5.1 Starting from Symfony 5.1, the Redis transport has moved to a separate package. @@ -1128,9 +1136,9 @@ Redis Transport $ composer require symfony/redis-messenger -The Redis transport uses `streams`_ to queue messages. +The Redis transport DSN may looks like this: -.. code-block:: bash +.. code-block:: env # .env MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages @@ -1143,11 +1151,7 @@ The Redis transport uses `streams`_ to queue messages. The Unix socket DSN was introduced in Symfony 5.1. -To use the Redis transport, you will need the Redis PHP extension (>=4.3) and -a running Redis server (^5.0). - -A number of options can be configured via the DSN or via the ``options`` key -under the transport in ``messenger.yaml``: +The transport has a number of options: =================== ===================================== ========================= Option Description Default @@ -1275,27 +1279,27 @@ Amazon SQS The Amazon SQS transport as introduced in Symfony 5.1. -Install Amazon SQS transport by running: +The Amazon SQS transport is perfect for application hosted on AWS. Install it by +running: .. code-block:: terminal $ composer require symfony/amazon-sqs-messenger -The ``SQS`` transport configuration looks like this: +The SQS transport DSN may looks like this: .. code-block:: env # .env MESSENGER_TRANSPORT_DSN=sqs://AKIAIOSFODNN7EXAMPLE:j17M97ffSVoKI0briFoo9a@sqs.eu-west-3.amazonaws.com/messages - #MESSENGER_TRANSPORT_DSN=sqs://localhost:9494/messages?sslmode=disable + MESSENGER_TRANSPORT_DSN=sqs://localhost:9494/messages?sslmode=disable .. note:: The transport will automatically create queues that are needed. This can be disabled setting the ``auto_setup`` option to ``false``. -A number of options can be configured via the DSN or via the ``options`` key -under the transport in ``messenger.yaml``: +The transport has a number of options: ====================== ====================================== =================================== Option Description Default From fe40b48251b4fc43bbe50a7194759014a2858715 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sat, 17 Oct 2020 19:44:49 +0200 Subject: [PATCH 565/752] Tweaks --- service_container/autowiring.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 56a117f7b16..4a2b606c538 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -600,15 +600,16 @@ Autowiring will automatically call *any* method with the ``#[Required]`` attribu above it, autowiring each argument. If you need to manually wire some of the arguments to a method, you can always explicitly :doc:`configure the method call `. -If you need to stay compatible with PHP 7 and thus cannot use attributes, you can use -the ``@required`` annotation instead. +If your PHP version doesn't support attributes (they were introduced in PHP 8), +you can use the ``@required`` annotation instead. .. versionadded:: 5.2 The ``#[Required]`` attribute was introduced in Symfony 5.2. -Despite property injection has some :ref:`drawbacks `, autowiring with ``#[Required]`` -or ``@required`` can also be applied to public typed properties:: +Despite property injection has some :ref:`drawbacks `, +autowiring with ``#[Required]`` or ``@required`` can also be applied to public +typed properties:: .. configuration-block:: From 8d1364ecfb4db767168dcd33dcb045971ffc4ff6 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Sun, 18 Oct 2020 10:20:10 +0200 Subject: [PATCH 566/752] Fixed some wrong class names --- translation.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/translation.rst b/translation.rst index 1d6bdf5b7e2..238e80ee38c 100644 --- a/translation.rst +++ b/translation.rst @@ -313,10 +313,10 @@ all the information needed to fully translate its contents when needed:: use Symfony\Component\Translation\Translatable; // the first argument is required and it's the original message - $message = new TranslatableMessage('Symfony is great!'); + $message = new Translatable('Symfony is great!'); // the optional second argument defines the translation parameters and // the optional third argument is the translation domain - $status = new TranslatableMessage('order.status', ['%status%' => $order->getStatus()], 'store'); + $status = new Translatable('order.status', ['%status%' => $order->getStatus()], 'store'); Templates are now much simpler because you can pass translatable objects to the ``trans`` filter: From b5b0f71b1c560f2cc0a8bffbb231c5b88f18d08a Mon Sep 17 00:00:00 2001 From: Marvin Hinz <35603466+marvinhinz@users.noreply.github.com> Date: Sun, 18 Oct 2020 21:12:40 +0200 Subject: [PATCH 567/752] Fix spelling in framework.rst --- reference/configuration/framework.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 0e09a21c5cf..cdf5451d94a 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -770,7 +770,7 @@ service into your autowired classes. .. _reference-http-client-retry-failed: By enabling the optional ``retry_failed`` configuration, the HTTP client service -will automaticaly retry failed HTTP requests. +will automatically retry failed HTTP requests. .. code-block:: yaml From 19521c3a25b4d1afb3b4b8e9fe02014ac9312972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 20 Oct 2020 09:53:08 +0200 Subject: [PATCH 568/752] Fix documentation about RetryStrategy --- http_client.rst | 7 ++-- reference/configuration/framework.rst | 55 +++++++++------------------ 2 files changed, 22 insertions(+), 40 deletions(-) diff --git a/http_client.rst b/http_client.rst index a54e9b125a8..e0a9d6808e3 100644 --- a/http_client.rst +++ b/http_client.rst @@ -710,10 +710,9 @@ original HTTP client:: $client = new RetryableHttpClient(HttpClient::create()); The ``RetryableHttpClient`` uses a -:class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface` to -decide if the request should be retried, and a -:class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface` to -define the waiting time between each retry. +:class:`Symfony\\Component\\HttpClient\\Retry\\RetryStrategyInterface` to +decide if the request should be retried, and to define the waiting time between +each retry. HTTP Proxies ~~~~~~~~~~~~ diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index cdf5451d94a..a3d6e9fd95a 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -140,8 +140,7 @@ Configuration * :ref:`retry_failed ` - * `backoff_service`_ - * `decider_service`_ + * `retry_strategy`_ * :ref:`enabled ` * `delay`_ * `http_codes`_ @@ -157,8 +156,7 @@ Configuration * :ref:`retry_failed ` - * `backoff_service`_ - * `decider_service`_ + * `retry_strategy`_ * :ref:`enabled ` * `delay`_ * `http_codes`_ @@ -780,8 +778,7 @@ will automatically retry failed HTTP requests. http_client: # ... retry_failed: - # backoff_service: app.custom_backoff - # decider_service: app.custom_decider + # retry_strategy: app.custom_strategy http_codes: [429, 500] max_retries: 2 delay: 1000 @@ -826,21 +823,6 @@ in the `Microsoft NTLM authentication protocol`_. The value of this option must follow the format ``username:password``. This authentication mechanism requires using the cURL-based transport. -backoff_service -............... - -**type**: ``string`` - -.. versionadded:: 5.2 - - The ``backoff_service`` option was introduced in Symfony 5.2. - -The service id used to compute the time to wait between retries. By default, it -uses an instance of -:class:`Symfony\\Component\\HttpClient\\Retry\\ExponentialBackOff` configured -with ``delay``, ``max_delay``, ``multiplier`` and ``jitter`` options. This -class has to implement :class:`Symfony\\Component\\HttpClient\\Retry\\RetryBackOffInterface`. - base_uri ........ @@ -909,21 +891,6 @@ ciphers A list of the names of the ciphers allowed for the SSL/TLS connections. They can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM-SHA256'``). -decider_service -............... - -**type**: ``string`` - -.. versionadded:: 5.2 - - The ``decider_service`` option was introduced in Symfony 5.2. - -The service id used to decide if a request should be retried. By default, it -uses an instance of -:class:`Symfony\\Component\\HttpClient\\Retry\\HttpStatusCodeDecider` configured -with the ``http_codes`` option. This class has to implement -:class:`Symfony\\Component\\HttpClient\\Retry\\RetryDeciderInterface`. - delay ..... @@ -1124,6 +1091,22 @@ client and to make your tests easier. The value of this option is an associative array of ``domain => IP address`` (e.g ``['symfony.com' => '46.137.106.254', ...]``). +retry_strategy +............... + +**type**: ``string`` + +.. versionadded:: 5.2 + + The ``retry_strategy`` option was introduced in Symfony 5.2. + +The service is used to decide if a request should be retried and to compute the +time to wait between retries. By default, it uses an instance of +:class:`Symfony\\Component\\HttpClient\\Retry\\GenericRetryStrategy` configured +with ``http_codes``, ``delay``, ``max_delay``, ``multiplier`` and ``jitter`` +options. This class has to implement +:class:`Symfony\\Component\\HttpClient\\Retry\\RetryStrategyInterface`. + scope ..... From 09a9aa0d903f154e4c62654e2c652c7750a72c58 Mon Sep 17 00:00:00 2001 From: Ahmed TAILOULOUTE Date: Mon, 30 Dec 2019 08:44:27 +0100 Subject: [PATCH 569/752] Update typehints --- components/asset.rst | 4 ++-- configuration/env_var_processors.rst | 2 +- form/data_mappers.rst | 4 ++-- form/type_guesser.rst | 12 ++++++------ forms.rst | 2 +- frontend/custom_version_strategy.rst | 6 +++--- reference/dic_tags.rst | 4 ++-- security/access_control.rst | 2 +- security/custom_authentication_provider.rst | 2 +- security/user_provider.rst | 6 +++--- serializer/custom_encoders.rst | 8 ++++---- session/locale_sticky_session.rst | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/components/asset.rst b/components/asset.rst index 20b5ce20b2d..48e51754449 100644 --- a/components/asset.rst +++ b/components/asset.rst @@ -200,12 +200,12 @@ every day:: $this->version = date('Ymd'); } - public function getVersion($path) + public function getVersion(string $path) { return $this->version; } - public function applyVersion($path) + public function applyVersion(string $path) { return sprintf('%s?v=%s', $path, $this->getVersion($path)); } diff --git a/configuration/env_var_processors.rst b/configuration/env_var_processors.rst index b9782d270cd..464bf7af984 100644 --- a/configuration/env_var_processors.rst +++ b/configuration/env_var_processors.rst @@ -631,7 +631,7 @@ create a class that implements class LowercasingEnvVarProcessor implements EnvVarProcessorInterface { - public function getEnv($prefix, $name, \Closure $getEnv) + public function getEnv(string $prefix, string $name, \Closure $getEnv) { $env = $getEnv($name); diff --git a/form/data_mappers.rst b/form/data_mappers.rst index 15e66ce54b3..54081c09e47 100644 --- a/form/data_mappers.rst +++ b/form/data_mappers.rst @@ -98,7 +98,7 @@ in your form type:: /** * @param Color|null $viewData */ - public function mapDataToForms($viewData, $forms) + public function mapDataToForms($viewData, iterable $forms) { // there is no data yet, so nothing to prepopulate if (null === $viewData) { @@ -119,7 +119,7 @@ in your form type:: $forms['blue']->setData($viewData->getBlue()); } - public function mapFormsToData($forms, &$viewData) + public function mapFormsToData(iterable $forms, &$viewData) { /** @var FormInterface[] $forms */ $forms = iterator_to_array($forms); diff --git a/form/type_guesser.rst b/form/type_guesser.rst index f990aad4115..13f54999692 100644 --- a/form/type_guesser.rst +++ b/form/type_guesser.rst @@ -43,19 +43,19 @@ Start by creating the class and these methods. Next, you'll learn how to fill ea class PHPDocTypeGuesser implements FormTypeGuesserInterface { - public function guessType($class, $property) + public function guessType(string $class, string $property) { } - public function guessRequired($class, $property) + public function guessRequired(string $class, string $property) { } - public function guessMaxLength($class, $property) + public function guessMaxLength(string $class, string $property) { } - public function guessPattern($class, $property) + public function guessPattern(string $class, string $property) { } } @@ -94,7 +94,7 @@ With this knowledge, you can implement the ``guessType()`` method of the class PHPDocTypeGuesser implements FormTypeGuesserInterface { - public function guessType($class, $property) + public function guessType(string $class, string $property) { $annotations = $this->readPhpDocAnnotations($class, $property); @@ -129,7 +129,7 @@ With this knowledge, you can implement the ``guessType()`` method of the } } - protected function readPhpDocAnnotations($class, $property) + protected function readPhpDocAnnotations(string $class, string $property) { $reflectionProperty = new \ReflectionProperty($class, $property); $phpdoc = $reflectionProperty->getDocComment(); diff --git a/forms.rst b/forms.rst index 5867d2f07d1..ec5a04fcfc1 100644 --- a/forms.rst +++ b/forms.rst @@ -672,7 +672,7 @@ Set the ``label`` option on fields to define their labels explicitly:: ->add('dueDate', DateType::class, [ // set it to FALSE to not display the label for this field - 'label' => 'To Be Completed Before', + 'label' => 'To Be Completed Before', ]) .. tip:: diff --git a/frontend/custom_version_strategy.rst b/frontend/custom_version_strategy.rst index 6361ba632c0..0fe3f5ff987 100644 --- a/frontend/custom_version_strategy.rst +++ b/frontend/custom_version_strategy.rst @@ -71,13 +71,13 @@ version string:: * @param string $manifestPath * @param string|null $format */ - public function __construct($manifestPath, $format = null) + public function __construct(string $manifestPath, string $format = null) { $this->manifestPath = $manifestPath; $this->format = $format ?: '%s?%s'; } - public function getVersion($path) + public function getVersion(string $path) { if (!is_array($this->hashes)) { $this->hashes = $this->loadManifest(); @@ -86,7 +86,7 @@ version string:: return isset($this->hashes[$path]) ? $this->hashes[$path] : ''; } - public function applyVersion($path) + public function applyVersion(string $path) { $version = $this->getVersion($path); diff --git a/reference/dic_tags.rst b/reference/dic_tags.rst index f7f43dca376..0aca3c91777 100644 --- a/reference/dic_tags.rst +++ b/reference/dic_tags.rst @@ -410,7 +410,7 @@ service class:: class MyClearer implements CacheClearerInterface { - public function clear($cacheDirectory) + public function clear(string $cacheDirectory) { // clear your cache } @@ -1062,7 +1062,7 @@ required option: ``alias``, which defines the name of the extractor:: /** * Sets the prefix that should be used for new found messages. */ - public function setPrefix($prefix) + public function setPrefix(string $prefix) { $this->prefix = $prefix; } diff --git a/security/access_control.rst b/security/access_control.rst index 9b345b87a24..b02b9057424 100644 --- a/security/access_control.rst +++ b/security/access_control.rst @@ -92,7 +92,7 @@ Take the following ``access_control`` entries as an example: 'path' => '^/admin', 'roles' => 'ROLE_USER_METHOD', 'methods' => 'POST, PUT', - ] + ], ], ]); diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 3199128b26a..4a0a5be4407 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -410,7 +410,7 @@ to service ids that may not exist yet: ``App\Security\Authentication\Provider\Ws - + diff --git a/security/user_provider.rst b/security/user_provider.rst index 000a7a49a38..5fcf19f3bf2 100644 --- a/security/user_provider.rst +++ b/security/user_provider.rst @@ -135,7 +135,7 @@ interface only requires one method: ``loadUserByUsername($username)``:: { // ... - public function loadUserByUsername($usernameOrEmail) + public function loadUserByUsername(string $usernameOrEmail) { $entityManager = $this->getEntityManager(); @@ -376,7 +376,7 @@ command will generate a nice skeleton to get you started:: * * @throws UsernameNotFoundException if the user is not found */ - public function loadUserByUsername($username) + public function loadUserByUsername(string $username) { // Load a User object from your data source or throw UsernameNotFoundException. // The $username argument may not actually be a username: @@ -412,7 +412,7 @@ command will generate a nice skeleton to get you started:: /** * Tells Symfony to use this provider for this User class. */ - public function supportsClass($class) + public function supportsClass(string $class) { return User::class === $class || is_subclass_of($class, User::class); } diff --git a/serializer/custom_encoders.rst b/serializer/custom_encoders.rst index 5bb78def4e4..e6bae859336 100644 --- a/serializer/custom_encoders.rst +++ b/serializer/custom_encoders.rst @@ -27,22 +27,22 @@ create your own encoder that uses the class YamlEncoder implements EncoderInterface, DecoderInterface { - public function encode($data, $format, array $context = []) + public function encode($data, string $format, array $context = []) { return Yaml::dump($data); } - public function supportsEncoding($format) + public function supportsEncoding(string $format) { return 'yaml' === $format; } - public function decode($data, $format, array $context = []) + public function decode(string $data, string $format, array $context = []) { return Yaml::parse($data); } - public function supportsDecoding($format) + public function supportsDecoding(string $format) { return 'yaml' === $format; } diff --git a/session/locale_sticky_session.rst b/session/locale_sticky_session.rst index f8caef23370..056f2a674cb 100644 --- a/session/locale_sticky_session.rst +++ b/session/locale_sticky_session.rst @@ -28,7 +28,7 @@ correct locale however you want:: { private $defaultLocale; - public function __construct($defaultLocale = 'en') + public function __construct(string $defaultLocale = 'en') { $this->defaultLocale = $defaultLocale; } From 010f62fc460e49461c5d3fb98f2aaceb636c813d Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Wed, 21 Oct 2020 15:49:46 +0200 Subject: [PATCH 570/752] Fix markup of configuration-block. --- routing.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routing.rst b/routing.rst index 53088f53a32..4588ba61cd2 100644 --- a/routing.rst +++ b/routing.rst @@ -58,7 +58,7 @@ This configuration tells Symfony to look for routes defined as annotations in any PHP class stored in the ``src/Controller/`` directory. Suppose you want to define a route for the ``/blog`` URL in your application. To -do so, create a :doc:`controller class ` like the following:: +do so, create a :doc:`controller class ` like the following: .. configuration-block:: From 0f91cc9f74a656da845b6a46b225a8351a83ccae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 20 Oct 2020 09:42:57 +0200 Subject: [PATCH 571/752] Add documentation for retry on idempotent methods --- http_client.rst | 8 +++++--- reference/configuration/framework.rst | 7 +++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/http_client.rst b/http_client.rst index e0a9d6808e3..5c899660b62 100644 --- a/http_client.rst +++ b/http_client.rst @@ -694,9 +694,10 @@ Retry Failed Requests Sometimes, requests fail because of network issues or temporary server errors. Symfony's HttpClient allows to retry failed requests automatically using the :ref:`retry_failed option `. When enabled, -each failed request with an HTTP status of ``423``, ``425``, ``429``, ``500``, -``502``, ``503``, ``504``, ``507``, or ``510`` is retried up to 3 times, with an -exponential delay between retries (first retry = 1 second; third retry: 4 seconds). +each failed request with an HTTP status of ``423``, ``425``, ``429``, ``502``, +``503`` or with an `idempotent method`_ and a HTTP status of ``500``, ``504``, +``507`` or ``510`` is retried up to 3 times, with an exponential delay between +retries (first retry = 1 second; third retry: 4 seconds). Check out the full list of configurable :ref:`retry_failed options ` to learn how to tweak each of them to fit your application needs. @@ -1609,3 +1610,4 @@ Then configure Symfony to use your callback: .. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php .. _`Server-sent events`: https://html.spec.whatwg.org/multipage/server-sent-events.html .. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource +.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index a3d6e9fd95a..b8b0a7887d6 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -779,7 +779,10 @@ will automatically retry failed HTTP requests. # ... retry_failed: # retry_strategy: app.custom_strategy - http_codes: [429, 500] + http_codes: + 0: ['GET', 'HEAD'] # retry network errors if request method is GET or HEAD + 429: true # retry all responses with 429 status code + 500: ['GET', 'HEAD'] max_retries: 2 delay: 1000 multiplier: 3 @@ -923,7 +926,7 @@ value must use the format ``['header-name' => 'value0, value1, ...']``. http_codes .......... -**type**: ``array`` **default**: ``[423, 425, 429, 500, 502, 503, 504, 507, 510]`` +**type**: ``array`` **default**: :method:`Symfony\\Component\\HttpClient\\Retry\\GenericRetryStrategy::DEFAULT_RETRY_STATUS_CODES` .. versionadded:: 5.2 From 689614433c04d186640f563d619c36adc43184c9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 21 Oct 2020 20:14:08 +0200 Subject: [PATCH 572/752] Tweak --- http_client.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/http_client.rst b/http_client.rst index 5c899660b62..efc5a14e799 100644 --- a/http_client.rst +++ b/http_client.rst @@ -693,11 +693,13 @@ Retry Failed Requests Sometimes, requests fail because of network issues or temporary server errors. Symfony's HttpClient allows to retry failed requests automatically using the -:ref:`retry_failed option `. When enabled, -each failed request with an HTTP status of ``423``, ``425``, ``429``, ``502``, -``503`` or with an `idempotent method`_ and a HTTP status of ``500``, ``504``, -``507`` or ``510`` is retried up to 3 times, with an exponential delay between -retries (first retry = 1 second; third retry: 4 seconds). +:ref:`retry_failed option `. + +By default, failed requests are retried up to 3 times, with an exponential delay +between retries (first retry = 1 second; third retry: 4 seconds) and only for +the following HTTP status codes: ``423``, ``425``, ``429``, ``502`` and ``503`` +when using any HTTP method and ``500``, ``504``, ``507`` and ``510`` when using +an HTTP `idempotent method`_. Check out the full list of configurable :ref:`retry_failed options ` to learn how to tweak each of them to fit your application needs. From 3781df649e39522eddbb612d452c661eb33f33d1 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Fri, 12 Jun 2020 13:46:50 +0200 Subject: [PATCH 573/752] [PropertyInfo] Document setting serializer_groups to null in the SerializerExtractor --- components/property_info.rst | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/components/property_info.rst b/components/property_info.rst index d67034b04fa..16aac3299e2 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -435,7 +435,18 @@ with the ``property_info`` service in the Symfony Framework:: $serializerExtractor = new SerializerExtractor($serializerClassMetadataFactory); // List information. - $serializerExtractor->getProperties($class); + $serializerExtractor->getProperties($class, ['serializer_groups' => ['mygroup']]); + +.. note:: + + The ``serializer_groups`` option must be provided in order to have a value different than ``null`` returned. + + If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be checked but you will get only the properties + considered by the Serializer Component (notably the ``@Ignore`` annotation is taken into account). + +.. versionadded:: 5.2 + + Support for the ``null`` value in ``serializer_groups`` was introduced in Symfony 5.2. DoctrineExtractor ~~~~~~~~~~~~~~~~~ From d0abaf04aa169560fa7e791debbc82299991be0e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 22 Oct 2020 09:19:42 +0200 Subject: [PATCH 574/752] Tweaks --- components/property_info.rst | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/components/property_info.rst b/components/property_info.rst index 16aac3299e2..b6684d948d8 100644 --- a/components/property_info.rst +++ b/components/property_info.rst @@ -434,15 +434,12 @@ with the ``property_info`` service in the Symfony Framework:: ); $serializerExtractor = new SerializerExtractor($serializerClassMetadataFactory); - // List information. + // the `serializer_groups` option must be configured (may be set to null) $serializerExtractor->getProperties($class, ['serializer_groups' => ['mygroup']]); - -.. note:: - - The ``serializer_groups`` option must be provided in order to have a value different than ``null`` returned. - If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be checked but you will get only the properties - considered by the Serializer Component (notably the ``@Ignore`` annotation is taken into account). +If ``serializer_groups`` is set to ``null``, serializer groups metadata won't be +checked but you will get only the properties considered by the Serializer +Component (notably the ``@Ignore`` annotation is taken into account). .. versionadded:: 5.2 From 3bc914cc2043612bfc97e1e9e7c78c95ef695e52 Mon Sep 17 00:00:00 2001 From: Rachid Hammaoui <37940572+makmaoui@users.noreply.github.com> Date: Fri, 14 Aug 2020 18:41:43 +0200 Subject: [PATCH 575/752] Fix wrong properties class Fix classname for query and cookies properties --- components/http_foundation.rst | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index dad9990dd64..3a90611edbe 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -83,17 +83,19 @@ can be accessed via several public properties: Each property is a :class:`Symfony\\Component\\HttpFoundation\\ParameterBag` instance (or a sub-class of), which is a data holder class: -* ``request``: :class:`Symfony\\Component\\HttpFoundation\\ParameterBag`; +* ``request``: :class:`Symfony\\Component\\HttpFoundation\\ParameterBag` or + :class:`Symfony\\Component\\HttpFoundation\\InputBag` if the data is + coming from ``$_POST`` parameters; -* ``query``: :class:`Symfony\\Component\\HttpFoundation\\ParameterBag`; +* ``query``: :class:`Symfony\\Component\\HttpFoundation\\InputBag`; -* ``cookies``: :class:`Symfony\\Component\\HttpFoundation\\ParameterBag`; +* ``cookies``: :class:`Symfony\\Component\\HttpFoundation\\InputBag`; * ``attributes``: :class:`Symfony\\Component\\HttpFoundation\\ParameterBag`; -* ``files``: :class:`Symfony\\Component\\HttpFoundation\\FileBag`; +* ``files``: :class:`Symfony\\Component\\HttpFoundation\\FileBag`; -* ``server``: :class:`Symfony\\Component\\HttpFoundation\\ServerBag`; +* ``server``: :class:`Symfony\\Component\\HttpFoundation\\ServerBag`; * ``headers``: :class:`Symfony\\Component\\HttpFoundation\\HeaderBag`. From 9d189ef6b5e1c381923ac894ec3237ed45e620de Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 22 Oct 2020 11:23:38 +0200 Subject: [PATCH 576/752] [RateLimiter] Document the RateLimit object --- rate_limiter.rst | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/rate_limiter.rst b/rate_limiter.rst index 6fa7192945f..527357cc011 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -212,6 +212,50 @@ processes by reserving unused tokens. $limit->wait(); } while (!$limit->isAccepted()); +Exposing the Rate Limiter Status +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +When using a rate limiter in APIs, it's common to include some standard HTTP +headers in the response to expose the limit status (e.g. remaining tokens, when +new tokens will be available, etc.) + +Use the :class:`Symfony\\Component\\RateLimiter\\RateLimit` object returned by +the ``consume()`` method (also available via the ``getRateLimit()`` method of +the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the +``reserve()`` method) to get the value of those HTTP headers:: + + // src/Controller/ApiController.php + namespace App\Controller; + + use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; + use Symfony\Component\HttpFoundation\Response; + use Symfony\Component\RateLimiter\RateLimiter; + + class ApiController extends AbstractController + { + public function index(RateLimiter $anonymousApiLimiter) + { + $limiter = $anonymousApiLimiter->create($request->getClientIp()); + $limit = $limiter->consume(); + $headers = [ + 'X-RateLimit-Remaining' => $limit->getRemainingTokens(), + 'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp(), + 'X-RateLimit-Limit' => $limit->getLimit(), + ]; + + if (false === $limit->isAccepted()) { + return new Response(null, Response::HTTP_TOO_MANY_REQUESTS, $headers); + } + + // ... + + $reponse = new Response('...'); + $response->headers->add($headers); + + return $response; + } + } + Rate Limiter Storage and Locking -------------------------------- From 809b7a0e63d9dfb743c6aaea9f6bda485bb3de2a Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 22 Oct 2020 09:56:38 +0200 Subject: [PATCH 577/752] [Lock] Mention the priority policy of shared locks --- components/lock.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/components/lock.rst b/components/lock.rst index 518a01c9375..3a92184c85e 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -237,6 +237,11 @@ to acquire the lock in a blocking mode:: $lock = $factory->createLock('user'.$user->id); $lock->acquireRead(true); +.. note:: + + The `priority policy`_ of Symfony's shared locks depends on the underlying + store (e.g. Redis store prioritizes readers vs writers). + When a read-only lock is acquired with the method ``acquireRead()``, it's possible to **promote** the lock, and change it to write lock, by calling the ``acquire()`` method:: @@ -915,3 +920,4 @@ are still running. .. _`Replica Set Read and Write Semantics`: https://docs.mongodb.com/manual/applications/replication/ .. _`ZooKeeper`: https://zookeeper.apache.org/ .. _`readers–writer lock`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock +.. _`priority policy`: https://en.wikipedia.org/wiki/Readers%E2%80%93writer_lock#Priority_policies From 269f500c45bf4ae3654d5edb92825c9d4e0c66ae Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 22 Oct 2020 17:41:24 +0200 Subject: [PATCH 578/752] Added missing namespace --- security/experimental_authenticators.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 83b3199d9ef..8a1b6081d84 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -472,6 +472,9 @@ the following badges are supported: For instance, if you want to add CSRF and password migration to your custom authenticator, you would initialize the passport like this:: + // src/Service/LoginAuthenticator.php + namespace App\Service; + // ... use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; From e912f23b557bd56ed1c7c296f12b178f48e6dfb5 Mon Sep 17 00:00:00 2001 From: TavoNiievez <64917965+TavoNiievez@users.noreply.github.com> Date: Thu, 22 Oct 2020 13:54:00 -0500 Subject: [PATCH 579/752] Typo in impersonator role The correct role is 'IS_IMPERSONATOR'. --- components/security/authorization.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/security/authorization.rst b/components/security/authorization.rst index c074cf14b75..b884ce97ac0 100644 --- a/components/security/authorization.rst +++ b/components/security/authorization.rst @@ -114,12 +114,12 @@ user fully authenticated, or only based on a "remember-me" cookie, or even authenticated anonymously? It also supports the attributes ``IS_ANONYMOUS``, ``IS_REMEMBERED``, -``IS_IMPERSONATED`` to grant access based on a specific state of +``IS_IMPERSONATOR`` to grant access based on a specific state of authentication. .. versionadded:: 5.1 - The ``IS_ANONYMOUS``, ``IS_REMEMBERED`` and ``IS_IMPERSONATED`` + The ``IS_ANONYMOUS``, ``IS_REMEMBERED`` and ``IS_IMPERSONATOR`` attributes were introduced in Symfony 5.1. :: From c630bcb1739638120d1fc7bf2c62c0f14bc7ee1e Mon Sep 17 00:00:00 2001 From: Mathieu Piot Date: Fri, 17 Apr 2020 13:51:19 +0200 Subject: [PATCH 580/752] Add Discord notifier --- notifier.rst | 3 ++- notifier/chatters.rst | 53 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 9d0b5148553..d79933b7188 100644 --- a/notifier.rst +++ b/notifier.rst @@ -139,6 +139,7 @@ integration with these chat services: ========== ================================ =========================================================================== Service Package DSN ========== ================================ =========================================================================== +Discord ``symfony/discord-notifier`` ``discord://TOKEN@default?webhook_id=ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` @@ -156,7 +157,7 @@ Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?ch .. versionadded:: 5.2 - The GoogleChat, LinkedIn and Zulip integrations were introduced in Symfony 5.2. + The GoogleChat, LinkedIn, Zulip and Discord integrations were introduced in Symfony 5.2. Chatters are configured using the ``chatter_transports`` setting: diff --git a/notifier/chatters.rst b/notifier/chatters.rst index efbd040593e..b37d17c2040 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -99,3 +99,56 @@ some interactive options called `Block elements`_:: $chatter->send($chatMessage); .. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements + +Adding Interactions to a Discord Message +-------------------------------------- + +With a Discord message, you can use the +:class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` to add +some interactive options called `Embed elements`_:: + + use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordEmbed; + use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFieldEmbedObject; + use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFooterEmbedObject; + use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordMediaEmbedObject; + use Symfony\Component\Notifier\Bridge\Discord\DiscordOptions; + use Symfony\Component\Notifier\Message\ChatMessage; + + $chatMessage = new ChatMessage(''); + + // Create Discord Embed + $discordOptions = (new DiscordOptions()) + ->username('connor bot') + ->addEmbed((new DiscordEmbed()) + ->color(2021216) + ->title('New song added!') + ->thumbnail((new DiscordMediaEmbedObject()) + ->url('https://i.scdn.co/image/ab67616d0000b2735eb27502aa5cb1b4c9db426b')) + ->addField((new DiscordFieldEmbedObject()) + ->name('Track') + ->value('[Common Ground](https://open.spotify.com/track/36TYfGWUhIRlVjM8TxGUK6)') + ->inline(true) + ) + ->addField((new DiscordFieldEmbedObject()) + ->name('Artist') + ->value('Alasdair Fraser') + ->inline(true) + ) + ->addField((new DiscordFieldEmbedObject()) + ->name('Album') + ->value('Dawn Dance') + ->inline(true) + ) + ->footer((new DiscordFooterEmbedObject()) + ->text('Added ...') + ->iconUrl('https://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Spotify_logo_without_text.svg/200px-Spotify_logo_without_text.svg.png') + ) + ) + ; + + // Add the custom options to the chat message and send the message + $chatMessage->options($discordOptions); + + $chatter->send($chatMessage); + +.. _`Embed elements`: https://discord.com/developers/docs/resources/webhook From bf6cca937f6c2e96a0e9a2deeeae0fc768b8a764 Mon Sep 17 00:00:00 2001 From: Baptiste Leduc Date: Fri, 23 Oct 2020 13:45:06 +0200 Subject: [PATCH 581/752] Non-standard adder/remover methods --- components/property_access.rst | 39 ++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/components/property_access.rst b/components/property_access.rst index df0f3d99b51..741d3023ad5 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -394,6 +394,45 @@ and ``removeChild()`` methods to access to the ``children`` property. If available, *adder* and *remover* methods have priority over a *setter* method. +Using non-standard adder/remover methods +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Sometimes, adder and remover methods don't use the standard ``add`` or ``remove`` prefix, like in this example:: + + // ... + class PeopleList + { + // ... + + public function joinPeople(string $people): void + { + $this->peoples[] = $people; + } + + public function leavePeople(string $people): void + { + foreach ($this->peoples as $id => $item) { + if ($people === $item) { + unset($this->peoples[$id]); + break; + } + } + } + } + + use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; + use Symfony\Component\PropertyAccess\PropertyAccessor; + + $list = new PeopleList(); + $reflectionExtractor = new ReflectionExtractor(null, null, ['join', 'leave']); + $propertyAccessor = new PropertyAccessor(false, false, null, true, $reflectionExtractor, $reflectionExtractor); + $propertyAccessor->setValue($person, 'peoples', ['kevin', 'wouter']); + + var_dump($person->getPeoples()); // ['kevin', 'wouter'] + +Instead of calling ``add()`` and ``remove()``, the PropertyAccess +component will call ``join()`` and ``leave()`` methods. + Checking Property Paths ----------------------- From 8fe20c33a49ba1bd21de5eb78477752e5c6fdd1b Mon Sep 17 00:00:00 2001 From: Toni Rudolf Date: Mon, 3 Feb 2020 17:24:10 +0100 Subject: [PATCH 582/752] Added redeliver_timeout and claim_interval options --- messenger.rst | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/messenger.rst b/messenger.rst index 54c7fb200a5..9917e5d7c28 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1038,9 +1038,9 @@ a running Redis server (^5.0). A number of options can be configured via the DSN or via the ``options`` key under the transport in ``messenger.yaml``: -================== ===================================== ========================= - Option Description Default -================== ===================================== ========================= +=================== ===================================== ================================= + Option Description Default +=================== ===================================== ================================= stream The Redis stream name messages group The Redis consumer group name symfony consumer Consumer name used in Redis consumer @@ -1056,7 +1056,23 @@ stream_max_entries The maximum number of entries which ``0`` (which means "n it to a large enough number to avoid losing pending messages tls Enable TLS support for the connection false -================== ===================================== ========================= +redeliver_timeout Timeout before retrying a pending ``3600`` + message which is owned by an + abandoned consumer (if a worker died + for some reason, this will occur, + eventually you should retry the + message) - in seconds. +claim_interval Interval on which pending/abandoned ``60000`` (1 Minute) + messages should be checked for to + claim - in milliseconds +=================== ===================================== ================================= + +.. caution:: + + There should never be more than one `messenger:consume` command running with the same + config (stream, group and consumer name) to avoid having a message handled more than once. + Using the ``HOSTNAME`` as the consumer might often be a good idea. In case you are using + Kubernetes to orchestrate your containers, consider using a ``StatefulSet``. .. tip:: From d6988a76ee403c23382fd420dd60dcc69fb083f3 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Fri, 23 Oct 2020 15:05:47 +0200 Subject: [PATCH 583/752] [#12976] Minor syntax fix --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 9917e5d7c28..78d09d50e9a 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1069,7 +1069,7 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute) .. caution:: - There should never be more than one `messenger:consume` command running with the same + There should never be more than one ``messenger:consume`` command running with the same config (stream, group and consumer name) to avoid having a message handled more than once. Using the ``HOSTNAME`` as the consumer might often be a good idea. In case you are using Kubernetes to orchestrate your containers, consider using a ``StatefulSet``. From 08496685d725a48630e0a019e11188cd1c7c1c91 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Fri, 23 Oct 2020 15:08:55 +0200 Subject: [PATCH 584/752] [#12976] Added the new options to the versionadded directive --- messenger.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 78d09d50e9a..3dce638cd70 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1083,7 +1083,8 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute) .. versionadded:: 5.1 - The ``delete_after_ack`` option was introduced in Symfony 5.1. + The ``delete_after_ack``, ``redeliver_timeout`` and ``claim_interval`` + options were introduced in Symfony 5.1. In Memory Transport ~~~~~~~~~~~~~~~~~~~ From f79b26828e2bed575c0fbecf3860b9893103efe4 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 23 Oct 2020 15:14:37 +0200 Subject: [PATCH 585/752] Syntax fix --- notifier/chatters.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index b37d17c2040..9d03f83987c 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -101,7 +101,7 @@ some interactive options called `Block elements`_:: .. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements Adding Interactions to a Discord Message --------------------------------------- +---------------------------------------- With a Discord message, you can use the :class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` to add From 55a6ad049d3c17b4a9c651aa5ecdf4dab5bec5c2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 23 Oct 2020 15:24:54 +0200 Subject: [PATCH 586/752] Fixed a syntax issue --- messenger.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/messenger.rst b/messenger.rst index f2c2a8b65be..7f74be71dd6 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1160,21 +1160,21 @@ under the transport in ``messenger.yaml``: =================== ===================================== ================================= Option Description Default =================== ===================================== ================================= -stream The Redis stream name messages -group The Redis consumer group name symfony -consumer Consumer name used in Redis consumer -auto_setup Create the Redis group automatically? true -auth The Redis password -delete_after_ack If ``true``, messages are deleted false - automatically after processing them -serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` - in Redis (the - ``Redis::OPT_SERIALIZER`` option) -stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") - the stream will be trimmed to. Set - it to a large enough number to - avoid losing pending messages -tls Enable TLS support for the connection false +stream The Redis stream name messages +group The Redis consumer group name symfony +consumer Consumer name used in Redis consumer +auto_setup Create the Redis group automatically? true +auth The Redis password +delete_after_ack If ``true``, messages are deleted false + automatically after processing them +serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` + in Redis (the + ``Redis::OPT_SERIALIZER`` option) +stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") + the stream will be trimmed to. Set + it to a large enough number to + avoid losing pending messages +tls Enable TLS support for the connection false redeliver_timeout Timeout before retrying a pending ``3600`` message which is owned by an abandoned consumer (if a worker died From 85b27e554a7e9b6a26e3358f51ca933eee90fec3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 23 Oct 2020 13:46:16 +0200 Subject: [PATCH 587/752] [Messenger] Added Lazy option to redis --- messenger.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index 7f74be71dd6..6c2f2e35794 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1167,6 +1167,10 @@ auto_setup Create the Redis group automatically? true auth The Redis password delete_after_ack If ``true``, messages are deleted false automatically after processing them +delete_after_reject If ``true``, messages are deleted true + automatically if they are rejected +lazy Connect only when a connection is false + really needed serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` in Redis (the ``Redis::OPT_SERIALIZER`` option) @@ -1207,7 +1211,7 @@ claim_interval Interval on which pending/abandoned ``60000`` (1 Minute) .. versionadded:: 5.2 - The ``delete_after_reject`` option was introduced in Symfony 5.2. + The ``delete_after_reject`` and ``lazy`` options were introduced in Symfony 5.2. In Memory Transport ~~~~~~~~~~~~~~~~~~~ From 2fcc6fe060af8fcdb7d7010130e535e548a6d919 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 25 Oct 2020 16:37:19 +0100 Subject: [PATCH 588/752] [RateLimit] Make sure we mention policy instead of limit --- rate_limiter.rst | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 527357cc011..22a56168498 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -16,11 +16,11 @@ Symfony uses these rate limiters in built-in features like "login throttling", which limits how many failed login attempts a user can make in a given period of time, but you can use them for your own features too. -Rate Limiting Strategies ------------------------- +Rate Limiting Policies +---------------------- -Symfony's rate limiter implements some of the most common strategies to enforce -rate limits: **fixed window**, **sliding window** and **token bucket**. +Symfony's rate limiter implements some of the most common policies to enforce +rate limits: **fixed window**, **sliding window**, **token bucket**. Fixed Window Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -86,12 +86,12 @@ enforce different levels of service (free or paid): framework: rate_limiter: anonymous_api: - # use 'sliding_window' if you prefer that strategy - strategy: 'fixed_window' + # use 'sliding_window' if you prefer that policy + policy: 'fixed_window' limit: 100 interval: '60 minutes' authenticated_api: - strategy: 'token_bucket' + policy: 'token_bucket' limit: 5000 rate: { interval: '15 minutes', amount: 500 } @@ -124,13 +124,13 @@ the number of requests to the API:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpKernel\Exception\TooManyRequestsHttpException; - use Symfony\Component\RateLimiter\RateLimiter; + use Symfony\Component\RateLimiter\RateLimiterFactory; class ApiController extends AbstractController { // if you're using service autowiring, the variable name must be: // "rate limiter name" (in camelCase) + "limiter" suffix - public function index(RateLimiter $anonymousApiLimiter) + public function index(RateLimiterFactory $anonymousApiLimiter) { // create a limiter based on a unique identifier of the client // (e.g. the client's IP address, a username/email, an API key, etc.) @@ -171,11 +171,11 @@ using the ``reserve()`` method:: use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\RateLimiter\RateLimiter; + use Symfony\Component\RateLimiter\RateLimiterFactory; class ApiController extends AbstractController { - public function registerUser(Request $request, RateLimiter $authenticatedApiLimiter) + public function registerUser(Request $request, RateLimiterFactory $authenticatedApiLimiter) { $apiKey = $request->headers->get('apikey'); $limiter = $authenticatedApiLimiter->create($apiKey); @@ -229,11 +229,11 @@ the :class:`Symfony\\Component\\RateLimiter\\Reservation` object returned by the use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; - use Symfony\Component\RateLimiter\RateLimiter; + use Symfony\Component\RateLimiter\RateLimiterFactory; class ApiController extends AbstractController { - public function index(RateLimiter $anonymousApiLimiter) + public function index(RateLimiterFactory $anonymousApiLimiter) { $limiter = $anonymousApiLimiter->create($request->getClientIp()); $limit = $limiter->consume(); From 3e0c21cc3eb8b8ed493b982a2c0c3cc77afb76aa Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 25 Oct 2020 16:39:18 +0100 Subject: [PATCH 589/752] Update wrong use statement --- translation.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/translation.rst b/translation.rst index cb774e70f7a..4c4b4b9a07b 100644 --- a/translation.rst +++ b/translation.rst @@ -307,16 +307,16 @@ parts of your application and mocking it in your tests. Instead of translating a string at the time of creation, you can use a "translatable object", which is an instance of the -:class:`Symfony\\Component\\Translation\\Translatable` class. This object stores +:class:`Symfony\\Component\\Translation\\TranslatableMessage` class. This object stores all the information needed to fully translate its contents when needed:: - use Symfony\Component\Translation\Translatable; + use Symfony\Component\Translation\TranslatableMessage; // the first argument is required and it's the original message - $message = new Translatable('Symfony is great!'); + $message = new TranslatableMessage('Symfony is great!'); // the optional second argument defines the translation parameters and // the optional third argument is the translation domain - $status = new Translatable('order.status', ['%status%' => $order->getStatus()], 'store'); + $status = new TranslatableMessage('order.status', ['%status%' => $order->getStatus()], 'store'); Templates are now much simpler because you can pass translatable objects to the ``trans`` filter: From 464904fa2d95fca3f3759e9c61162d1d5d2579ef Mon Sep 17 00:00:00 2001 From: Francois CONTE Date: Sat, 24 Oct 2020 22:20:51 +0200 Subject: [PATCH 590/752] [Security] Update examples of Login Link --- security/login_link.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/login_link.rst b/security/login_link.rst index 3db4f34f8eb..b92dd694178 100644 --- a/security/login_link.rst +++ b/security/login_link.rst @@ -253,7 +253,7 @@ number:: 'Welcome to MY WEBSITE!' // email subject ); // create a recipient for this user - $recipient = (new Recipient())->email($user->getEmail()); + $recipient = new Recipient($user->getEmail()); // send the notification to the user $notifier->send($notification, $recipient); @@ -620,7 +620,7 @@ user create this POST request (e.g. by clicking a button):: /** * @Route("/login_check", name="login_check") */ - public function check() + public function check(Request $request) { // get the login link query parameters $expires = $request->query->get('expires'); From 1776c69a192042c6999fafc629a88f3c5d646ad0 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sun, 25 Oct 2020 23:53:32 +0100 Subject: [PATCH 591/752] [DependencyInjection] Fix markup of configuration-block --- service_container/autowiring.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/service_container/autowiring.rst b/service_container/autowiring.rst index 4a2b606c538..e62f75f7513 100644 --- a/service_container/autowiring.rst +++ b/service_container/autowiring.rst @@ -609,7 +609,7 @@ you can use the ``@required`` annotation instead. Despite property injection has some :ref:`drawbacks `, autowiring with ``#[Required]`` or ``@required`` can also be applied to public -typed properties:: +typed properties: .. configuration-block:: From 5094d7f5e59a75b48279925822d58e16d538cb7d Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Mon, 26 Oct 2020 11:50:23 +0100 Subject: [PATCH 592/752] Fixed table margin --- messenger.rst | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/messenger.rst b/messenger.rst index 3dce638cd70..e9253431bd4 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1041,21 +1041,21 @@ under the transport in ``messenger.yaml``: =================== ===================================== ================================= Option Description Default =================== ===================================== ================================= -stream The Redis stream name messages -group The Redis consumer group name symfony -consumer Consumer name used in Redis consumer -auto_setup Create the Redis group automatically? true -auth The Redis password -delete_after_ack If ``true``, messages are deleted false - automatically after processing them -serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` - in Redis (the - ``Redis::OPT_SERIALIZER`` option) -stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") - the stream will be trimmed to. Set - it to a large enough number to - avoid losing pending messages -tls Enable TLS support for the connection false +stream The Redis stream name messages +group The Redis consumer group name symfony +consumer Consumer name used in Redis consumer +auto_setup Create the Redis group automatically? true +auth The Redis password +delete_after_ack If ``true``, messages are deleted false + automatically after processing them +serializer How to serialize the final payload ``Redis::SERIALIZER_PHP`` + in Redis (the + ``Redis::OPT_SERIALIZER`` option) +stream_max_entries The maximum number of entries which ``0`` (which means "no trimming") + the stream will be trimmed to. Set + it to a large enough number to + avoid losing pending messages +tls Enable TLS support for the connection false redeliver_timeout Timeout before retrying a pending ``3600`` message which is owned by an abandoned consumer (if a worker died From 5a36f03d309624c8dd2d251d9db5a0c666e7c7df Mon Sep 17 00:00:00 2001 From: Wouter J Date: Fri, 30 Oct 2020 10:39:54 +0100 Subject: [PATCH 593/752] Fixed code block rendering --- components/process.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/process.rst b/components/process.rst index 8664ddead85..f89935036f1 100644 --- a/components/process.rst +++ b/components/process.rst @@ -394,7 +394,7 @@ Using a Prepared Command Line You can run a process by using a prepared command line with double quote variable notation. This allows you to use placeholders so that only the -parameterized values can be changed, but not the rest of the script: +parameterized values can be changed, but not the rest of the script:: use Symfony\Component\Process\Process; From 64058aa3c6a3da18112ac9d92e638137490783c0 Mon Sep 17 00:00:00 2001 From: freezy Date: Wed, 28 Oct 2020 14:15:13 +0100 Subject: [PATCH 594/752] Mention supported hex colors --- console/coloring.rst | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/console/coloring.rst b/console/coloring.rst index 3684d71709d..913805b5cea 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -40,13 +40,22 @@ It is possible to define your own styles using the use Symfony\Component\Console\Formatter\OutputFormatterStyle; // ... - $outputStyle = new OutputFormatterStyle('red', 'yellow', ['bold', 'blink']); + $outputStyle = new OutputFormatterStyle('red', '#ff0', ['bold', 'blink']); $output->getFormatter()->setStyle('fire', $outputStyle); $output->writeln('foo'); -Available foreground and background colors are: ``black``, ``red``, ``green``, -``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``. +Any hex color is supported for foreground and background colors. Besides that, these named colors are supported: +``black``, ``red``, ``green``, ``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``. + +.. versionadded:: 5.2 + + True (hex) color support was introduced in Symfony 5.2 + +.. note:: + + If the terminal doesn't support true colors, the nearest named color is used. + E.g. ``#c0392b`` is degraded to ``red`` or ``#f1c40f`` is degraded to ``yellow``. And available options are: ``bold``, ``underscore``, ``blink``, ``reverse`` (enables the "reverse video" mode where the background and foreground colors @@ -59,6 +68,9 @@ You can also set these colors and options directly inside the tag name:: // green text $output->writeln('foo'); + // red text + $output->writeln('foo'); + // black text on a cyan background $output->writeln('foo'); From dbed899b608229706ed88b84fb36d5e7a7ba7da1 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 25 Oct 2020 16:42:30 +0100 Subject: [PATCH 595/752] [Notifier][Discord] Use correct use statements --- notifier/chatters.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index 9d03f83987c..7fe42a02f67 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -107,11 +107,11 @@ With a Discord message, you can use the :class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` to add some interactive options called `Embed elements`_:: - use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordEmbed; - use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFieldEmbedObject; - use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordFooterEmbedObject; - use Symfony\Component\Notifier\Bridge\Discord\Block\DiscordMediaEmbedObject; use Symfony\Component\Notifier\Bridge\Discord\DiscordOptions; + use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordEmbed; + use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordFieldEmbedObject; + use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordFooterEmbedObject; + use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordMediaEmbedObject; use Symfony\Component\Notifier\Message\ChatMessage; $chatMessage = new ChatMessage(''); From 447065dc4fe6fb83fd658bf4ea1bd10c65821d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 4 Nov 2020 10:03:11 +0100 Subject: [PATCH 596/752] Add documentation about GetQueueUrl and DSN format in SQS transport --- messenger.rst | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/messenger.rst b/messenger.rst index 6c2f2e35794..2e41a0ca86f 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1300,7 +1300,7 @@ Amazon SQS .. versionadded:: 5.1 - The Amazon SQS transport as introduced in Symfony 5.1. + The Amazon SQS transport has been introduced in Symfony 5.1. The Amazon SQS transport is perfect for application hosted on AWS. Install it by running: @@ -1314,7 +1314,7 @@ The SQS transport DSN may looks like this: .. code-block:: env # .env - MESSENGER_TRANSPORT_DSN=sqs://AKIAIOSFODNN7EXAMPLE:j17M97ffSVoKI0briFoo9a@sqs.eu-west-3.amazonaws.com/messages + MESSENGER_TRANSPORT_DSN=https://AKIAIOSFODNN7EXAMPLE:j17M97ffSVoKI0briFoo9a@sqs.eu-west-3.amazonaws.com/123456789012/messages MESSENGER_TRANSPORT_DSN=sqs://localhost:9494/messages?sslmode=disable .. note:: @@ -1322,6 +1322,17 @@ The SQS transport DSN may looks like this: The transport will automatically create queues that are needed. This can be disabled setting the ``auto_setup`` option to ``false``. +.. tip:: + + Before sending or receiving a message, Symfony needs to convert the queue + name into an AWS queue URL by calling the ``GetQueueUrl`` API in AWS. This + extra API call can be avoided by providing a DSN which is the queue URL. + +.. versionadded:: 5.2 + + Providing a DSN equals to the queue URL to avoid call to ``GetQueueUrl`` + has been introduced in Symfony 5.2. + The transport has a number of options: ====================== ====================================== =================================== From 2a48c4410f659638d42c51c0e8388cfe7a177030 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 5 Nov 2020 10:26:53 +0100 Subject: [PATCH 597/752] Tweaks --- messenger.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/messenger.rst b/messenger.rst index 2e41a0ca86f..ac07b40c624 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1300,7 +1300,7 @@ Amazon SQS .. versionadded:: 5.1 - The Amazon SQS transport has been introduced in Symfony 5.1. + The Amazon SQS transport was introduced in Symfony 5.1. The Amazon SQS transport is perfect for application hosted on AWS. Install it by running: @@ -1328,10 +1328,9 @@ The SQS transport DSN may looks like this: name into an AWS queue URL by calling the ``GetQueueUrl`` API in AWS. This extra API call can be avoided by providing a DSN which is the queue URL. -.. versionadded:: 5.2 + .. versionadded:: 5.2 - Providing a DSN equals to the queue URL to avoid call to ``GetQueueUrl`` - has been introduced in Symfony 5.2. + The feature to provide the queue URL in the DSN was introduced in Symfony 5.2. The transport has a number of options: From 4bdab6fb8fc7f06eb05b3c5141a1ed415b1b035c Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Sun, 3 May 2020 21:36:09 +0200 Subject: [PATCH 598/752] Add wither behavior with PHP8 static return type --- service_container/calls.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/service_container/calls.rst b/service_container/calls.rst index 11dea241613..8496caa724a 100644 --- a/service_container/calls.rst +++ b/service_container/calls.rst @@ -90,9 +90,6 @@ instead of mutating the object they were called on:: { private $logger; - /** - * @return static - */ public function withLogger(LoggerInterface $logger) { $new = clone $this; @@ -146,3 +143,19 @@ The configuration to tell the container it should do so would be like: $container->register(MessageGenerator::class) ->addMethodCall('withLogger', [new Reference('logger')], true); + +If autowire is enabled, you can also use annotations; with the previous exemple it would be:: + + /** + * @required + * @return static + */ + public function withLogger(LoggerInterface $logger) + { + $new = clone $this; + $new->logger = $logger; + + return $new; + } + +You can also leverage the PHP8 ``static`` return type instead of the ``@return static`` annotation. Note if you don't want a method with a PHP8 ``static`` return type and a ``@required`` annotation to behave as a wither, you can add a ``@return $this`` annotation to disable the *returns clone* feature. From 281d758f331081bf27e6046958169474b5bff53c Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Thu, 5 Nov 2020 16:12:49 +0100 Subject: [PATCH 599/752] [#13619] Moved text into a note and added versionadded --- service_container/calls.rst | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/service_container/calls.rst b/service_container/calls.rst index 8496caa724a..7f12a38ac4c 100644 --- a/service_container/calls.rst +++ b/service_container/calls.rst @@ -144,18 +144,30 @@ The configuration to tell the container it should do so would be like: $container->register(MessageGenerator::class) ->addMethodCall('withLogger', [new Reference('logger')], true); -If autowire is enabled, you can also use annotations; with the previous exemple it would be:: +.. tip:: - /** - * @required - * @return static - */ - public function withLogger(LoggerInterface $logger) - { - $new = clone $this; - $new->logger = $logger; + If autowire is enabled, you can also use annotations; with the previous + example it would be:: - return $new; - } + /** + * @required + * @return static + */ + public function withLogger(LoggerInterface $logger) + { + $new = clone $this; + $new->logger = $logger; + + return $new; + } + + You can also leverage the PHP 8 ``static`` return type instead of the + ``@return static`` annotation. If you don't want a method with a + PHP 8 ``static`` return type and a ``@required`` annotation to behave as + a wither, you can add a ``@return $this`` annotation to disable the + *returns clone* feature. + + .. versionadded:: 5.1 -You can also leverage the PHP8 ``static`` return type instead of the ``@return static`` annotation. Note if you don't want a method with a PHP8 ``static`` return type and a ``@required`` annotation to behave as a wither, you can add a ``@return $this`` annotation to disable the *returns clone* feature. + Support for the PHP 8 ``static`` return type was introduced in + Symfony 5.1. From adf1978d322bcf2977cdc7c5c8ce01a4b5402886 Mon Sep 17 00:00:00 2001 From: Maarten de Keizer Date: Sun, 8 Nov 2020 10:08:32 +0100 Subject: [PATCH 600/752] Correct case of suffix in example rate limiter The suffix should be with an uppercase (`limiter` -> `Limiter) --- rate_limiter.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 22a56168498..f5473607fe7 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -129,7 +129,7 @@ the number of requests to the API:: class ApiController extends AbstractController { // if you're using service autowiring, the variable name must be: - // "rate limiter name" (in camelCase) + "limiter" suffix + // "rate limiter name" (in camelCase) + "Limiter" suffix public function index(RateLimiterFactory $anonymousApiLimiter) { // create a limiter based on a unique identifier of the client From bdbd7a697ea722e4a5e076b590d52e4472f06521 Mon Sep 17 00:00:00 2001 From: Yoann Chocteau Date: Mon, 9 Nov 2020 09:28:21 +0100 Subject: [PATCH 601/752] Update simple-example.rst Just a little typo, now we use ./styles and not ../css --- frontend/encore/simple-example.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/encore/simple-example.rst b/frontend/encore/simple-example.rst index 3d38686ce05..d0ed86a5922 100644 --- a/frontend/encore/simple-example.rst +++ b/frontend/encore/simple-example.rst @@ -17,7 +17,7 @@ application: it will *require* all of the dependencies it needs (e.g. jQuery or // assets/app.js // ... - import '../css/app.css'; + import './styles/app.css'; // var $ = require('jquery'); From cca746686382f80f3a9307915d92669e9c3c6d5e Mon Sep 17 00:00:00 2001 From: Romain Monteil Date: Thu, 5 Nov 2020 15:18:19 +0100 Subject: [PATCH 602/752] [Encore] Fix CSS path --- frontend/encore/installation.rst | 2 +- frontend/encore/simple-example.rst | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/frontend/encore/installation.rst b/frontend/encore/installation.rst index 8241dbcd0b2..bbd6469a1c3 100644 --- a/frontend/encore/installation.rst +++ b/frontend/encore/installation.rst @@ -143,7 +143,7 @@ Next, open the new ``assets/app.js`` file which contains some JavaScript code */ // any CSS you import will output into a single css file (app.css in this case) - import '../css/app.css'; + import './styles/app.css'; // Need jQuery? Install it with "yarn add jquery", then uncomment to import it. // import $ from 'jquery'; diff --git a/frontend/encore/simple-example.rst b/frontend/encore/simple-example.rst index d0ed86a5922..23c215b1105 100644 --- a/frontend/encore/simple-example.rst +++ b/frontend/encore/simple-example.rst @@ -19,7 +19,7 @@ application: it will *require* all of the dependencies it needs (e.g. jQuery or import './styles/app.css'; - // var $ = require('jquery'); + // import $ from 'jquery'; Encore's job (via Webpack) is simple: to read and follow *all* of the ``require()`` statements and create one final ``app.js`` (and ``app.css``) that contains *everything* @@ -204,8 +204,8 @@ To import values, use ``import``: .. code-block:: diff // assets/app.js - - require('../css/app.css'); - + import '../css/app.css'; + - require('../styles/app.css'); + + import './styles/app.css'; - var $ = require('jquery'); + import $ from 'jquery'; @@ -292,8 +292,8 @@ file to ``app.scss`` and update the ``import`` statement: .. code-block:: diff // assets/app.js - - import '../css/app.css'; - + import '../css/app.scss'; + - import './styles/app.css'; + + import './styles/app.scss'; Then, tell Encore to enable the Sass pre-processor: From 2c0cad0155fe7ec66b5f853388e40d6acb149b22 Mon Sep 17 00:00:00 2001 From: Youssef Benhssaien Date: Wed, 11 Nov 2020 08:34:42 +0100 Subject: [PATCH 603/752] Use int type instead integer Uses the same type hint `int` for all the page Used in `optimizations` config --- reference/configuration/twig.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index e00d7f63958..055568b1f2e 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -269,7 +269,7 @@ every ``number_format`` filter call. decimals ........ -**type**: ``integer`` **default**: ``0`` +**type**: ``int`` **default**: ``0`` The number of decimals used to format numeric values when no specific number is passed as argument to the ``number_format`` filter. From 71b3d30cbc50f750479a4afce29148cb6f64f90e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 12 Nov 2020 10:00:04 +0100 Subject: [PATCH 604/752] Minor: Fix namespace --- mailer.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index a932050c049..dffbd25b3ed 100644 --- a/mailer.rst +++ b/mailer.rst @@ -605,7 +605,7 @@ arguments to the filter: .. code-block:: html+twig - {% apply inline_css(source('@css/email.css')) %} + {% apply inline_css(source('@styles/email.css')) %}

Welcome {{ username }}!

{# ... #} {% endapply %} From fc220753a708416e2f007f9317bae266b0ffee2e Mon Sep 17 00:00:00 2001 From: Youssef Benhssaien Date: Thu, 12 Nov 2020 12:04:48 +0100 Subject: [PATCH 605/752] Use integer typehint instead int --- reference/configuration/twig.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index 055568b1f2e..100d168b792 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -269,7 +269,7 @@ every ``number_format`` filter call. decimals ........ -**type**: ``int`` **default**: ``0`` +**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. @@ -294,7 +294,7 @@ no specific character is passed as argument to the ``number_format`` filter. optimizations ~~~~~~~~~~~~~ -**type**: ``int`` **default**: ``-1`` +**type**: ``integer`` **default**: ``-1`` Twig includes an extension called ``optimizer`` which is enabled by default in Symfony applications. This extension analyzes the templates to optimize them From 120290daedd1f928c7c78d781d3911f4d754a60f Mon Sep 17 00:00:00 2001 From: Youssef BENHSSAIEN Date: Thu, 12 Nov 2020 14:16:44 +0100 Subject: [PATCH 606/752] Replace bool by boolean --- reference/configuration/framework.rst | 4 ++-- reference/constraints/AtLeastOneOf.rst | 2 +- reference/constraints/Hostname.rst | 2 +- reference/constraints/NotBlank.rst | 2 +- reference/constraints/Traverse.rst | 2 +- reference/forms/types/color.rst | 2 +- reference/forms/types/options/help_html.rst.inc | 2 +- reference/forms/types/options/label_html.rst.inc | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index d4058e76c82..c353f73f163 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -801,7 +801,7 @@ outgoing network interface. buffer ...... -**type**: ``bool`` | ``Closure`` +**type**: ``boolean`` | ``Closure`` Buffering the response means that you can access its content multiple times without performing the request again. Buffering is enabled by default when the @@ -2851,7 +2851,7 @@ Name of the workflow you want to create. audit_trail """"""""""" -**type**: ``bool`` +**type**: ``boolean`` If set to ``true``, the :class:`Symfony\\Component\\Workflow\\EventListener\\AuditTrailListener` will be enabled. diff --git a/reference/constraints/AtLeastOneOf.rst b/reference/constraints/AtLeastOneOf.rst index 6a48c44a4fd..b69894184d6 100644 --- a/reference/constraints/AtLeastOneOf.rst +++ b/reference/constraints/AtLeastOneOf.rst @@ -163,7 +163,7 @@ has to be satisfied in order for the validation to succeed. includeInternalMessages ~~~~~~~~~~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` If set to ``true``, the message that is shown if the validation fails, will include the list of messages for the internal constraints. See option diff --git a/reference/constraints/Hostname.rst b/reference/constraints/Hostname.rst index 4cbe606ccb4..a08425f5fa2 100644 --- a/reference/constraints/Hostname.rst +++ b/reference/constraints/Hostname.rst @@ -117,7 +117,7 @@ Parameter Description ``requireTld`` ~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` By default, hostnames are considered valid only when they are fully qualified and include their TLDs (top-level domain names). For instance, ``example.com`` diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index c3c16f21eae..a87b8696824 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -85,7 +85,7 @@ Options allowNull ~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` If set to ``true``, ``null`` values are considered valid and won't trigger a constraint violation. diff --git a/reference/constraints/Traverse.rst b/reference/constraints/Traverse.rst index 852f17cdd01..aea7e051ee1 100644 --- a/reference/constraints/Traverse.rst +++ b/reference/constraints/Traverse.rst @@ -146,7 +146,7 @@ The ``groups`` option is not available for this constraint. ``traverse`` ~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` Instances of ``\Traversable`` are traversed by default, use this option to disable validating: diff --git a/reference/forms/types/color.rst b/reference/forms/types/color.rst index a290b31e673..5dfd61915ce 100644 --- a/reference/forms/types/color.rst +++ b/reference/forms/types/color.rst @@ -49,7 +49,7 @@ Field Options html5 ~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` .. versionadded:: 5.1 diff --git a/reference/forms/types/options/help_html.rst.inc b/reference/forms/types/options/help_html.rst.inc index 83bbe583ca6..2a5dccfb32e 100644 --- a/reference/forms/types/options/help_html.rst.inc +++ b/reference/forms/types/options/help_html.rst.inc @@ -1,7 +1,7 @@ help_html ~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` By default, the contents of the ``help`` option are escaped before rendering them in the template. Set this option to ``true`` to not escape them, which is diff --git a/reference/forms/types/options/label_html.rst.inc b/reference/forms/types/options/label_html.rst.inc index 06568ed08f4..a87ad4ab6db 100644 --- a/reference/forms/types/options/label_html.rst.inc +++ b/reference/forms/types/options/label_html.rst.inc @@ -1,7 +1,7 @@ ``label_html`` ~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` .. versionadded:: 5.1 From df7682967fc887e516779ea015b4787728f69d6e Mon Sep 17 00:00:00 2001 From: Youssef Benhssaien Date: Wed, 11 Nov 2020 08:34:42 +0100 Subject: [PATCH 607/752] Use integer type instead of int & boolean instead of bool --- reference/configuration/framework.rst | 4 ++-- reference/configuration/twig.rst | 2 +- reference/constraints/AtLeastOneOf.rst | 2 +- reference/constraints/Hostname.rst | 2 +- reference/constraints/NotBlank.rst | 2 +- reference/constraints/Traverse.rst | 2 +- reference/forms/types/color.rst | 2 +- reference/forms/types/options/help_html.rst.inc | 2 +- reference/forms/types/options/label_html.rst.inc | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index d4058e76c82..c353f73f163 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -801,7 +801,7 @@ outgoing network interface. buffer ...... -**type**: ``bool`` | ``Closure`` +**type**: ``boolean`` | ``Closure`` Buffering the response means that you can access its content multiple times without performing the request again. Buffering is enabled by default when the @@ -2851,7 +2851,7 @@ Name of the workflow you want to create. audit_trail """"""""""" -**type**: ``bool`` +**type**: ``boolean`` If set to ``true``, the :class:`Symfony\\Component\\Workflow\\EventListener\\AuditTrailListener` will be enabled. diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index e00d7f63958..100d168b792 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -294,7 +294,7 @@ no specific character is passed as argument to the ``number_format`` filter. optimizations ~~~~~~~~~~~~~ -**type**: ``int`` **default**: ``-1`` +**type**: ``integer`` **default**: ``-1`` Twig includes an extension called ``optimizer`` which is enabled by default in Symfony applications. This extension analyzes the templates to optimize them diff --git a/reference/constraints/AtLeastOneOf.rst b/reference/constraints/AtLeastOneOf.rst index 6a48c44a4fd..b69894184d6 100644 --- a/reference/constraints/AtLeastOneOf.rst +++ b/reference/constraints/AtLeastOneOf.rst @@ -163,7 +163,7 @@ has to be satisfied in order for the validation to succeed. includeInternalMessages ~~~~~~~~~~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` If set to ``true``, the message that is shown if the validation fails, will include the list of messages for the internal constraints. See option diff --git a/reference/constraints/Hostname.rst b/reference/constraints/Hostname.rst index 4cbe606ccb4..a08425f5fa2 100644 --- a/reference/constraints/Hostname.rst +++ b/reference/constraints/Hostname.rst @@ -117,7 +117,7 @@ Parameter Description ``requireTld`` ~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` By default, hostnames are considered valid only when they are fully qualified and include their TLDs (top-level domain names). For instance, ``example.com`` diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index c3c16f21eae..a87b8696824 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -85,7 +85,7 @@ Options allowNull ~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` If set to ``true``, ``null`` values are considered valid and won't trigger a constraint violation. diff --git a/reference/constraints/Traverse.rst b/reference/constraints/Traverse.rst index 852f17cdd01..aea7e051ee1 100644 --- a/reference/constraints/Traverse.rst +++ b/reference/constraints/Traverse.rst @@ -146,7 +146,7 @@ The ``groups`` option is not available for this constraint. ``traverse`` ~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``true`` +**type**: ``boolean`` **default**: ``true`` Instances of ``\Traversable`` are traversed by default, use this option to disable validating: diff --git a/reference/forms/types/color.rst b/reference/forms/types/color.rst index a290b31e673..5dfd61915ce 100644 --- a/reference/forms/types/color.rst +++ b/reference/forms/types/color.rst @@ -49,7 +49,7 @@ Field Options html5 ~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` .. versionadded:: 5.1 diff --git a/reference/forms/types/options/help_html.rst.inc b/reference/forms/types/options/help_html.rst.inc index 83bbe583ca6..2a5dccfb32e 100644 --- a/reference/forms/types/options/help_html.rst.inc +++ b/reference/forms/types/options/help_html.rst.inc @@ -1,7 +1,7 @@ help_html ~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` By default, the contents of the ``help`` option are escaped before rendering them in the template. Set this option to ``true`` to not escape them, which is diff --git a/reference/forms/types/options/label_html.rst.inc b/reference/forms/types/options/label_html.rst.inc index 06568ed08f4..a87ad4ab6db 100644 --- a/reference/forms/types/options/label_html.rst.inc +++ b/reference/forms/types/options/label_html.rst.inc @@ -1,7 +1,7 @@ ``label_html`` ~~~~~~~~~~~~~~ -**type**: ``bool`` **default**: ``false`` +**type**: ``boolean`` **default**: ``false`` .. versionadded:: 5.1 From b781296cf0e084b00ee8f4f4aee78c7604c60099 Mon Sep 17 00:00:00 2001 From: wkania <57155526+wkania@users.noreply.github.com> Date: Sat, 14 Nov 2020 15:27:25 +0100 Subject: [PATCH 608/752] [Validator] Fix ExpressionLanguageSyntax example --- reference/constraints/ExpressionLanguageSyntax.rst | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/reference/constraints/ExpressionLanguageSyntax.rst b/reference/constraints/ExpressionLanguageSyntax.rst index 2ca0355dfaf..18c465e8a9d 100644 --- a/reference/constraints/ExpressionLanguageSyntax.rst +++ b/reference/constraints/ExpressionLanguageSyntax.rst @@ -40,13 +40,13 @@ The following constraints ensure that: class Order { /** - * @Assert\ExpressionLanguageSyntax() + * @Assert\ExpressionLanguageSyntax */ protected $promotion; /** * @Assert\ExpressionLanguageSyntax( - * allowedVariables = ['user', 'shipping_centers'] + * allowedVariables={"user", "shipping_centers"} * ) */ protected $shippingOptions; @@ -77,7 +77,10 @@ The following constraints ensure that: - + From 3a439bddc1646c482f3f6f78894391c0153199da Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Mon, 16 Nov 2020 00:02:25 +0100 Subject: [PATCH 609/752] [#14011] Documented the NullToken usage --- security/experimental_authenticators.rst | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index d0813795b12..45c0edb882d 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -135,6 +135,42 @@ unauthenticated access (e.g. the login page): ], ]); +Granting Anonymous Users Access in a Custom Voter +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + The ``NullToken`` class was introduced in Symfony 5.2. + +If you're using a :doc:`custom voter `, you can allow +anonymous users access by checking for a special +:class:`Symfony\\Component\\Security\\Core\\Authentication\\Token\\NullToken`. This token is used +in the voters to represent the unauthenticated access:: + + // src/Security/PostVoter.php + namespace App\Security; + + // ... + use Symfony\Component\Security\Core\Authentication\Token\NullToken; + use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + use Symfony\Component\Security\Core\Authorization\Voter\Voter; + + class PostVoter extends Voter + { + // ... + + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool + { + // ... + + if ($token instanceof NullToken) { + // the user is not authenticated, e.g. only allow them to + // see public posts + return $subject->isPublic(); + } + } + } + .. _authenticators-required-entry-point: Configuring the Authentication Entry Point From 0eae59cf1d7b3c8a02d6610127ea89115dd628dd Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Mon, 16 Nov 2020 00:12:03 +0100 Subject: [PATCH 610/752] Documented passport attributes --- security/experimental_authenticators.rst | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index d0813795b12..0a713e6b0ca 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -502,3 +502,40 @@ authenticator, you would initialize the passport like this:: ]); } } + +.. tip:: + + Besides badges, passports can define attributes, which allows the + ``authenticate()`` method to store arbitrary information in the + passport to access it from other authenticator methods (e.g. + ``createAuthenticatedToken()``):: + + // ... + use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + + class LoginAuthenticator extends AbstractAuthenticator + { + // ... + + public function authenticate(Request $request): PassportInterface + { + // ... process the request + + $passport = new SelfValidatingPassport($username, []); + + // set a custom attribute (e.g. scope) + $passport->setAttribute('scope', $oauthScope); + + return $passport; + } + + public function createAuthenticatedToken(PassportInterface $passport, string $firewallName): TokenInterface + { + // read the attribute value + return new CustomOauthToken($passport->getUser(), $passport->getAttribute('scope')); + } + } + +.. versionadded:: 5.2 + + Passport attributes were introduced in Symfony 5.2. From e5918146ca5fbd2d54a88965d0df26bd6880a49c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 4 Nov 2020 10:18:54 +0100 Subject: [PATCH 611/752] Remove deprecated HEADER_X_FORWARDED_ALL header --- deployment/proxies.rst | 12 ++++++++++-- migration.rst | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 12bf3f1cac1..a7e0aff99b2 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -35,15 +35,22 @@ and what headers your reverse proxy uses to send information:: ['192.0.0.1', '10.0.0.0/8'], // trust *all* "X-Forwarded-*" headers - Request::HEADER_X_FORWARDED_ALL + Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO // or, if your proxy instead uses the "Forwarded" header // Request::HEADER_FORWARDED - // or, if you're using AWS ELB + // or, if you're using a wellknown proxy // Request::HEADER_X_FORWARDED_AWS_ELB + // Request::HEADER_X_FORWARDED_TRAEFIK ); +.. caution:: + + Enabling the ``Request::HEADER_X_FORWARDED_HOST`` option exposes the + application to "`HTTP Host header attacks`_". Make sure the proxy really + send a ``x-forwarded-host`` header. + The Request object has several ``Request::HEADER_*`` constants that control exactly *which* headers from your reverse proxy are trusted. The argument is a bit field, so you can also pass your own value (e.g. ``0b00110``). @@ -114,3 +121,4 @@ In this case, you'll need to set the header ``X-Forwarded-Proto`` with the value .. _`security groups`: https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-security-groups.html .. _`CloudFront`: https://en.wikipedia.org/wiki/Amazon_CloudFront .. _`CloudFront IP ranges`: https://ip-ranges.amazonaws.com/ip-ranges.json +.. _`HTTP Host header attacks`: https://www.skeletonscribe.net/2013/05/practical-http-host-header-attacks.html diff --git a/migration.rst b/migration.rst index fa8c2bfc24b..5c786c103b9 100644 --- a/migration.rst +++ b/migration.rst @@ -262,7 +262,7 @@ could look something like this:: if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) { Request::setTrustedProxies( explode(',', $trustedProxies), - Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST + Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO ); } From 42c1ca4fe901ec3e7339f13b00ac7764f8dfada9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 18 Nov 2020 10:54:34 +0100 Subject: [PATCH 612/752] Added a deprecation notice --- deployment/proxies.rst | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index a7e0aff99b2..81c1f5c7826 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -40,16 +40,22 @@ and what headers your reverse proxy uses to send information:: // or, if your proxy instead uses the "Forwarded" header // Request::HEADER_FORWARDED - // or, if you're using a wellknown proxy + // or, if you're using a well-known proxy // Request::HEADER_X_FORWARDED_AWS_ELB // Request::HEADER_X_FORWARDED_TRAEFIK ); +.. deprecated:: 5.2 + + In previous Symfony versions, the above example used ``HEADER_X_FORWARDED_ALL`` + to trust all "X-Forwarded-*" headers, but that constant is deprecated since + Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_*`` constants. + .. caution:: Enabling the ``Request::HEADER_X_FORWARDED_HOST`` option exposes the - application to "`HTTP Host header attacks`_". Make sure the proxy really - send a ``x-forwarded-host`` header. + application to `HTTP Host header attacks`_. Make sure the proxy really + sends an ``x-forwarded-host`` header. The Request object has several ``Request::HEADER_*`` constants that control exactly *which* headers from your reverse proxy are trusted. The argument is a bit field, From 163c6941e9b8cc0cc7fd2721e34b4445b86c5554 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 18 Nov 2020 11:27:44 +0100 Subject: [PATCH 613/752] Fixed a RST syntax issue --- deployment/proxies.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 81c1f5c7826..cae9e285648 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -48,7 +48,7 @@ and what headers your reverse proxy uses to send information:: .. deprecated:: 5.2 In previous Symfony versions, the above example used ``HEADER_X_FORWARDED_ALL`` - to trust all "X-Forwarded-*" headers, but that constant is deprecated since + to trust all "X-Forwarded-" headers, but that constant is deprecated since Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_*`` constants. .. caution:: From 50f3ece07c22e16326616b0b420880d154bea37b Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Wed, 18 Nov 2020 17:03:01 +0100 Subject: [PATCH 614/752] Add little tip about PHPdocs --- messenger/multiple_buses.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/messenger/multiple_buses.rst b/messenger/multiple_buses.rst index 5136553dac2..6191bc0556c 100644 --- a/messenger/multiple_buses.rst +++ b/messenger/multiple_buses.rst @@ -249,4 +249,9 @@ You can also restrict the list to a specific bus by providing its name as argume handled by App\MessageHandler\MultipleBusesMessageHandler --------------------------------------------------------------------------------------- +.. tip:: + + Since Symfony 5.1, the command will also show the PHPDoc description of + the message and handler classes. + .. _article about CQRS: https://martinfowler.com/bliki/CQRS.html From 74de492ada02ece7221a55390825e013e3dedf42 Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Thu, 19 Nov 2020 09:23:27 +0100 Subject: [PATCH 615/752] Fix strict_variables default value since Symfony 5 The default was changed in https://github.com/symfony/symfony/blob/494ef421c554a78b38c6779c4b7deb9a20d89923/UPGRADE-5.0.md#twigbundle --- reference/configuration/twig.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/twig.rst b/reference/configuration/twig.rst index c7d77739b1c..5d5edd1d43c 100644 --- a/reference/configuration/twig.rst +++ b/reference/configuration/twig.rst @@ -363,7 +363,7 @@ Read more about :ref:`template directories and namespaces strict_variables ~~~~~~~~~~~~~~~~ -**type**: ``boolean`` **default**: ``false`` +**type**: ``boolean`` **default**: ``%kernel.debug%`` If set to ``true``, Symfony shows an exception whenever a Twig variable, attribute or method doesn't exist. If set to ``false`` these errors are ignored From 649a63397f9dc404294a037ef41deb48e92f3872 Mon Sep 17 00:00:00 2001 From: Timo Bakx Date: Fri, 20 Nov 2020 00:34:27 +0100 Subject: [PATCH 616/752] [Form] Documented legacy_error_messages --- forms.rst | 43 ++++++++++ reference/forms/types/birthday.rst | 86 ++++++++++---------- reference/forms/types/checkbox.rst | 63 ++++++++------- reference/forms/types/choice.rst | 99 ++++++++++++----------- reference/forms/types/collection.rst | 73 +++++++++-------- reference/forms/types/color.rst | 63 +++++++++------ reference/forms/types/country.rst | 85 +++++++++++--------- reference/forms/types/currency.rst | 81 ++++++++++--------- reference/forms/types/date.rst | 88 ++++++++++---------- reference/forms/types/dateinterval.rst | 94 ++++++++++++---------- reference/forms/types/datetime.rst | 106 +++++++++++++------------ reference/forms/types/email.rst | 59 ++++++++------ reference/forms/types/file.rst | 64 ++++++++------- reference/forms/types/form.rst | 94 +++++++++++----------- reference/forms/types/hidden.rst | 45 ++++++----- reference/forms/types/integer.rst | 69 ++++++++-------- reference/forms/types/language.rst | 87 ++++++++++---------- reference/forms/types/locale.rst | 83 ++++++++++--------- reference/forms/types/money.rst | 77 +++++++++--------- reference/forms/types/number.rst | 75 ++++++++--------- reference/forms/types/password.rst | 60 +++++++------- reference/forms/types/percent.rst | 75 ++++++++--------- reference/forms/types/radio.rst | 69 +++++++++------- reference/forms/types/range.rst | 57 +++++++------ reference/forms/types/repeated.rst | 63 ++++++++------- reference/forms/types/search.rst | 57 +++++++------ reference/forms/types/tel.rst | 59 ++++++++------ reference/forms/types/time.rst | 92 +++++++++++---------- reference/forms/types/timezone.rst | 85 +++++++++++--------- reference/forms/types/url.rst | 63 +++++++++------ reference/forms/types/week.rst | 74 +++++++++-------- 31 files changed, 1269 insertions(+), 1019 deletions(-) diff --git a/forms.rst b/forms.rst index ec5a04fcfc1..6e2c9ec5120 100644 --- a/forms.rst +++ b/forms.rst @@ -553,6 +553,49 @@ To see the second approach - adding constraints to the form - and to learn more about the validation constraints, please refer to the :doc:`Symfony validation documentation `. +.. versionadded:: 5.2 + + Validation messages for forms have been rewritten to be more user-friendly. + These newer messages can be enabled by setting the `legacy_error_messages` + option to "false". Details about these messages can be found in the corresponding + form type documentation. + + .. configuration-block:: + + .. code-block:: yaml + + # config/packages/framework.yaml + framework: + form: + legacy_error_messages: false + + .. code-block:: xml + + + + + + + + + + + .. code-block:: php + + // config/packages/framework.php + $container->loadFromExtension('framework', [ + 'form' => [ + 'legacy-error-messages' => false, + ], + ]); + + Other Common Form Features -------------------------- diff --git a/reference/forms/types/birthday.rst b/reference/forms/types/birthday.rst index 6299dbf1e09..127528bc774 100644 --- a/reference/forms/types/birthday.rst +++ b/reference/forms/types/birthday.rst @@ -14,51 +14,57 @@ This type is essentially the same as the :doc:`DateType `) | -+----------------------+-------------------------------------------------------------------------------+ -| Rendered as | can be three select boxes or 1 or 3 text boxes, based on the `widget`_ option | -+----------------------+-------------------------------------------------------------------------------+ -| Overridden options | - `years`_ | -+----------------------+-------------------------------------------------------------------------------+ -| Inherited options | from the :doc:`DateType `: | -| | | -| | - `choice_translation_domain`_ | -| | - `days`_ | -| | - `placeholder`_ | -| | - `format`_ | -| | - `input`_ | -| | - `input_format`_ | -| | - `model_timezone`_ | -| | - `months`_ | -| | - `view_timezone`_ | -| | - `widget`_ | -| | | -| | from the :doc:`FormType `: | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+-------------------------------------------------------------------------------+ -| Parent type | :doc:`DateType ` | -+----------------------+-------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` | -+----------------------+-------------------------------------------------------------------------------+ ++---------------------------+-------------------------------------------------------------------------------+ +| Underlying Data Type | can be ``DateTime``, ``string``, ``timestamp``, or ``array`` | +| | (see the :ref:`input option `) | ++---------------------------+-------------------------------------------------------------------------------+ +| Rendered as | can be three select boxes or 1 or 3 text boxes, based on the `widget`_ option | ++---------------------------+-------------------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | +| | - `years`_ | ++---------------------------+-------------------------------------------------------------------------------+ +| Inherited options | from the :doc:`DateType `: | +| | | +| | - `choice_translation_domain`_ | +| | - `days`_ | +| | - `placeholder`_ | +| | - `format`_ | +| | - `input`_ | +| | - `input_format`_ | +| | - `model_timezone`_ | +| | - `months`_ | +| | - `view_timezone`_ | +| | - `widget`_ | +| | | +| | from the :doc:`FormType `: | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+-------------------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid birthdate. | ++---------------------------+-------------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-------------------------------------------------------------------------------+ +| Parent type | :doc:`DateType ` | ++---------------------------+-------------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\BirthdayType` | ++---------------------------+-------------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc Overridden Options ------------------ +.. include:: /reference/forms/types/options/invalid_message.rst.inc + ``years`` ~~~~~~~~~ @@ -128,8 +134,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index aef03ef1e44..1463c542a1e 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -11,34 +11,39 @@ you can specify an array of values that, if submitted, will be evaluated to "false" as well (this differs from what HTTP defines, but can be handy if you want to handle submitted values like "0" or "false"). -+-------------+------------------------------------------------------------------------+ -| Rendered as | ``input`` ``checkbox`` field | -+-------------+------------------------------------------------------------------------+ -| Options | - `false_values`_ | -| | - `value`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | - `empty_data`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | ``input`` ``checkbox`` field | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `false_values`_ | +| | - `value`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `empty_data`_ | +| | - `invalid_message`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | The checkbox has an invalid value. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CheckboxType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -74,6 +79,8 @@ Overridden Options .. include:: /reference/forms/types/options/checkbox_empty_data.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index 04efd2fe02c..d0c81a829bd 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -9,52 +9,57 @@ It can be rendered as a ``select`` tag, radio buttons, or checkboxes. To use this field, you must specify *either* ``choices`` or ``choice_loader`` option. -+-------------+------------------------------------------------------------------------------+ -| Rendered as | can be various tags (see below) | -+-------------+------------------------------------------------------------------------------+ -| Options | - `choices`_ | -| | - `choice_attr`_ | -| | - `choice_filter`_ | -| | - `choice_label`_ | -| | - `choice_loader`_ | -| | - `choice_name`_ | -| | - `choice_translation_domain`_ | -| | - `choice_value`_ | -| | - `expanded`_ | -| | - `group_by`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -+-------------+------------------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `trim`_ | -+-------------+------------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `by_reference`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `translation_domain`_ | -| | - `label_translation_parameters`_ | -| | - `attr_translation_parameters`_ | -| | - `help_translation_parameters`_ | -+-------------+------------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType` | -+-------------+------------------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------+ +| Rendered as | can be various tags (see below) | ++---------------------------+----------------------------------------------------------------------+ +| Options | - `choices`_ | +| | - `choice_attr`_ | +| | - `choice_filter`_ | +| | - `choice_label`_ | +| | - `choice_loader`_ | +| | - `choice_name`_ | +| | - `choice_translation_domain`_ | +| | - `choice_value`_ | +| | - `expanded`_ | +| | - `group_by`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | ++---------------------------+----------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `trim`_ | +| | - `invalid_message`_ | ++---------------------------+----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `by_reference`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `translation_domain`_ | +| | - `label_translation_parameters`_ | +| | - `attr_translation_parameters`_ | +| | - `help_translation_parameters`_ | ++---------------------------+----------------------------------------------------------------------+ +| Default `invalid_message` | The selected choice is invalid. | ++---------------------------+----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ChoiceType` | ++---------------------------+----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -272,6 +277,8 @@ the parent field (the form in most cases). .. include:: /reference/forms/types/options/choice_type_trim.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index f3f0c8f4562..a30cc250f6f 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -11,37 +11,43 @@ forms, which is useful when creating forms that expose one-to-many relationships (e.g. a product from where you can manage many related product photos). -+-------------+-----------------------------------------------------------------------------+ -| Rendered as | depends on the `entry_type`_ option | -+-------------+-----------------------------------------------------------------------------+ -| Options | - `allow_add`_ | -| | - `allow_delete`_ | -| | - `delete_empty`_ | -| | - `entry_options`_ | -| | - `entry_type`_ | -| | - `prototype`_ | -| | - `prototype_data`_ | -| | - `prototype_name`_ | -+-------------+-----------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `by_reference`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType` | -+-------------+-----------------------------------------------------------------------------+ ++---------------------------+--------------------------------------------------------------------------+ +| Rendered as | depends on the `entry_type`_ option | ++---------------------------+--------------------------------------------------------------------------+ +| Options | - `allow_add`_ | +| | - `allow_delete`_ | +| | - `delete_empty`_ | +| | - `entry_options`_ | +| | - `entry_type`_ | +| | - `prototype`_ | +| | - `prototype_data`_ | +| | - `prototype_name`_ | ++---------------------------+--------------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+--------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `by_reference`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+--------------------------------------------------------------------------+ +| Default `invalid_message` | The collection is invalid. | ++---------------------------+--------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+--------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+--------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType` | ++---------------------------+--------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -396,6 +402,11 @@ If you have several collections in your form, or worse, nested collections you may want to change the placeholder so that unrelated placeholders are not replaced with the same value. +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/color.rst b/reference/forms/types/color.rst index 5dfd61915ce..f3d97c6cd1b 100644 --- a/reference/forms/types/color.rst +++ b/reference/forms/types/color.rst @@ -14,32 +14,38 @@ The value of the underlying ```` field is always a That's why it's not possible to select semi-transparent colors with this element. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``color`` field (a text box) | -+-------------+---------------------------------------------------------------------+ -| Options | - `html5`_ | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ColorType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+---------------------------------------------------------------------+ +| Rendered as | ``input`` ``color`` field (a text box) | ++---------------------------+---------------------------------------------------------------------+ +| Options | - `html5`_ | ++---------------------------+---------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+---------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+---------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid color. | ++---------------------------+---------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+---------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\ColorType` | ++---------------------------+---------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -59,6 +65,11 @@ When this option is set to ``true``, the form type checks that its value matches the `HTML5 color format`_ (``/^#[0-9a-f]{6}$/i``). If it doesn't match it, you'll see the following error message: *"This value is not a valid HTML5 color"*. +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index f4082e498e8..a2b1527764e 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -18,45 +18,50 @@ Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the field type automatically uses all of the countries of the world. You *can* specify the option 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_translation_locale`_ | -+-------------+-----------------------------------------------------------------------+ -| Overridden | - `choices`_ | -| options | - `choice_translation_domain`_ | -+-------------+-----------------------------------------------------------------------+ -| Inherited | from the :doc:`ChoiceType ` | -| options | | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `expanded`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -| | - `trim`_ | -| | | -| | from the :doc:`FormType ` | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`ChoiceType ` | -+-------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CountryType` | -+-------------+-----------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------+ +| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | ++---------------------------+-----------------------------------------------------------------------+ +| Options | - `alpha3`_ | +| | - `choice_translation_locale`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Overridden options | - `choices`_ | +| | - `choice_translation_domain`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Inherited options | from the :doc:`ChoiceType ` | +| | | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `expanded`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | +| | - `trim`_ | +| | | +| | from the :doc:`FormType ` | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid country. | ++---------------------------+-----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------+ +| Parent type | :doc:`ChoiceType ` | ++---------------------------+-----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CountryType` | ++---------------------------+-----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -92,6 +97,8 @@ The locale is used to translate the countries names. .. include:: /reference/forms/types/options/choice_translation_domain_disabled.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index 77da0481942..e8628aa3edf 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -11,43 +11,48 @@ Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the field type automatically uses a large list of currencies. You *can* specify the option manually, but then you should just use the ``ChoiceType`` directly. -+-------------+------------------------------------------------------------------------+ -| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | -+-------------+------------------------------------------------------------------------+ -| Options | - `choice_translation_locale`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `choices`_ | -| options | - `choice_translation_domain`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`ChoiceType ` | -| options | | -| | - `error_bubbling`_ | -| | - `expanded`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -| | - `trim`_ | -| | | -| | from the :doc:`FormType ` type | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`ChoiceType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CurrencyType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `choice_translation_locale`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `choices`_ | +| | - `choice_translation_domain`_ | +| | - `invalid_message`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | from the :doc:`ChoiceType ` | +| | | +| | - `error_bubbling`_ | +| | - `expanded`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | +| | - `trim`_ | +| | | +| | from the :doc:`FormType ` type | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid currency. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`ChoiceType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\CurrencyType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -73,6 +78,8 @@ The choices option defaults to all currencies. .. include:: /reference/forms/types/options/choice_translation_domain_disabled.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index 582b5bef6ff..fa696007803 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -10,46 +10,50 @@ different HTML elements. This field can be rendered in a variety of different ways via the `widget`_ option and can understand a number of different input formats via the `input`_ option. -+----------------------+-----------------------------------------------------------------------------+ -| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | -+----------------------+-----------------------------------------------------------------------------+ -| Rendered as | single text box or three select fields | -+----------------------+-----------------------------------------------------------------------------+ -| Options | - `days`_ | -| | - `placeholder`_ | -| | - `format`_ | -| | - `html5`_ | -| | - `input`_ | -| | - `input_format`_ | -| | - `model_timezone`_ | -| | - `months`_ | -| | - `view_timezone`_ | -| | - `widget`_ | -| | - `years`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Overridden options | - `by_reference`_ | -| | - `choice_translation_domain`_ | -| | - `compound`_ | -| | - `data_class`_ | -| | - `error_bubbling`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+----------------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateType` | -+----------------------+-----------------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------------+ +| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | ++---------------------------+-----------------------------------------------------------------------------+ +| Rendered as | single text box or three select fields | ++---------------------------+-----------------------------------------------------------------------------+ +| Options | - `days`_ | +| | - `placeholder`_ | +| | - `format`_ | +| | - `html5`_ | +| | - `input`_ | +| | - `input_format`_ | +| | - `model_timezone`_ | +| | - `months`_ | +| | - `view_timezone`_ | +| | - `widget`_ | +| | - `years`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Overridden options | - `by_reference`_ | +| | - `choice_translation_domain`_ | +| | - `compound`_ | +| | - `data_class`_ | +| | - `error_bubbling`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid date. | ++---------------------------+-----------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+-----------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateType` | ++---------------------------+-----------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -210,6 +214,8 @@ The ``DateTime`` classes are treated as immutable objects. **default**: ``false`` +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -231,8 +237,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/dateinterval.rst b/reference/forms/types/dateinterval.rst index 84986f93c87..69147d95bee 100644 --- a/reference/forms/types/dateinterval.rst +++ b/reference/forms/types/dateinterval.rst @@ -12,47 +12,52 @@ The field can be rendered in a variety of different ways (see `widget`_) and can give you a ``DateInterval`` object, an `ISO 8601`_ duration string (e.g. ``P1DT12H``) or an array (see `input`_). -+----------------------+----------------------------------------------------------------------------------+ -| Underlying Data Type | can be ``DateInterval``, string or array (see the ``input`` option) | -+----------------------+----------------------------------------------------------------------------------+ -| Rendered as | single text box, multiple text boxes or select fields - see the `widget`_ option | -+----------------------+----------------------------------------------------------------------------------+ -| Options | - `days`_ | -| | - `hours`_ | -| | - `minutes`_ | -| | - `months`_ | -| | - `seconds`_ | -| | - `weeks`_ | -| | - `input`_ | -| | - `labels`_ | -| | - `placeholder`_ | -| | - `widget`_ | -| | - `with_days`_ | -| | - `with_hours`_ | -| | - `with_invert`_ | -| | - `with_minutes`_ | -| | - `with_months`_ | -| | - `with_seconds`_ | -| | - `with_weeks`_ | -| | - `with_years`_ | -| | - `years`_ | -+----------------------+----------------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+----------------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+----------------------+----------------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateIntervalType` | -+----------------------+----------------------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------------------+ +| Underlying Data Type | can be ``DateInterval``, string or array (see the ``input`` option) | ++---------------------------+----------------------------------------------------------------------------------+ +| Rendered as | single text box, multiple text boxes or select fields - see the `widget`_ option | ++---------------------------+----------------------------------------------------------------------------------+ +| Options | - `days`_ | +| | - `hours`_ | +| | - `minutes`_ | +| | - `months`_ | +| | - `seconds`_ | +| | - `weeks`_ | +| | - `input`_ | +| | - `labels`_ | +| | - `placeholder`_ | +| | - `widget`_ | +| | - `with_days`_ | +| | - `with_hours`_ | +| | - `with_invert`_ | +| | - `with_minutes`_ | +| | - `with_months`_ | +| | - `with_seconds`_ | +| | - `with_weeks`_ | +| | - `with_years`_ | +| | - `years`_ | ++---------------------------+----------------------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+----------------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+----------------------------------------------------------------------------------+ +| Default `invalid_message` | Please choose a valid date interval. | ++---------------------------+----------------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+----------------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateIntervalType` | ++---------------------------+----------------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -333,6 +338,11 @@ when the ``widget`` option is set to ``choice``:: // values displayed to users range from 1 to 100 (both inclusive) 'years' => array_combine(range(1, 100), range(1, 100)), +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -352,8 +362,6 @@ These options inherit from the :doc:`form ` type: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index ad56b6e2d52..ca61be3e538 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -10,55 +10,59 @@ date and time (e.g. ``1984-06-05 12:15:30``). Can be rendered as a text input or select tags. The underlying format of the data can be a ``DateTime`` object, a string, a timestamp or an array. -+----------------------+-----------------------------------------------------------------------------+ -| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | -+----------------------+-----------------------------------------------------------------------------+ -| Rendered as | single text box or three select fields | -+----------------------+-----------------------------------------------------------------------------+ -| Options | - `choice_translation_domain`_ | -| | - `date_format`_ | -| | - `date_label`_ | -| | - `date_widget`_ | -| | - `days`_ | -| | - `placeholder`_ | -| | - `format`_ | -| | - `hours`_ | -| | - `html5`_ | -| | - `input`_ | -| | - `input_format`_ | -| | - `minutes`_ | -| | - `model_timezone`_ | -| | - `months`_ | -| | - `seconds`_ | -| | - `time_label`_ | -| | - `time_widget`_ | -| | - `view_timezone`_ | -| | - `widget`_ | -| | - `with_minutes`_ | -| | - `with_seconds`_ | -| | - `years`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Overridden options | - `by_reference`_ | -| | - `compound`_ | -| | - `data_class`_ | -| | - `error_bubbling`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+----------------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType` | -+----------------------+-----------------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------------+ +| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | ++---------------------------+-----------------------------------------------------------------------------+ +| Rendered as | single text box or three select fields | ++---------------------------+-----------------------------------------------------------------------------+ +| Options | - `choice_translation_domain`_ | +| | - `date_format`_ | +| | - `date_label`_ | +| | - `date_widget`_ | +| | - `days`_ | +| | - `placeholder`_ | +| | - `format`_ | +| | - `hours`_ | +| | - `html5`_ | +| | - `input`_ | +| | - `input_format`_ | +| | - `minutes`_ | +| | - `model_timezone`_ | +| | - `months`_ | +| | - `seconds`_ | +| | - `time_label`_ | +| | - `time_widget`_ | +| | - `view_timezone`_ | +| | - `widget`_ | +| | - `with_minutes`_ | +| | - `with_seconds`_ | +| | - `years`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Overridden options | - `by_reference`_ | +| | - `compound`_ | +| | - `data_class`_ | +| | - `error_bubbling`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid date and time. | ++---------------------------+-----------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+-----------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\DateTimeType` | ++---------------------------+-----------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -231,6 +235,8 @@ error_bubbling **default**: ``false`` +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -250,8 +256,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index 74eeaa95272..31d6f5db90b 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -7,33 +7,44 @@ EmailType Field The ``EmailType`` field is a text field that is rendered using the HTML5 ```` tag. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``email`` field (a text box) | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+---------------------------------------------------------------------+ +| Rendered as | ``input`` ``email`` field (a text box) | ++---------------------------+---------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+---------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+---------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid email address. | ++---------------------------+---------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+---------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\EmailType` | ++---------------------------+---------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index 66a18560577..f745c9bc1fd 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -6,33 +6,38 @@ FileType Field The ``FileType`` represents a file input in your form. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``file`` field | -+-------------+---------------------------------------------------------------------+ -| Options | - `multiple`_ | -+-------------+---------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | - `data_class`_ | -| | - `empty_data`_ | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `disabled`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FileType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+--------------------------------------------------------------------+ +| Rendered as | ``input`` ``file`` field | ++---------------------------+--------------------------------------------------------------------+ +| Options | - `multiple`_ | ++---------------------------+--------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `data_class`_ | +| | - `empty_data`_ | +| | - `invalid_message`_ | ++---------------------------+--------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `disabled`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+--------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid file. | ++---------------------------+--------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+--------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+--------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FileType` | ++---------------------------+--------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -120,6 +125,11 @@ This option sets the appropriate file-related data mapper to be used by the type This option determines what value the field will return when the submitted value is empty. +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index 8a0c219f410..e406413bf37 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -7,51 +7,55 @@ FormType Field The ``FormType`` predefines a couple of options that are then available on all types for which ``FormType`` is the parent. -+-----------+--------------------------------------------------------------------+ -| Options | - `action`_ | -| | - `allow_extra_fields`_ | -| | - `by_reference`_ | -| | - `compound`_ | -| | - `constraints`_ | -| | - `data`_ | -| | - `data_class`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `extra_fields_message`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `help_translation_parameters`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `method`_ | -| | - `post_max_size_message`_ | -| | - `property_path`_ | -| | - `required`_ | -| | - `trim`_ | -| | - `validation_groups`_ | -+-----------+--------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `auto_initialize`_ | -| | - `block_name`_ | -| | - `block_prefix`_ | -| | - `disabled`_ | -| | - `label`_ | -| | - `label_html`_ | -| | - `row_attr`_ | -| | - `translation_domain`_ | -| | - `label_translation_parameters`_ | -| | - `attr_translation_parameters`_ | -+-----------+--------------------------------------------------------------------+ -| Parent | none | -+-----------+--------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` | -+-----------+--------------------------------------------------------------------+ ++---------------------------+--------------------------------------------------------------------+ +| Options | - `action`_ | +| | - `allow_extra_fields`_ | +| | - `by_reference`_ | +| | - `compound`_ | +| | - `constraints`_ | +| | - `data`_ | +| | - `data_class`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `extra_fields_message`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `help_translation_parameters`_ | +| | - `inherit_data`_ | +| | - `invalid_message`_ | +| | - `invalid_message_parameters`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `method`_ | +| | - `post_max_size_message`_ | +| | - `property_path`_ | +| | - `required`_ | +| | - `trim`_ | +| | - `validation_groups`_ | ++---------------------------+--------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `auto_initialize`_ | +| | - `block_name`_ | +| | - `block_prefix`_ | +| | - `disabled`_ | +| | - `label`_ | +| | - `label_html`_ | +| | - `row_attr`_ | +| | - `translation_domain`_ | +| | - `label_translation_parameters`_ | +| | - `attr_translation_parameters`_ | ++---------------------------+--------------------------------------------------------------------+ +| Default `invalid_message` | This value is not valid. | ++---------------------------+--------------------------------------------------------------------+ +| Legacy `invalid_message` | This value is not valid. | ++---------------------------+--------------------------------------------------------------------+ +| Parent | none | ++---------------------------+--------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType` | ++---------------------------+--------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index 1a74e107555..f0bddfa4260 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -6,25 +6,30 @@ HiddenType Field The hidden type represents a hidden input field. -+-------------+----------------------------------------------------------------------+ -| Rendered as | ``input`` ``hidden`` field | -+-------------+----------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | - `error_bubbling`_ | -| | - `required`_ | -+-------------+----------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `empty_data`_ | -| | - `error_mapping`_ | -| | - `mapped`_ | -| | - `property_path`_ | -| | - `row_attr`_ | -+-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType` | -+-------------+----------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------+ +| Rendered as | ``input`` ``hidden`` field | ++---------------------------+----------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `error_bubbling`_ | +| | - `invalid_message`_ | +| | - `required`_ | ++---------------------------+----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `empty_data`_ | +| | - `error_mapping`_ | +| | - `mapped`_ | +| | - `property_path`_ | +| | - `row_attr`_ | ++---------------------------+----------------------------------------------------------------------+ +| Default `invalid_message` | The hidden field is invalid. | ++---------------------------+----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\HiddenType` | ++---------------------------+----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -40,6 +45,8 @@ Overridden Options Pass errors to the root form, otherwise they will not be visible. +.. include:: /reference/forms/types/options/invalid_message.rst.inc + ``required`` ~~~~~~~~~~~~ diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index fa5660158bc..7eb32abf7f9 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -13,37 +13,40 @@ This field has different options on how to handle input values that aren't integers. By default, all non-integer values (e.g. 6.78) will round down (e.g. 6). -+-------------+-----------------------------------------------------------------------+ -| Rendered as | ``input`` ``number`` field | -+-------------+-----------------------------------------------------------------------+ -| Options | - `grouping`_ | -| | - `rounding_mode`_ | -+-------------+-----------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | | -+-------------+-----------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\IntegerType` | -+-------------+-----------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------+ +| Rendered as | ``input`` ``number`` field | ++---------------------------+-----------------------------------------------------------------------+ +| Options | - `grouping`_ | +| | - `rounding_mode`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `invalid_message_parameters`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Default `invalid_message` | Please enter an integer. | ++---------------------------+-----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+-----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\IntegerType` | ++---------------------------+-----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -86,6 +89,8 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -115,8 +120,6 @@ The default value is ``''`` (the empty string). .. include:: /reference/forms/types/options/help_html.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/label.rst.inc diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 5fa38697701..420ab1b59a0 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -20,46 +20,51 @@ Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the field type automatically uses a large list of languages. You *can* specify the option 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`_ | -| options | - `choice_translation_domain`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`ChoiceType ` | -| options | | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `expanded`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -| | - `trim`_ | -| | | -| | from the :doc:`FormType ` | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`ChoiceType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LanguageType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `alpha3`_ | +| | - `choice_self_translation`_ | +| | - `choice_translation_locale`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `choices`_ | +| | - `choice_translation_domain`_ | +| | - `invalid_message`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | from the :doc:`ChoiceType ` | +| | | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `expanded`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | +| | - `trim`_ | +| | | +| | from the :doc:`FormType ` | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid language. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`ChoiceType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LanguageType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -114,6 +119,8 @@ The default locale is used to translate the languages names. .. include:: /reference/forms/types/options/choice_translation_domain_disabled.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index 385cc4f6fd8..be6dde7e950 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -21,44 +21,49 @@ Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the field type automatically uses a large list of locales. You *can* specify these options manually, but then you should just use the ``ChoiceType`` directly. -+-------------+------------------------------------------------------------------------+ -| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | -+-------------+------------------------------------------------------------------------+ -| Options | - `choice_translation_locale`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `choices`_ | -| options | - `choice_translation_domain`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`ChoiceType ` | -| options | | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `expanded`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -| | - `trim`_ | -| | | -| | from the :doc:`FormType ` | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`ChoiceType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LocaleType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------+ +| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | ++---------------------------+----------------------------------------------------------------------+ +| Options | - `choice_translation_locale`_ | ++---------------------------+----------------------------------------------------------------------+ +| Overridden options | - `choices`_ | +| | - `choice_translation_domain`_ | +| | - `invalid_message`_ | ++---------------------------+----------------------------------------------------------------------+ +| Inherited options | from the :doc:`ChoiceType ` | +| | | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `expanded`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | +| | - `trim`_ | +| | | +| | from the :doc:`FormType ` | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+----------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid locale. | ++---------------------------+----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------+ +| Parent type | :doc:`ChoiceType ` | ++---------------------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\LocaleType` | ++---------------------------+----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -85,6 +90,8 @@ specify the language. .. include:: /reference/forms/types/options/choice_translation_domain_disabled.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index bb91d0b08da..ca7a5aceac7 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -11,41 +11,44 @@ This field type allows you to specify a currency, whose symbol is rendered next to the text field. There are also several other options for customizing how the input and output of the data is handled. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``text`` field | -+-------------+---------------------------------------------------------------------+ -| Options | - `currency`_ | -| | - `divisor`_ | -| | - `grouping`_ | -| | - `html5`_ | -| | - `rounding_mode`_ | -| | - `scale`_ | -+-------------+---------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+---------------------------------------------------------------------+ +| Rendered as | ``input`` ``text`` field | ++---------------------------+---------------------------------------------------------------------+ +| Options | - `currency`_ | +| | - `divisor`_ | +| | - `grouping`_ | +| | - `html5`_ | +| | - `rounding_mode`_ | +| | - `scale`_ | ++---------------------------+---------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `invalid_message`_ | ++---------------------------+---------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `invalid_message_parameters`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+---------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid money amount. | ++---------------------------+---------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+---------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\MoneyType` | ++---------------------------+---------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -122,6 +125,8 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -151,8 +156,6 @@ The default value is ``''`` (the empty string). .. include:: /reference/forms/types/options/help_html.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/label.rst.inc diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 599d0efa4cd..319c84b951e 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -8,40 +8,43 @@ Renders an input text field and specializes in handling number input. This type offers different options for the scale, rounding and grouping that you want to use for your number. -+-------------+----------------------------------------------------------------------+ -| Rendered as | ``input`` ``text`` field | -+-------------+----------------------------------------------------------------------+ -| Options | - `grouping`_ | -| | - `html5`_ | -| | - `input`_ | -| | - `scale`_ | -| | - `rounding_mode`_ | -+-------------+----------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | | -+-------------+----------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\NumberType` | -+-------------+----------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------+ +| Rendered as | ``input`` ``text`` field | ++---------------------------+----------------------------------------------------------------------+ +| Options | - `grouping`_ | +| | - `html5`_ | +| | - `input`_ | +| | - `scale`_ | +| | - `rounding_mode`_ | ++---------------------------+----------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `invalid_message`_ | ++---------------------------+----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `invalid_message_parameters`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+----------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a number. | ++---------------------------+----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\NumberType` | ++---------------------------+----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -86,6 +89,8 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -115,8 +120,6 @@ The default value is ``''`` (the empty string). .. include:: /reference/forms/types/options/help_html.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/label.rst.inc diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 37acff1a616..10b38a5ac8b 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -6,33 +6,37 @@ PasswordType Field The ``PasswordType`` field renders an input password text box. -+-------------+------------------------------------------------------------------------+ -| Rendered as | ``input`` ``password`` field | -+-------------+------------------------------------------------------------------------+ -| Options | - `always_empty`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `trim`_ | -| options | | -+-------------+------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | ``input`` ``password`` field | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `always_empty`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | +| | - `trim`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | The password is invalid. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PasswordType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -54,6 +58,8 @@ entered into the box, set this to false and submit the form. Overridden Options ------------------ +.. include:: /reference/forms/types/options/invalid_message.rst.inc + ``trim`` ~~~~~~~~ diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 4b21f1f2856..3dd47e1d320 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -12,40 +12,43 @@ you can use this field out-of-the-box. If you store your data as a number When ``symbol`` is not ``false``, the field will render the given string after the input. -+-------------+-----------------------------------------------------------------------+ -| Rendered as | ``input`` ``text`` field | -+-------------+-----------------------------------------------------------------------+ -| Options | - `html5`_ | -| | - `rounding_mode`_ | -| | - `scale`_ | -| | - `symbol`_ | -| | - `type`_ | -+-------------+-----------------------------------------------------------------------+ -| Overridden | - `compound`_ | -| options | | -+-------------+-----------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+-----------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+-----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PercentType` | -+-------------+-----------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------+ +| Rendered as | ``input`` ``text`` field | ++---------------------------+-----------------------------------------------------------------------+ +| Options | - `html5`_ | +| | - `rounding_mode`_ | +| | - `scale`_ | +| | - `symbol`_ | +| | - `type`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `invalid_message_parameters`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a percentage value. | ++---------------------------+-----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+-----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\PercentType` | ++---------------------------+-----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -115,6 +118,8 @@ Overridden Options .. include:: /reference/forms/types/options/compound_type.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -144,8 +149,6 @@ The default value is ``''`` (the empty string). .. include:: /reference/forms/types/options/help_html.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/label.rst.inc diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index ae0d58d2fe4..579dab0bc1d 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -13,38 +13,49 @@ The ``RadioType`` isn't usually used directly. More commonly it's used internally by other types such as :doc:`ChoiceType `. If you want to have a boolean field, use :doc:`CheckboxType `. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``radio`` field | -+-------------+---------------------------------------------------------------------+ -| Inherited | from the :doc:`CheckboxType `: | -| options | | -| | - `value`_ | -| | | -| | from the :doc:`FormType `: | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`CheckboxType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RadioType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+---------------------------------------------------------------------+ +| Rendered as | ``input`` ``radio`` field | ++---------------------------+---------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+---------------------------------------------------------------------+ +| Inherited options | from the :doc:`CheckboxType `: | +| | | +| | - `value`_ | +| | | +| | from the :doc:`FormType `: | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+---------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid option. | ++---------------------------+---------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+---------------------------------------------------------------------+ +| Parent type | :doc:`CheckboxType ` | ++---------------------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RadioType` | ++---------------------------+---------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/range.rst b/reference/forms/types/range.rst index e328a1bbe97..ab3a0d15859 100644 --- a/reference/forms/types/range.rst +++ b/reference/forms/types/range.rst @@ -7,29 +7,35 @@ RangeType Field The ``RangeType`` field is a slider that is rendered using the HTML5 ```` tag. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``range`` field (slider in HTML5 supported browser) | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RangeType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+---------------------------------------------------------------------+ +| Rendered as | ``input`` ``range`` field (slider in HTML5 supported browser) | ++---------------------------+---------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+---------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+---------------------------------------------------------------------+ +| Default `invalid_message` | Please choose a valid range. | ++---------------------------+---------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+---------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+---------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RangeType` | ++---------------------------+---------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -48,6 +54,11 @@ Basic Usage ] ]); +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index c78e6cc318e..7a9f6d9d9be 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -9,34 +9,37 @@ values must match (or a validation error is thrown). The most common use is when you need the user to repeat their password or email to verify accuracy. -+-------------+------------------------------------------------------------------------+ -| Rendered as | input ``text`` field by default, but see `type`_ option | -+-------------+------------------------------------------------------------------------+ -| Options | - `first_name`_ | -| | - `first_options`_ | -| | - `options`_ | -| | - `second_name`_ | -| | - `second_options`_ | -| | - `type`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `error_bubbling`_ | -| options | | -+-------------+------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | input ``text`` field by default, but see `type`_ option | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `first_name`_ | +| | - `first_options`_ | +| | - `options`_ | +| | - `second_name`_ | +| | - `second_options`_ | +| | - `type`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `error_bubbling`_ | +| | - `invalid_message`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | The values do not match. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\RepeatedType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -184,6 +187,8 @@ Overridden Options **default**: ``false`` +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -201,8 +206,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/help_html.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index e0f8233aa5b..f9c53733872 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -9,32 +9,43 @@ special functionality supported by some browsers. Read about the input search field at `DiveIntoHTML5.info`_ -+-------------+----------------------------------------------------------------------+ -| Rendered as | ``input search`` field | -+-------------+----------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+----------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+----------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\SearchType` | -+-------------+----------------------------------------------------------------------+ ++---------------------------+----------------------------------------------------------------------+ +| Rendered as | ``input search`` field | ++---------------------------+----------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+----------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+----------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid search term. | ++---------------------------+----------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+----------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+----------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\SearchType` | ++---------------------------+----------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/tel.rst b/reference/forms/types/tel.rst index f6c19391ada..fc45434bc4e 100644 --- a/reference/forms/types/tel.rst +++ b/reference/forms/types/tel.rst @@ -13,33 +13,44 @@ Nevertheless, it may be useful to use this type in web applications because some browsers (e.g. smartphone browsers) adapt the input keyboard to make it easier to input phone numbers. -+-------------+---------------------------------------------------------------------+ -| Rendered as | ``input`` ``tel`` field (a text box) | -+-------------+---------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+---------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+---------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TelType` | -+-------------+---------------------------------------------------------------------+ ++---------------------------+-------------------------------------------------------------------+ +| Rendered as | ``input`` ``tel`` field (a text box) | ++---------------------------+-------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+-------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+-------------------------------------------------------------------+ +| Default `invalid_message` | Please provide a valid phone number. | ++---------------------------+-------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+-------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TelType` | ++---------------------------+-------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 042e3e7da0c..08c3efb77f4 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -10,48 +10,52 @@ This can be rendered as a text field, a series of text fields (e.g. hour, minute, second) or a series of select fields. The underlying data can be stored as a ``DateTime`` object, a string, a timestamp or an array. -+----------------------+-----------------------------------------------------------------------------+ -| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | -+----------------------+-----------------------------------------------------------------------------+ -| Rendered as | can be various tags (see below) | -+----------------------+-----------------------------------------------------------------------------+ -| Options | - `choice_translation_domain`_ | -| | - `placeholder`_ | -| | - `hours`_ | -| | - `html5`_ | -| | - `input`_ | -| | - `input_format`_ | -| | - `minutes`_ | -| | - `model_timezone`_ | -| | - `reference_date`_ | -| | - `seconds`_ | -| | - `view_timezone`_ | -| | - `widget`_ | -| | - `with_minutes`_ | -| | - `with_seconds`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Overridden options | - `by_reference`_ | -| | - `compound`_ | -| | - `data_class`_ | -| | - `error_bubbling`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Parent type | FormType | -+----------------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimeType` | -+----------------------+-----------------------------------------------------------------------------+ ++---------------------------+-----------------------------------------------------------------------------+ +| Underlying Data Type | can be ``DateTime``, string, timestamp, or array (see the ``input`` option) | ++---------------------------+-----------------------------------------------------------------------------+ +| Rendered as | can be various tags (see below) | ++---------------------------+-----------------------------------------------------------------------------+ +| Options | - `choice_translation_domain`_ | +| | - `placeholder`_ | +| | - `hours`_ | +| | - `html5`_ | +| | - `input`_ | +| | - `input_format`_ | +| | - `minutes`_ | +| | - `model_timezone`_ | +| | - `reference_date`_ | +| | - `seconds`_ | +| | - `view_timezone`_ | +| | - `widget`_ | +| | - `with_minutes`_ | +| | - `with_seconds`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Overridden options | - `by_reference`_ | +| | - `compound`_ | +| | - `data_class`_ | +| | - `error_bubbling`_ | +| | - `invalid_message`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+-----------------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid time. | ++---------------------------+-----------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-----------------------------------------------------------------------------+ +| Parent type | FormType | ++---------------------------+-----------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimeType` | ++---------------------------+-----------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -220,6 +224,8 @@ error_bubbling **default**: ``false`` +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -241,8 +247,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index c18cdbaf339..64e17890de8 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -14,45 +14,50 @@ Unlike the ``ChoiceType``, you don't need to specify a ``choices`` option as the field type automatically uses a large list of timezones. You *can* specify the option manually, but then you should just use the ``ChoiceType`` directly. -+-------------+------------------------------------------------------------------------+ -| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | -+-------------+------------------------------------------------------------------------+ -| Options | - `input`_ | -| | - `intl`_ | -+-------------+------------------------------------------------------------------------+ -| Overridden | - `choices`_ | -| options | - `choice_translation_domain`_ | -+-------------+------------------------------------------------------------------------+ -| Inherited | from the :doc:`ChoiceType ` | -| options | | -| | - `expanded`_ | -| | - `multiple`_ | -| | - `placeholder`_ | -| | - `preferred_choices`_ | -| | - `trim`_ | -| | | -| | from the :doc:`FormType ` | -| | | -| | - `attr`_ | -| | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -+-------------+------------------------------------------------------------------------+ -| Parent type | :doc:`ChoiceType ` | -+-------------+------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimezoneType` | -+-------------+------------------------------------------------------------------------+ ++---------------------------+------------------------------------------------------------------------+ +| Rendered as | can be various tags (see :ref:`forms-reference-choice-tags`) | ++---------------------------+------------------------------------------------------------------------+ +| Options | - `input`_ | +| | - `intl`_ | ++---------------------------+------------------------------------------------------------------------+ +| Overridden options | - `choices`_ | +| | - `choice_translation_domain`_ | +| | - `invalid_message`_ | ++---------------------------+------------------------------------------------------------------------+ +| Inherited options | from the :doc:`ChoiceType ` | +| | | +| | - `expanded`_ | +| | - `multiple`_ | +| | - `placeholder`_ | +| | - `preferred_choices`_ | +| | - `trim`_ | +| | | +| | from the :doc:`FormType ` | +| | | +| | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | ++---------------------------+------------------------------------------------------------------------+ +| Default `invalid_message` | Please select a valid timezone. | ++---------------------------+------------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+------------------------------------------------------------------------+ +| Parent type | :doc:`ChoiceType ` | ++---------------------------+------------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\TimezoneType` | ++---------------------------+------------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -107,6 +112,8 @@ The Timezone type defaults the choices to all timezones returned by .. include:: /reference/forms/types/options/choice_translation_domain_disabled.rst.inc +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index a03f1532021..e5f782ce088 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -8,32 +8,38 @@ The ``UrlType`` field is a text field that prepends the submitted value with a given protocol (e.g. ``http://``) if the submitted value doesn't already have a protocol. -+-------------+-------------------------------------------------------------------+ -| Rendered as | ``input url`` field | -+-------------+-------------------------------------------------------------------+ -| Options | - `default_protocol`_ | -+-------------+-------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -| | - `error_mapping`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `label`_ | -| | - `label_attr`_ | -| | - `label_format`_ | -| | - `mapped`_ | -| | - `required`_ | -| | - `row_attr`_ | -| | - `trim`_ | -+-------------+-------------------------------------------------------------------+ -| Parent type | :doc:`TextType ` | -+-------------+-------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\UrlType` | -+-------------+-------------------------------------------------------------------+ ++---------------------------+-------------------------------------------------------------------+ +| Rendered as | ``input url`` field | ++---------------------------+-------------------------------------------------------------------+ +| Options | - `default_protocol`_ | ++---------------------------+-------------------------------------------------------------------+ +| Overridden options | - `invalid_message`_ | ++---------------------------+-------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `error_mapping`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `label`_ | +| | - `label_attr`_ | +| | - `label_format`_ | +| | - `mapped`_ | +| | - `required`_ | +| | - `row_attr`_ | +| | - `trim`_ | ++---------------------------+-------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid URL. | ++---------------------------+-------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+-------------------------------------------------------------------+ +| Parent type | :doc:`TextType ` | ++---------------------------+-------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\UrlType` | ++---------------------------+-------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -49,6 +55,11 @@ If a value is submitted that doesn't begin with some protocol (e.g. ``http://``, ``ftp://``, etc), this protocol will be prepended to the string when the data is submitted to the form. +Overridden Options +------------------ + +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- diff --git a/reference/forms/types/week.rst b/reference/forms/types/week.rst index 6967df09bb7..eb526c160af 100644 --- a/reference/forms/types/week.rst +++ b/reference/forms/types/week.rst @@ -10,39 +10,43 @@ This field type allows the user to modify data that represents a specific Can be rendered as a text input or select tags. The underlying format of the data can be a string or an array. -+----------------------+-----------------------------------------------------------------------------+ -| Underlying Data Type | can be a string, or array (see the ``input`` option) | -+----------------------+-----------------------------------------------------------------------------+ -| Rendered as | single text box, two text boxes or two select fields | -+----------------------+-----------------------------------------------------------------------------+ -| Options | - `choice_translation_domain`_ | -| | - `placeholder`_ | -| | - `html5`_ | -| | - `input`_ | -| | - `widget`_ | -| | - `weeks`_ | -| | - `years`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Overridden options | - `compound`_ | -| | - `empty_data`_ | -| | - `error_bubbling`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Inherited | - `attr`_ | -| options | - `data`_ | -| | - `disabled`_ | -| | - `help`_ | -| | - `help_attr`_ | -| | - `help_html`_ | -| | - `inherit_data`_ | -| | - `invalid_message`_ | -| | - `invalid_message_parameters`_ | -| | - `mapped`_ | -| | - `row_attr`_ | -+----------------------+-----------------------------------------------------------------------------+ -| Parent type | :doc:`FormType ` | -+----------------------+-----------------------------------------------------------------------------+ -| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\WeekType` | -+----------------------+-----------------------------------------------------------------------------+ ++---------------------------+--------------------------------------------------------------------+ +| Underlying Data Type | can be a string, or array (see the ``input`` option) | ++---------------------------+--------------------------------------------------------------------+ +| Rendered as | single text box, two text boxes or two select fields | ++---------------------------+--------------------------------------------------------------------+ +| Options | - `choice_translation_domain`_ | +| | - `placeholder`_ | +| | - `html5`_ | +| | - `input`_ | +| | - `widget`_ | +| | - `weeks`_ | +| | - `years`_ | ++---------------------------+--------------------------------------------------------------------+ +| Overridden options | - `compound`_ | +| | - `empty_data`_ | +| | - `error_bubbling`_ | +| | - `invalid_message`_ | ++---------------------------+--------------------------------------------------------------------+ +| Inherited options | - `attr`_ | +| | - `data`_ | +| | - `disabled`_ | +| | - `help`_ | +| | - `help_attr`_ | +| | - `help_html`_ | +| | - `inherit_data`_ | +| | - `invalid_message_parameters`_ | +| | - `mapped`_ | +| | - `row_attr`_ | ++---------------------------+--------------------------------------------------------------------+ +| Default `invalid_message` | Please enter a valid week. | ++---------------------------+--------------------------------------------------------------------+ +| Legacy `invalid_message` | The value {{ value }} is not valid. | ++---------------------------+--------------------------------------------------------------------+ +| Parent type | :doc:`FormType ` | ++---------------------------+--------------------------------------------------------------------+ +| Class | :class:`Symfony\\Component\\Form\\Extension\\Core\\Type\\WeekType` | ++---------------------------+--------------------------------------------------------------------+ .. include:: /reference/forms/types/options/_debug_form.rst.inc @@ -138,6 +142,8 @@ error_bubbling **default**: ``false`` +.. include:: /reference/forms/types/options/invalid_message.rst.inc + Inherited Options ----------------- @@ -157,8 +163,6 @@ These options inherit from the :doc:`FormType `: .. include:: /reference/forms/types/options/inherit_data.rst.inc -.. include:: /reference/forms/types/options/invalid_message.rst.inc - .. include:: /reference/forms/types/options/invalid_message_parameters.rst.inc .. include:: /reference/forms/types/options/mapped.rst.inc From 289ca7c128f4c413f75a0606cc54f9833130e5c1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 20 Nov 2020 10:08:28 +0100 Subject: [PATCH 617/752] Fix: DOCtor-RST build --- http_client.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/http_client.rst b/http_client.rst index 2fb102a0fcc..b46a3f7760d 100644 --- a/http_client.rst +++ b/http_client.rst @@ -1616,5 +1616,5 @@ Then configure Symfony to use your callback: .. _`amphp/http-client`: https://packagist.org/packages/amphp/http-client .. _`cURL options`: https://www.php.net/manual/en/function.curl-setopt.php .. _`Server-sent events`: https://html.spec.whatwg.org/multipage/server-sent-events.html -.. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource -.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications +.. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource +.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods_and_web_applications From 12fff0cf5ec2a195709c5ac1ccbad8e04da6bef1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 20 Nov 2020 09:45:20 +0100 Subject: [PATCH 618/752] Enhancement: New rule for DOCtor-RST --- .doctor-rst.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.doctor-rst.yaml b/.doctor-rst.yaml index 5c4fadeb132..94d88088d52 100644 --- a/.doctor-rst.yaml +++ b/.doctor-rst.yaml @@ -6,6 +6,7 @@ rules: composer_dev_option_not_at_the_end: ~ correct_code_block_directive_based_on_the_content: ~ deprecated_directive_should_have_version: ~ + ensure_exactly_one_space_between_link_definition_and_link: ~ ensure_order_of_code_blocks_in_configuration_block: ~ extend_abstract_controller: ~ extension_xlf_instead_of_xliff: ~ From 26dfa839ad7242522a97968096403c5801852424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Barray?= Date: Fri, 20 Nov 2020 14:01:55 +0100 Subject: [PATCH 619/752] [Messenger] Add mention about serialize in inMemory transport dsn --- messenger.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/messenger.rst b/messenger.rst index ac07b40c624..e5a4da76cf9 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1295,6 +1295,15 @@ during a request:: :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase` or :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase`. +.. tip:: + + Using ``in-memory://?serialize=true`` as dsn will perform message serialization as real asynchronous transport will do. + Useful to test an additional layer, especially when you use your own message serializer. + +.. versionadded:: 5.3 + + The ``in-memory://?serialize=true`` dsn was introduced in Symfony 5.3. + Amazon SQS ~~~~~~~~~~ From 0ccfa6e913782c1788e08032ebfcf14968e72b96 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 20 Nov 2020 15:55:35 +0100 Subject: [PATCH 620/752] Tweaks --- forms.rst | 8 +++----- reference/forms/types/birthday.rst | 4 ++-- reference/forms/types/checkbox.rst | 4 ++-- reference/forms/types/choice.rst | 4 ++-- reference/forms/types/collection.rst | 4 ++-- reference/forms/types/color.rst | 4 ++-- reference/forms/types/country.rst | 4 ++-- reference/forms/types/currency.rst | 4 ++-- reference/forms/types/date.rst | 4 ++-- reference/forms/types/dateinterval.rst | 4 ++-- reference/forms/types/datetime.rst | 4 ++-- reference/forms/types/email.rst | 4 ++-- reference/forms/types/file.rst | 4 ++-- reference/forms/types/form.rst | 4 ++-- reference/forms/types/hidden.rst | 4 ++-- reference/forms/types/integer.rst | 4 ++-- reference/forms/types/language.rst | 4 ++-- reference/forms/types/locale.rst | 4 ++-- reference/forms/types/money.rst | 4 ++-- reference/forms/types/number.rst | 4 ++-- reference/forms/types/password.rst | 4 ++-- reference/forms/types/percent.rst | 4 ++-- reference/forms/types/radio.rst | 4 ++-- reference/forms/types/range.rst | 4 ++-- reference/forms/types/repeated.rst | 4 ++-- reference/forms/types/search.rst | 4 ++-- reference/forms/types/tel.rst | 4 ++-- reference/forms/types/time.rst | 4 ++-- reference/forms/types/timezone.rst | 4 ++-- reference/forms/types/url.rst | 4 ++-- reference/forms/types/week.rst | 4 ++-- 31 files changed, 63 insertions(+), 65 deletions(-) diff --git a/forms.rst b/forms.rst index 6e2c9ec5120..8635b8fedbd 100644 --- a/forms.rst +++ b/forms.rst @@ -555,10 +555,9 @@ learn more about the validation constraints, please refer to the .. versionadded:: 5.2 - Validation messages for forms have been rewritten to be more user-friendly. - These newer messages can be enabled by setting the `legacy_error_messages` - option to "false". Details about these messages can be found in the corresponding - form type documentation. + In Symfony 5.2, the form validation messages have been rewritten to be more + user-friendly. Set the ``legacy_error_messages`` option to ``false`` to + enable these new messages: .. configuration-block:: @@ -595,7 +594,6 @@ learn more about the validation constraints, please refer to the ], ]); - Other Common Form Features -------------------------- diff --git a/reference/forms/types/birthday.rst b/reference/forms/types/birthday.rst index 127528bc774..94cff698cb4 100644 --- a/reference/forms/types/birthday.rst +++ b/reference/forms/types/birthday.rst @@ -49,9 +49,9 @@ option defaults to 120 years ago to the current year. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+-------------------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid birthdate. | +| Default invalid message | Please enter a valid birthdate. | +---------------------------+-------------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-------------------------------------------------------------------------------+ | Parent type | :doc:`DateType ` | +---------------------------+-------------------------------------------------------------------------------+ diff --git a/reference/forms/types/checkbox.rst b/reference/forms/types/checkbox.rst index 1463c542a1e..d4fdd17580c 100644 --- a/reference/forms/types/checkbox.rst +++ b/reference/forms/types/checkbox.rst @@ -36,9 +36,9 @@ if you want to handle submitted values like "0" or "false"). | | - `required`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | The checkbox has an invalid value. | +| Default invalid message | The checkbox has an invalid value. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index d0c81a829bd..affcce9ab54 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -52,9 +52,9 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | | - `attr_translation_parameters`_ | | | - `help_translation_parameters`_ | +---------------------------+----------------------------------------------------------------------+ -| Default `invalid_message` | The selected choice is invalid. | +| Default invalid message | The selected choice is invalid. | +---------------------------+----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/collection.rst b/reference/forms/types/collection.rst index a30cc250f6f..9e1eb170933 100644 --- a/reference/forms/types/collection.rst +++ b/reference/forms/types/collection.rst @@ -40,9 +40,9 @@ photos). | | - `required`_ | | | - `row_attr`_ | +---------------------------+--------------------------------------------------------------------------+ -| Default `invalid_message` | The collection is invalid. | +| Default invalid message | The collection is invalid. | +---------------------------+--------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+--------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+--------------------------------------------------------------------------+ diff --git a/reference/forms/types/color.rst b/reference/forms/types/color.rst index f3d97c6cd1b..6bbc28da2a7 100644 --- a/reference/forms/types/color.rst +++ b/reference/forms/types/color.rst @@ -38,9 +38,9 @@ element. | | - `row_attr`_ | | | - `trim`_ | +---------------------------+---------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid color. | +| Default invalid message | Please select a valid color. | +---------------------------+---------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+---------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/country.rst b/reference/forms/types/country.rst index a2b1527764e..10cf652947a 100644 --- a/reference/forms/types/country.rst +++ b/reference/forms/types/country.rst @@ -54,9 +54,9 @@ the option manually, but then you should just use the ``ChoiceType`` directly. | | - `required`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid country. | +| Default invalid message | Please select a valid country. | +---------------------------+-----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------+ | Parent type | :doc:`ChoiceType ` | +---------------------------+-----------------------------------------------------------------------+ diff --git a/reference/forms/types/currency.rst b/reference/forms/types/currency.rst index e8628aa3edf..e28b39c328a 100644 --- a/reference/forms/types/currency.rst +++ b/reference/forms/types/currency.rst @@ -45,9 +45,9 @@ manually, but then you should just use the ``ChoiceType`` directly. | | - `required`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid currency. | +| Default invalid message | Please select a valid currency. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`ChoiceType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/date.rst b/reference/forms/types/date.rst index fa696007803..5a12ad24b9c 100644 --- a/reference/forms/types/date.rst +++ b/reference/forms/types/date.rst @@ -46,9 +46,9 @@ and can understand a number of different input formats via the `input`_ option. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid date. | +| Default invalid message | Please enter a valid date. | +---------------------------+-----------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+-----------------------------------------------------------------------------+ diff --git a/reference/forms/types/dateinterval.rst b/reference/forms/types/dateinterval.rst index 69147d95bee..5248ca88739 100644 --- a/reference/forms/types/dateinterval.rst +++ b/reference/forms/types/dateinterval.rst @@ -50,9 +50,9 @@ or an array (see `input`_). | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+----------------------------------------------------------------------------------+ -| Default `invalid_message` | Please choose a valid date interval. | +| Default invalid message | Please choose a valid date interval. | +---------------------------+----------------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+----------------------------------------------------------------------------------+ diff --git a/reference/forms/types/datetime.rst b/reference/forms/types/datetime.rst index ca61be3e538..e742048fd24 100644 --- a/reference/forms/types/datetime.rst +++ b/reference/forms/types/datetime.rst @@ -55,9 +55,9 @@ the data can be a ``DateTime`` object, a string, a timestamp or an array. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid date and time. | +| Default invalid message | Please enter a valid date and time. | +---------------------------+-----------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+-----------------------------------------------------------------------------+ diff --git a/reference/forms/types/email.rst b/reference/forms/types/email.rst index 31d6f5db90b..3dfe77db44f 100644 --- a/reference/forms/types/email.rst +++ b/reference/forms/types/email.rst @@ -29,9 +29,9 @@ The ``EmailType`` field is a text field that is rendered using the HTML5 | | - `row_attr`_ | | | - `trim`_ | +---------------------------+---------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid email address. | +| Default invalid message | Please enter a valid email address. | +---------------------------+---------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+---------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/file.rst b/reference/forms/types/file.rst index f745c9bc1fd..50bc55fee88 100644 --- a/reference/forms/types/file.rst +++ b/reference/forms/types/file.rst @@ -30,9 +30,9 @@ The ``FileType`` represents a file input in your form. | | - `required`_ | | | - `row_attr`_ | +---------------------------+--------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid file. | +| Default invalid message | Please select a valid file. | +---------------------------+--------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+--------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+--------------------------------------------------------------------+ diff --git a/reference/forms/types/form.rst b/reference/forms/types/form.rst index e406413bf37..9e1a5d47227 100644 --- a/reference/forms/types/form.rst +++ b/reference/forms/types/form.rst @@ -48,9 +48,9 @@ on all types for which ``FormType`` is the parent. | | - `label_translation_parameters`_ | | | - `attr_translation_parameters`_ | +---------------------------+--------------------------------------------------------------------+ -| Default `invalid_message` | This value is not valid. | +| Default invalid message | This value is not valid. | +---------------------------+--------------------------------------------------------------------+ -| Legacy `invalid_message` | This value is not valid. | +| Legacy invalid message | This value is not valid. | +---------------------------+--------------------------------------------------------------------+ | Parent | none | +---------------------------+--------------------------------------------------------------------+ diff --git a/reference/forms/types/hidden.rst b/reference/forms/types/hidden.rst index f0bddfa4260..00e858303bf 100644 --- a/reference/forms/types/hidden.rst +++ b/reference/forms/types/hidden.rst @@ -22,9 +22,9 @@ The hidden type represents a hidden input field. | | - `property_path`_ | | | - `row_attr`_ | +---------------------------+----------------------------------------------------------------------+ -| Default `invalid_message` | The hidden field is invalid. | +| Default invalid message | The hidden field is invalid. | +---------------------------+----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 7eb32abf7f9..db774ec2ce9 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -39,9 +39,9 @@ integers. By default, all non-integer values (e.g. 6.78) will round down | | - `required`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------+ -| Default `invalid_message` | Please enter an integer. | +| Default invalid message | Please enter an integer. | +---------------------------+-----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+-----------------------------------------------------------------------+ diff --git a/reference/forms/types/language.rst b/reference/forms/types/language.rst index 420ab1b59a0..f74016d1a0c 100644 --- a/reference/forms/types/language.rst +++ b/reference/forms/types/language.rst @@ -57,9 +57,9 @@ manually, but then you should just use the ``ChoiceType`` directly. | | - `required`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid language. | +| Default invalid message | Please select a valid language. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`ChoiceType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/locale.rst b/reference/forms/types/locale.rst index be6dde7e950..bab466d262f 100644 --- a/reference/forms/types/locale.rst +++ b/reference/forms/types/locale.rst @@ -56,9 +56,9 @@ manually, but then you should just use the ``ChoiceType`` directly. | | - `required`_ | | | - `row_attr`_ | +---------------------------+----------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid locale. | +| Default invalid message | Please select a valid locale. | +---------------------------+----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------+ | Parent type | :doc:`ChoiceType ` | +---------------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/money.rst b/reference/forms/types/money.rst index ca7a5aceac7..162d8543b20 100644 --- a/reference/forms/types/money.rst +++ b/reference/forms/types/money.rst @@ -41,9 +41,9 @@ how the input and output of the data is handled. | | - `required`_ | | | - `row_attr`_ | +---------------------------+---------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid money amount. | +| Default invalid message | Please enter a valid money amount. | +---------------------------+---------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+---------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/number.rst b/reference/forms/types/number.rst index 319c84b951e..99d80628d33 100644 --- a/reference/forms/types/number.rst +++ b/reference/forms/types/number.rst @@ -37,9 +37,9 @@ that you want to use for your number. | | - `required`_ | | | - `row_attr`_ | +---------------------------+----------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a number. | +| Default invalid message | Please enter a number. | +---------------------------+----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/password.rst b/reference/forms/types/password.rst index 10b38a5ac8b..18be51b396f 100644 --- a/reference/forms/types/password.rst +++ b/reference/forms/types/password.rst @@ -29,9 +29,9 @@ The ``PasswordType`` field renders an input password text box. | | - `required`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | The password is invalid. | +| Default invalid message | The password is invalid. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/percent.rst b/reference/forms/types/percent.rst index 3dd47e1d320..36ffdcc1e1b 100644 --- a/reference/forms/types/percent.rst +++ b/reference/forms/types/percent.rst @@ -41,9 +41,9 @@ the input. | | - `required`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a percentage value. | +| Default invalid message | Please enter a percentage value. | +---------------------------+-----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+-----------------------------------------------------------------------+ diff --git a/reference/forms/types/radio.rst b/reference/forms/types/radio.rst index 579dab0bc1d..93fbe3ecfd9 100644 --- a/reference/forms/types/radio.rst +++ b/reference/forms/types/radio.rst @@ -40,9 +40,9 @@ If you want to have a boolean field, use :doc:`CheckboxType ` | +---------------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/range.rst b/reference/forms/types/range.rst index ab3a0d15859..f8284f1b7eb 100644 --- a/reference/forms/types/range.rst +++ b/reference/forms/types/range.rst @@ -28,9 +28,9 @@ The ``RangeType`` field is a slider that is rendered using the HTML5 | | - `row_attr`_ | | | - `trim`_ | +---------------------------+---------------------------------------------------------------------+ -| Default `invalid_message` | Please choose a valid range. | +| Default invalid message | Please choose a valid range. | +---------------------------+---------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+---------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+---------------------------------------------------------------------+ diff --git a/reference/forms/types/repeated.rst b/reference/forms/types/repeated.rst index 7a9f6d9d9be..8c36c64ddd5 100644 --- a/reference/forms/types/repeated.rst +++ b/reference/forms/types/repeated.rst @@ -32,9 +32,9 @@ accuracy. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | The values do not match. | +| Default invalid message | The values do not match. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/search.rst b/reference/forms/types/search.rst index f9c53733872..d6dceeb0264 100644 --- a/reference/forms/types/search.rst +++ b/reference/forms/types/search.rst @@ -30,9 +30,9 @@ Read about the input search field at `DiveIntoHTML5.info`_ | | - `row_attr`_ | | | - `trim`_ | +---------------------------+----------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid search term. | +| Default invalid message | Please enter a valid search term. | +---------------------------+----------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+----------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+----------------------------------------------------------------------+ diff --git a/reference/forms/types/tel.rst b/reference/forms/types/tel.rst index fc45434bc4e..19847431dd3 100644 --- a/reference/forms/types/tel.rst +++ b/reference/forms/types/tel.rst @@ -35,9 +35,9 @@ to input phone numbers. | | - `row_attr`_ | | | - `trim`_ | +---------------------------+-------------------------------------------------------------------+ -| Default `invalid_message` | Please provide a valid phone number. | +| Default invalid message | Please provide a valid phone number. | +---------------------------+-------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+-------------------------------------------------------------------+ diff --git a/reference/forms/types/time.rst b/reference/forms/types/time.rst index 08c3efb77f4..cac168d569e 100644 --- a/reference/forms/types/time.rst +++ b/reference/forms/types/time.rst @@ -48,9 +48,9 @@ stored as a ``DateTime`` object, a string, a timestamp or an array. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+-----------------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid time. | +| Default invalid message | Please enter a valid time. | +---------------------------+-----------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-----------------------------------------------------------------------------+ | Parent type | FormType | +---------------------------+-----------------------------------------------------------------------------+ diff --git a/reference/forms/types/timezone.rst b/reference/forms/types/timezone.rst index 64e17890de8..987f26c9036 100644 --- a/reference/forms/types/timezone.rst +++ b/reference/forms/types/timezone.rst @@ -50,9 +50,9 @@ manually, but then you should just use the ``ChoiceType`` directly. | | - `required`_ | | | - `row_attr`_ | +---------------------------+------------------------------------------------------------------------+ -| Default `invalid_message` | Please select a valid timezone. | +| Default invalid message | Please select a valid timezone. | +---------------------------+------------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+------------------------------------------------------------------------+ | Parent type | :doc:`ChoiceType ` | +---------------------------+------------------------------------------------------------------------+ diff --git a/reference/forms/types/url.rst b/reference/forms/types/url.rst index e5f782ce088..13f425f1d70 100644 --- a/reference/forms/types/url.rst +++ b/reference/forms/types/url.rst @@ -32,9 +32,9 @@ have a protocol. | | - `row_attr`_ | | | - `trim`_ | +---------------------------+-------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid URL. | +| Default invalid message | Please enter a valid URL. | +---------------------------+-------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+-------------------------------------------------------------------+ | Parent type | :doc:`TextType ` | +---------------------------+-------------------------------------------------------------------+ diff --git a/reference/forms/types/week.rst b/reference/forms/types/week.rst index eb526c160af..99762f803e3 100644 --- a/reference/forms/types/week.rst +++ b/reference/forms/types/week.rst @@ -39,9 +39,9 @@ the data can be a string or an array. | | - `mapped`_ | | | - `row_attr`_ | +---------------------------+--------------------------------------------------------------------+ -| Default `invalid_message` | Please enter a valid week. | +| Default invalid message | Please enter a valid week. | +---------------------------+--------------------------------------------------------------------+ -| Legacy `invalid_message` | The value {{ value }} is not valid. | +| Legacy invalid message | The value {{ value }} is not valid. | +---------------------------+--------------------------------------------------------------------+ | Parent type | :doc:`FormType ` | +---------------------------+--------------------------------------------------------------------+ From 676403e7020add302de8df03e7f37c87211ea4d8 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 21 Nov 2020 20:42:54 +0100 Subject: [PATCH 621/752] Removed 4.3 versionadded directive --- reference/configuration/framework.rst | 4 ---- 1 file changed, 4 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 9086078e30f..5d3f3cf1fde 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -2797,10 +2797,6 @@ Name of the lock you want to create. mailer ~~~~~~ -.. versionadded:: 4.3 - - The ``mailer`` settings were introduced in Symfony 4.3. - .. _mailer-dsn: dsn From 1da6b0b5e30017e126228a94893ce505ccbeb270 Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Mon, 17 Aug 2020 09:10:48 +0200 Subject: [PATCH 622/752] Complete documentation about mailer integration --- mailer.rst | 4 +++- reference/configuration/framework.rst | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/mailer.rst b/mailer.rst index ac768b09cde..8cab1b50659 100644 --- a/mailer.rst +++ b/mailer.rst @@ -46,6 +46,7 @@ over SMTP by configuring the DSN in your ``.env`` file (the ``user``, xsi:schemaLocation="http://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + @@ -55,6 +56,7 @@ over SMTP by configuring the DSN in your ``.env`` file (the ``user``, // config/packages/mailer.php use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; + return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->extension('framework', [ 'mailer' => [ @@ -83,7 +85,7 @@ sendmail ``sendmail://default`` Mailer uses the local se Using a 3rd Party Transport ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Instead of using your own SMTP server, you can send emails via a 3rd party +Instead of using your own SMTP server or sendmail binary, you can send emails via a 3rd party provider. Mailer supports several - install whichever you want: ================== ============================================= diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 3174485f516..8fc30e2712a 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -155,6 +155,7 @@ Configuration * :ref:`dsn ` * `transports`_ + * `message_bus`_ * `envelope`_ * `sender`_ @@ -846,6 +847,8 @@ can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM- .. _http-headers: +.. _http-headers: + headers ....... @@ -2813,6 +2816,18 @@ transports A :ref:`list of DSN ` that can be used by the mailer. A transport name is the key and the dsn is the value. +message_bus +........... + +.. versionadded:: 5.1 + + The ``message_bus`` option was introduced in Symfony 5.1. + +**type**: ``string`` **default**: ``null`` or default bus if Messenger component is installed + +Service identifier of the message bus to use when using the +:doc:`Messenger component ` (e.g. ``messenger.default_bus``). + envelope ........ @@ -2867,6 +2882,7 @@ recipients set in the code. // config/packages/mailer.php namespace Symfony\Component\DependencyInjection\Loader\Configurator; + return static function (ContainerConfigurator $containerConfigurator): void { $containerConfigurator->extension('framework', [ 'mailer' => [ From a389dfb123e3bd9b6024399e21067c40822944ff Mon Sep 17 00:00:00 2001 From: Laurent VOULLEMIER Date: Mon, 17 Aug 2020 09:10:48 +0200 Subject: [PATCH 623/752] Complete documentation about mailer integration --- mailer.rst | 20 +++++++++++++------- reference/configuration/framework.rst | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/mailer.rst b/mailer.rst index 200064fbbef..60575fed9e9 100644 --- a/mailer.rst +++ b/mailer.rst @@ -73,14 +73,20 @@ over SMTP by configuring the DSN in your ``.env`` file (the ``user``, Using Built-in Transports ~~~~~~~~~~~~~~~~~~~~~~~~~ -============ ======================================== ============================== +.. versionadded:: 5.2 + + The native protocol was introduced in Symfony 5.2. + +============ ======================================== ============================================================== DSN protocol Example Description -============ ======================================== ============================== -smtp ``smtp://user:pass@smtp.example.com:25`` Mailer uses an SMTP server to - send emails -sendmail ``sendmail://default`` Mailer uses the local sendmail - binary to send emails -============ ======================================== ============================== +============ ======================================== ============================================================== +smtp ``smtp://user:pass@smtp.example.com:25`` Mailer uses an SMTP server to send emails +sendmail ``sendmail://default`` Mailer uses the local sendmail binary to send emails +native ``native://default`` Mailer uses the sendmail binary and options configured + in the ``sendmail_path`` setting of ``php.ini``. On Windows + hosts, Mailer fallbacks to ``smtp`` and ``smtp_port`` + ``php.ini`` settings when ``sendmail_path`` is not configured. +============ ======================================== ============================================================== Using a 3rd Party Transport ~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 38388ad21f9..fdc11499c4b 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -184,6 +184,8 @@ Configuration * `sender`_ * `recipients`_ + * :ref:`headers ` + * `php_errors`_ * `log`_ @@ -927,8 +929,6 @@ This setting is automatically set to true when one of the child settings is conf .. _http-headers: -.. _http-headers: - headers ....... @@ -3091,6 +3091,20 @@ recipients set in the code. ]); }; +.. _mailer-headers: + +headers +....... + +.. versionadded:: 5.2 + + The ``headers`` mailer option was introduced in Symfony 5.2. + +**type**: ``array`` + +Headers to add to emails. The key (``name`` attribute in xml format) is the +header name and value the header value. + workflows ~~~~~~~~~ From 6b04c5f824e178cb6b0d9575b2068a0c56839c7e Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 21 Nov 2020 21:09:19 +0100 Subject: [PATCH 624/752] Removed duplicated line --- reference/configuration/framework.rst | 2 -- 1 file changed, 2 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 8fc30e2712a..0780b49b0b9 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -847,8 +847,6 @@ can be separated by colons, commas or spaces (e.g. ``'RC4-SHA:TLS13-AES-128-GCM- .. _http-headers: -.. _http-headers: - headers ....... From 034727f94ce8f1247d3ea7c18ff1bb2730522a41 Mon Sep 17 00:00:00 2001 From: Timo Bakx Date: Sat, 21 Nov 2020 18:34:04 +0100 Subject: [PATCH 625/752] [Form] Fixed the layout in the forms page by moving the configuration tabs outside the versionadded block. --- forms.rst | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/forms.rst b/forms.rst index f7acdd18fe2..832a11ca075 100644 --- a/forms.rst +++ b/forms.rst @@ -560,46 +560,51 @@ To see the second approach - adding constraints to the form - and to learn more about the validation constraints, please refer to the :doc:`Symfony validation documentation `. +Form Validation Messages +~~~~~~~~~~~~~~~~~~~~~~~~ + .. versionadded:: 5.2 - In Symfony 5.2, the form validation messages have been rewritten to be more - user-friendly. Set the ``legacy_error_messages`` option to ``false`` to - enable these new messages: + The ``framework.form.legacy_error_messages`` option was introduced in Symfony 5.2 - .. configuration-block:: +The form validation messages have been rewritten to be more user-friendly. +To enable these new messages set the ``legacy_error_messages`` option in ``framework``, +``form`` to ``false``: + +.. configuration-block:: - .. code-block:: yaml + .. code-block:: yaml - # config/packages/framework.yaml - framework: - form: - legacy_error_messages: false + # config/packages/framework.yaml + framework: + form: + legacy_error_messages: false - .. code-block:: xml + .. code-block:: xml - - - + + + - - - - + + + + - .. code-block:: php + .. code-block:: php - // config/packages/framework.php - $container->loadFromExtension('framework', [ - 'form' => [ - 'legacy-error-messages' => false, - ], - ]); + // config/packages/framework.php + $container->loadFromExtension('framework', [ + 'form' => [ + 'legacy_error_messages' => false, + ], + ]); Other Common Form Features -------------------------- From c4b9fc43192dbec06c0646b18b9afa529537f664 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 21 Nov 2020 23:11:15 +0100 Subject: [PATCH 626/752] [#14589] Reworded form error messages paragraph --- forms.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/forms.rst b/forms.rst index 832a11ca075..f6935d3d107 100644 --- a/forms.rst +++ b/forms.rst @@ -565,11 +565,11 @@ Form Validation Messages .. versionadded:: 5.2 - The ``framework.form.legacy_error_messages`` option was introduced in Symfony 5.2 + The ``legacy_error_messages`` option was introduced in Symfony 5.2 -The form validation messages have been rewritten to be more user-friendly. -To enable these new messages set the ``legacy_error_messages`` option in ``framework``, -``form`` to ``false``: +The form types have default error messages that are more clear and +user-friendly than the ones provided by the validation constraints. To enable +these new messages set the ``legacy_error_messages`` option to ``false``: .. configuration-block:: From b6777219bd16a04857f4cf3570a852fca5def089 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 21 Nov 2020 23:14:00 +0100 Subject: [PATCH 627/752] Fixed build --- reference/configuration/framework.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 5d9459ce97d..fdc11499c4b 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -927,6 +927,8 @@ enabled Whether to enable the support for retry failed HTTP request or not. This setting is automatically set to true when one of the child settings is configured. +.. _http-headers: + headers ....... From 07230432e2a85a77ca575abb771e597b06b1ad28 Mon Sep 17 00:00:00 2001 From: Matthieu DANET Date: Tue, 24 Nov 2020 10:35:10 +0100 Subject: [PATCH 628/752] Fix wrong key name --- reference/forms/types/options/choice_attr.rst.inc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/forms/types/options/choice_attr.rst.inc b/reference/forms/types/options/choice_attr.rst.inc index b26f2099023..5a0add4f195 100644 --- a/reference/forms/types/options/choice_attr.rst.inc +++ b/reference/forms/types/options/choice_attr.rst.inc @@ -49,7 +49,7 @@ If an array, the keys of the ``choices`` array must be used as keys:: // ... $builder->add('choices', ChoiceType::class, [ - 'choice_label' => ChoiceList::attr($this, function (?Category $category) { + 'choice_attr' => ChoiceList::attr($this, function (?Category $category) { return $category ? ['data-uuid' => $category->getUuid()] : []; }), ]); From 67eb42f6599876ae05c8b17cc7c25792350de662 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Tue, 24 Nov 2020 21:11:35 +0200 Subject: [PATCH 629/752] Fix package name for OvhCloud notifier --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 9737df6395e..573ad0d942c 100644 --- a/notifier.rst +++ b/notifier.rst @@ -59,7 +59,7 @@ Service Package DSN ========== ================================ ==================================================== FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` -OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` +OvhCloud ``symfony/ovh-cloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` ========== ================================ ==================================================== From def35a7da9d49d627906d69aac68e0d597ceba4a Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 23 Nov 2020 15:29:56 +0100 Subject: [PATCH 630/752] [Notifier] Add better example for Slack DSN --- notifier.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/notifier.rst b/notifier.rst index 9737df6395e..cad35611ec0 100644 --- a/notifier.rst +++ b/notifier.rst @@ -149,6 +149,8 @@ Chatters are configured using the ``chatter_transports`` setting: # .env SLACK_DSN=slack://default/ID + # If your slack webhook looks like "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" then use: + SLACK_DSN=slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX .. configuration-block:: From cf8af6af4ab5f541b8f7bb155434cc769a1d301d Mon Sep 17 00:00:00 2001 From: Quentin Dequippe Date: Thu, 26 Nov 2020 09:54:54 +0100 Subject: [PATCH 631/752] Update messenger.rst --- messenger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/messenger.rst b/messenger.rst index e9253431bd4..2f33d850cbc 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1202,7 +1202,7 @@ under the transport in ``messenger.yaml``: ====================== ====================================== =================================== ``access_key`` AWS access key ``account`` Identifier of the AWS account The owner of the credentials -``auto_setup`` Whether the table should be created ``true`` +``auto_setup`` Whether the queue should be created ``true`` automatically during send / get. ``buffer_size`` Number of messages to prefetch 9 ``endpoint`` Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com From 89828678a7443848962d380b31980e22d893c75b Mon Sep 17 00:00:00 2001 From: gary houbre Date: Fri, 27 Nov 2020 12:49:56 +0100 Subject: [PATCH 632/752] Added Invalid Constant --- console.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/console.rst b/console.rst index 34dc50003f9..246ae474d48 100644 --- a/console.rst +++ b/console.rst @@ -57,6 +57,10 @@ want a command to create a user:: // or return this if some error happened during the execution // (it's equivalent to returning int(1)) // return Command::FAILURE; + + // or return this if there was invalid value during the execution + // (it's equivalent to returning int(2)) + // return Command::INVALID } } @@ -65,6 +69,10 @@ want a command to create a user:: The ``Command::SUCCESS`` and ``Command::FAILURE`` constants were introduced in Symfony 5.1. +.. versionadded:: 5.3 + + The ``Command::INVALID`` constants was introduced in Symfony 5.3 + Configuring the Command ----------------------- From d41389ad85d4812423919a7c8c1f8163006c1f38 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 27 Nov 2020 13:34:18 +0100 Subject: [PATCH 633/752] Tweak --- console.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/console.rst b/console.rst index 246ae474d48..58708719974 100644 --- a/console.rst +++ b/console.rst @@ -58,8 +58,8 @@ want a command to create a user:: // (it's equivalent to returning int(1)) // return Command::FAILURE; - // or return this if there was invalid value during the execution - // (it's equivalent to returning int(2)) + // or return this to indicate incorrect command usage; e.g. invalid options + // or missing arguments (it's equivalent to returning int(2)) // return Command::INVALID } } @@ -71,7 +71,7 @@ want a command to create a user:: .. versionadded:: 5.3 - The ``Command::INVALID`` constants was introduced in Symfony 5.3 + The ``Command::INVALID`` constant was introduced in Symfony 5.3 Configuring the Command ----------------------- From 36b60ac475fccea62f7ef338de5e26b9f2c7ed77 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 30 Nov 2020 16:43:45 +0100 Subject: [PATCH 634/752] [Security] Minor typo --- security/experimental_authenticators.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 8a1b6081d84..c86622ba84d 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -337,7 +337,7 @@ The authenticator can be enabled using the ``custom_authenticators`` setting: - App\Security\ApiKeyAuthenticator # don't forget to also configure the entry_point if the - # authenticator implements AuthenticatorEntryPointInterface + # authenticator implements AuthenticationEntryPointInterface # entry_point: App\Security\CustomFormLoginAuthenticator .. code-block:: xml @@ -409,7 +409,7 @@ well as other pieces of information, like whether a password should be checked or if "remember me" functionality should be enabled. The default -:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport`. +:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport` requires a user object and credentials. The following credential classes are supported by default: From 3c48f6898c6bf47849306e558c55158c98755da3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Malte=20Schlu=CC=88ter?= Date: Thu, 3 Dec 2020 11:24:58 +0100 Subject: [PATCH 635/752] [Notifier] Update information for slack on actual implementation --- notifier.rst | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/notifier.rst b/notifier.rst index a3bb15f2232..3145bce544c 100644 --- a/notifier.rst +++ b/notifier.rst @@ -145,29 +145,26 @@ GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_T LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` -Slack ``symfony/slack-notifier`` ``slack://default/ID`` +Slack ``symfony/slack-notifier`` ``slack://TOKEN@default?channel=CHANNEL`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` ========== ================================ =========================================================================== .. versionadded:: 5.1 - The Mattermost and RocketChat integrations were introduced in Symfony - 5.1. The Slack DSN changed in Symfony 5.1 to use Slack Incoming - Webhooks instead of legacy tokens. + The Mattermost and RocketChat integrations were introduced in Symfony 5.1. .. versionadded:: 5.2 The GoogleChat, LinkedIn, Zulip and Discord integrations were introduced in Symfony 5.2. + The Slack DSN changed in Symfony 5.2 to use Slack Web API again same as in 5.0. Chatters are configured using the ``chatter_transports`` setting: .. code-block:: bash # .env - SLACK_DSN=slack://default/ID - # If your slack webhook looks like "https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX" then use: - SLACK_DSN=slack://default/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX + SLACK_DSN=slack://TOKEN@default?channel=CHANNEL .. configuration-block:: From 9695d7ef573a24ad440c3b291bdd291fad83f390 Mon Sep 17 00:00:00 2001 From: Timo Bakx Date: Thu, 3 Dec 2020 22:24:10 +0100 Subject: [PATCH 636/752] [Debug] Added option to specify the event dispatcher in debug:event-dispatcher --- event_dispatcher.rst | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 55e99a8da34..03630c2e5f0 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -322,6 +322,18 @@ its name: $ php bin/console debug:event-dispatcher kernel.exception +For the :doc:`new experimental Security ` +an event dispatcher per firewall was added. You can get the registered listeners +for a particular event dispatcher by using the ``--dispatcher`` option: + +.. code-block:: terminal + + $ php bin/console debug:event-dispatcher --dispatcher=security.event_dispatcher.main + +.. versionadded:: 5.3 + + The ``dispatcher`` option was introduced in Symfony 5.3. + Learn more ---------- From 4677e42c58bf87f72dd75150eb41f852acf7a576 Mon Sep 17 00:00:00 2001 From: Valentin Udaltsov Date: Sat, 5 Dec 2020 21:54:21 +0300 Subject: [PATCH 637/752] Changed iterable $forms to Traversable in the data mapper implementation example --- form/data_mappers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/form/data_mappers.rst b/form/data_mappers.rst index f10d74813b0..24ff0716f5f 100644 --- a/form/data_mappers.rst +++ b/form/data_mappers.rst @@ -98,7 +98,7 @@ in your form type:: /** * @param Color|null $viewData */ - public function mapDataToForms($viewData, iterable $forms): void + public function mapDataToForms($viewData, \Traversable $forms): void { // there is no data yet, so nothing to prepopulate if (null === $viewData) { @@ -119,7 +119,7 @@ in your form type:: $forms['blue']->setData($viewData->getBlue()); } - public function mapFormsToData(iterable $forms, &$viewData): void + public function mapFormsToData(\Traversable $forms, &$viewData): void { /** @var FormInterface[] $forms */ $forms = iterator_to_array($forms); From 4e4924e22d2a53d39be593d31e895947b1d8e892 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Schl=C3=A4pfer?= Date: Sat, 5 Dec 2020 16:45:37 +0100 Subject: [PATCH 638/752] [Cache] Document cache encryption using SodiumMarshaller --- cache.rst | 83 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/cache.rst b/cache.rst index 58e3cd0b816..20d9af8999e 100644 --- a/cache.rst +++ b/cache.rst @@ -714,3 +714,86 @@ Clear all caches everywhere: .. code-block:: terminal $ php bin/console cache:pool:clear cache.global_clearer + +Encrypting the Cache +-------------------- + +.. versionadded:: 5.1 + + :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller` has been + introduced in Symfony 5.1. + +To encrypt the cache using ``libsodium``, you can use the +:class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller`. + +.. note:: + + This will encrypt the values of the cache items, but not the cache keys. Be + careful not the leak sensitive data in the keys. + +Generate a key: + +.. code-block:: terminal + + $ php -r 'echo base64_encode(sodium_crypto_box_keypair());' + +And add it to your :doc:`secret store ` as +``CACHE_DECRYPTION_KEY`` and enable the ``SodiumMarshaller``: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/cache.yaml + services: + Symfony\Component\Cache\Marshaller\SodiumMarshaller: + decorates: cache.default_marshaller + arguments: + - ['%env(base64:CACHE_DECRYPTION_KEY)%'] + # use multiple keys in order to rotate them + #- ['%env(base64:CACHE_DECRYPTION_KEY)%', '%env(base64:OLD_CACHE_DECRYPTION_KEY)%'] + - '@Symfony\Component\Cache\Marshaller\SodiumMarshaller.inner' + + .. code-block:: xml + + + + + + + + redis://localhost + + env(base64:CACHE_DECRYPTION_KEY) + + + + + + + + + .. code-block:: php + + // config/packages/cache.php + use Symfony\Component\Cache\Marshaller\SodiumMarshaller; + + $container->register(SodiumMarshaller::class) + ->decorate('cache.default_marshaller') + ->addArgument(['env(base64:CACHE_DECRYPTION_KEY)']) + // use multiple keys in order to rotate them + // ->addArgument(['env(base64:CACHE_DECRYPTION_KEY)', 'env(base64:OLD_CACHE_DECRYPTION_KEY)']) + ->addArgument(service('@Symfony\Component\Cache\Marshaller\SodiumMarshaller.inner')); + +To rotate your encryption keys but still be able to read existing cache entries, +add the old encryption key to the service arguments. The first key will be used +for reading and writing, and the additional key(s) will only be used for reading. + +Once all cache items encrypted with the old key have expired, you can remove +`OLD_CACHE_DECRYPTION_KEY` completely. From 54fdf7a0771a2ea5a49886bd6cda6a7595d76742 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sun, 6 Dec 2020 12:16:03 +0100 Subject: [PATCH 639/752] [#14658] Minor tweaks to cache encryption section --- cache.rst | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/cache.rst b/cache.rst index 20d9af8999e..5f31c495e4b 100644 --- a/cache.rst +++ b/cache.rst @@ -720,31 +720,28 @@ Encrypting the Cache .. versionadded:: 5.1 - :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller` has been - introduced in Symfony 5.1. + The :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller` + class was introduced in Symfony 5.1. To encrypt the cache using ``libsodium``, you can use the :class:`Symfony\\Component\\Cache\\Marshaller\\SodiumMarshaller`. -.. note:: - - This will encrypt the values of the cache items, but not the cache keys. Be - careful not the leak sensitive data in the keys. - -Generate a key: +First, you need to generate a secure key and add it to your :doc:`secret +store ` as ``CACHE_DECRYPTION_KEY``: .. code-block:: terminal $ php -r 'echo base64_encode(sodium_crypto_box_keypair());' -And add it to your :doc:`secret store ` as -``CACHE_DECRYPTION_KEY`` and enable the ``SodiumMarshaller``: +Then, register the ``SodiumMarshaller`` service using this key: .. configuration-block:: .. code-block:: yaml # config/packages/cache.yaml + + # ... services: Symfony\Component\Cache\Marshaller\SodiumMarshaller: decorates: cache.default_marshaller @@ -766,13 +763,14 @@ And add it to your :doc:`secret store ` as http://symfony.com/schema/dic/symfony https://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> + + - redis://localhost env(base64:CACHE_DECRYPTION_KEY) - + @@ -783,17 +781,22 @@ And add it to your :doc:`secret store ` as // config/packages/cache.php use Symfony\Component\Cache\Marshaller\SodiumMarshaller; + use Symfony\Component\DependencyInjection\ChildDefinition; + use Symfony\Component\DependencyInjection\Reference; - $container->register(SodiumMarshaller::class) - ->decorate('cache.default_marshaller') + // ... + $container->setDefinition(SodiumMarshaller::class, new ChildDefinition('cache.default_marshaller')) ->addArgument(['env(base64:CACHE_DECRYPTION_KEY)']) // use multiple keys in order to rotate them - // ->addArgument(['env(base64:CACHE_DECRYPTION_KEY)', 'env(base64:OLD_CACHE_DECRYPTION_KEY)']) - ->addArgument(service('@Symfony\Component\Cache\Marshaller\SodiumMarshaller.inner')); + //->addArgument(['env(base64:CACHE_DECRYPTION_KEY)', 'env(base64:OLD_CACHE_DECRYPTION_KEY)']) + ->addArgument(new Reference(SodiumMarshaller::class.'.inner')); -To rotate your encryption keys but still be able to read existing cache entries, -add the old encryption key to the service arguments. The first key will be used -for reading and writing, and the additional key(s) will only be used for reading. +.. caution:: + + This will encrypt the values of the cache items, but not the cache keys. Be + careful not the leak sensitive data in the keys. -Once all cache items encrypted with the old key have expired, you can remove -`OLD_CACHE_DECRYPTION_KEY` completely. +When configuring multiple keys, the first key will be used for reading and +writing, and the additional key(s) will only be used for reading. Once all +cache items encrypted with the old key have expired, you can remove +``OLD_CACHE_DECRYPTION_KEY`` completely. From e60cd0edd2ebd14a577ab18a9d404835c79dd2d2 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Fri, 4 Dec 2020 11:51:53 +0100 Subject: [PATCH 640/752] Added config reference for router.default_uri --- reference/configuration/framework.rst | 9 +++++++++ routing.rst | 2 ++ 2 files changed, 11 insertions(+) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 0780b49b0b9..833329a8d44 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -190,6 +190,7 @@ Configuration * `router`_ + * `default_uri`_ * `http_port`_ * `https_port`_ * `resource`_ @@ -1145,6 +1146,14 @@ 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``, ``.yaml``, ``.php``). +default_uri +........... + +**type**: ``string`` + +The default URI used to generate URLs in a non-HTTP context (see +:ref:`Generating URLs in Commands `). + http_port ......... diff --git a/routing.rst b/routing.rst index e8f5bb91b83..ec6de557b5d 100644 --- a/routing.rst +++ b/routing.rst @@ -2055,6 +2055,8 @@ If you need to generate URLs dynamically or if you are using pure JavaScript code, this solution doesn't work. In those cases, consider using the `FOSJsRoutingBundle`_. +.. _router-generate-urls-commands: + Generating URLs in Commands ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 2ed719f9b47fdc5e87a3253d19f7a1f853de0c15 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Dec 2020 08:24:35 +0100 Subject: [PATCH 641/752] Added the versionadded directive --- reference/configuration/framework.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 833329a8d44..0e61184b6be 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1151,6 +1151,10 @@ default_uri **type**: ``string`` +.. versionadded:: 5.1 + + The ``default_uri`` option was introduced in Symfony 5.1. + The default URI used to generate URLs in a non-HTTP context (see :ref:`Generating URLs in Commands `). From e68926ff9c76c82081de84c515d71e85280e07d2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 7 Dec 2020 08:27:54 +0100 Subject: [PATCH 642/752] Reword --- event_dispatcher.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index 03630c2e5f0..ed6740cc162 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -322,9 +322,9 @@ its name: $ php bin/console debug:event-dispatcher kernel.exception -For the :doc:`new experimental Security ` -an event dispatcher per firewall was added. You can get the registered listeners -for a particular event dispatcher by using the ``--dispatcher`` option: +The :doc:`new experimental Security ` +system adds an event dispatcher per firewall. Use the ``--dispatcher`` option to +get the registered listeners for a particular event dispatcher: .. code-block:: terminal From 3f0bf94b2a5a93df1950fa06588777032e4f02c3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sat, 5 Dec 2020 17:28:42 +0100 Subject: [PATCH 643/752] [EventDispatcher] Show partial matching for debug:event-dispatcher --- event_dispatcher.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/event_dispatcher.rst b/event_dispatcher.rst index ed6740cc162..038a405b10b 100644 --- a/event_dispatcher.rst +++ b/event_dispatcher.rst @@ -322,6 +322,17 @@ its name: $ php bin/console debug:event-dispatcher kernel.exception +or can get everything which partial matches the event name: + +.. code-block:: terminal + + $ php bin/console debug:event-dispatcher kernel // matches "kernel.exception", "kernel.response" etc. + $ php bin/console debug:event-dispatcher Security // matches "Symfony\Component\Security\Http\Event\CheckPassportEvent" + +.. versionadded:: 5.3 + + The ability to match partial event names was introduced in Symfony 5.3. + The :doc:`new experimental Security ` system adds an event dispatcher per firewall. Use the ``--dispatcher`` option to get the registered listeners for a particular event dispatcher: From bd44d05db34f5c9b624cadbbdbd042e34bf23e10 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 7 Dec 2020 12:03:43 +0100 Subject: [PATCH 644/752] minor --- notifier/chatters.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index 40e9cea2096..1183de984d7 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -46,9 +46,9 @@ you to send messages to chat services like Slack or Telegram:: Adding Interactions to a Slack Message -------------------------------------- -With a Slack message, you can use the -:class:`Symfony\\Component\\Notifier\\Bridge\\Slack\\SlackOptions` to add -some interactive options called `Block elements`_:: +With a Slack message, you can use the +:class:`Symfony\\Component\\Notifier\\Bridge\\Slack\\SlackOptions` class +to add some interactive options called `Block elements`_:: use Symfony\Component\Notifier\Bridge\Slack\Block\SlackActionsBlock; use Symfony\Component\Notifier\Bridge\Slack\Block\SlackDividerBlock; From f62f89a054c59166adf51375501b120691b04bf7 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 7 Dec 2020 12:04:43 +0100 Subject: [PATCH 645/752] minor --- notifier/chatters.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index 50f3e5bc20f..4a10ad109d2 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -104,8 +104,8 @@ Adding Interactions to a Discord Message ---------------------------------------- With a Discord message, you can use the -:class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` to add -some interactive options called `Embed elements`_:: +:class:`Symfony\\Component\\Notifier\\Bridge\\Discord\\DiscordOptions` class +to add some interactive options called `Embed elements`_:: use Symfony\Component\Notifier\Bridge\Discord\DiscordOptions; use Symfony\Component\Notifier\Bridge\Discord\Embeds\DiscordEmbed; From 25c651959497529779d3d2ec7ca0dae8744dd2c1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 7 Dec 2020 12:10:03 +0100 Subject: [PATCH 646/752] Use constant over int. refs #14648 --- console/lockable_trait.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/lockable_trait.rst b/console/lockable_trait.rst index 7745874a764..9c77073d087 100644 --- a/console/lockable_trait.rst +++ b/console/lockable_trait.rst @@ -38,8 +38,8 @@ that adds two convenient methods to lock and release commands:: // if not released explicitly, Symfony releases the lock // automatically when the execution of the command ends $this->release(); - - return 0; + + return Command:SUCCESS; } } From 4239d4eb515786acdc698f302bc36339007a0ef5 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 7 Dec 2020 15:08:01 +0100 Subject: [PATCH 647/752] minor --- console.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/console.rst b/console.rst index 25dd6b76924..18f39f1edd4 100644 --- a/console.rst +++ b/console.rst @@ -45,7 +45,7 @@ want a command to create a user:: protected function execute(InputInterface $input, OutputInterface $output) { - // ... put here the code to to create the user + // ... put here the code to create the user // this method must return an integer number with the "exit status code" // of the command. You can also use these constants to make code more readable From 46d1f1ae56fbb04df4ff050e6efa9673fb5165de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Renan=20Gon=C3=A7alves?= Date: Mon, 7 Dec 2020 15:34:33 +0100 Subject: [PATCH 648/752] Support Redis Sentinel mode when using phpredis/phpredis extension See https://github.com/symfony/symfony/pull/39363 --- components/cache/adapters/redis_adapter.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/cache/adapters/redis_adapter.rst b/components/cache/adapters/redis_adapter.rst index 64bf7ab9e4c..7846cde5200 100644 --- a/components/cache/adapters/redis_adapter.rst +++ b/components/cache/adapters/redis_adapter.rst @@ -95,8 +95,8 @@ Below are common examples of valid DSNs showing a combination of available value ); `Redis Sentinel`_, which provides high availability for Redis, is also supported -when using the Predis library. Use the ``redis_sentinel`` parameter to set the -name of your service group:: +when using the PHP Redis Extension v5.2+ or the Predis library. Use the ``redis_sentinel`` +parameter to set the name of your service group:: RedisAdapter::createConnection( 'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster' From fb8dea5501e50386f7ed9d7e9d83750055a75540 Mon Sep 17 00:00:00 2001 From: Florent <73140597+flovrent@users.noreply.github.com> Date: Mon, 7 Dec 2020 16:52:47 +0100 Subject: [PATCH 649/752] Update mercure.rst --- mercure.rst | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/mercure.rst b/mercure.rst index 8c0f52f8039..9222ddc68c5 100644 --- a/mercure.rst +++ b/mercure.rst @@ -408,7 +408,7 @@ And here is the controller:: // src/Controller/DiscoverController.php namespace App\Controller; - use Lcobucci\JWT\Builder; + use Lcobucci\JWT\Configuration; use Lcobucci\JWT\Signer\Hmac\Sha256; use Lcobucci\JWT\Signer\Key; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; @@ -423,11 +423,14 @@ And here is the controller:: { $hubUrl = $this->getParameter('mercure.default_hub'); $this->addLink($request, new Link('mercure', $hubUrl)); - - $token = (new Builder()) - // set other appropriate JWT claims, such as an expiration date - ->withClaim('mercure', ['subscribe' => ["http://example.com/books/1"]]) // can also be a URI template, or * - ->getToken(new Sha256(), new Key($this->getParameter('mercure_secret_key'))); // don't forget to set this parameter! Test value: !ChangeMe! + + $key = Key\InMemory::plainText('mercure_secret_key'); // don't forget to set this parameter! Test value: !ChangeMe! + $configuration = Configuration::forSymmetricSigner(new Sha256(), $key); + + $token = $configuration->builder() + ->withClaim('mercure', ['subscribe' => ["http://example.com/books/1"]]) // can also be a URI template, or * + ->getToken($configuration->signer(), $configuration->signingKey()) + ->toString(); $response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']); $cookie = Cookie::create('mercureAuthorization') From 8c21f36cb139d30907404fa831fe1cd8e499fccf Mon Sep 17 00:00:00 2001 From: Julien Falque Date: Wed, 29 Jul 2020 18:35:18 +0200 Subject: [PATCH 650/752] Document routing inline requirements and defaults for host --- routing.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/routing.rst b/routing.rst index d879feac6e3..39cb575ed8d 100644 --- a/routing.rst +++ b/routing.rst @@ -790,6 +790,11 @@ concise, but it can decrease route readability when requirements are complex: // ... }; +.. versionadded:: 5.2 + + Since Symfony 5.2, inline parameter requirements are also supported in the + host. Before Symfony 5.2, they were supported in the path only. + Optional Parameters ~~~~~~~~~~~~~~~~~~~ @@ -984,6 +989,11 @@ parameter: To give a ``null`` default value to any parameter, add nothing after the ``?`` character (e.g. ``/blog/{page?}``). +.. versionadded:: 5.2 + + Since Symfony 5.2, inline parameter default values are also supported in + the host. Before Symfony 5.2, they were supported in the path only. + Priority Parameter ~~~~~~~~~~~~~~~~~~ From d232aa9f524045720b2d6d1b114440911a3470c8 Mon Sep 17 00:00:00 2001 From: Peter Bottenberg Date: Fri, 30 Oct 2020 17:55:57 +0100 Subject: [PATCH 651/752] [Notifier] Add documentation for telegram options --- notifier/chatters.rst | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/notifier/chatters.rst b/notifier/chatters.rst index 9d03f83987c..764f05320a8 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -98,8 +98,6 @@ some interactive options called `Block elements`_:: $chatter->send($chatMessage); -.. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements - Adding Interactions to a Discord Message ---------------------------------------- @@ -151,4 +149,38 @@ some interactive options called `Embed elements`_:: $chatter->send($chatMessage); +Adding Interactions to a Telegram Message +----------------------------------------- + +With a Telegram message, you can use the +:class:`Symfony\\Component\\Notifier\\Bridge\\Telegram\\TelegramOptions` class +to add `message options`_:: + + use Symfony\Component\Notifier\Bridge\Telegram\Reply\Markup\Button\InlineKeyboardButton; + use Symfony\Component\Notifier\Bridge\Telegram\Reply\Markup\InlineKeyboardMarkup; + use Symfony\Component\Notifier\Bridge\Telegram\TelegramOptions; + use Symfony\Component\Notifier\Message\ChatMessage; + + $chatMessage = new ChatMessage(''); + + // Create Telegram options + $telegramOptions = (new TelegramOptions()) + ->chatId('@symfonynotifierdev') + ->parseMode('MarkdownV2') + ->disableWebPagePreview(true) + ->disableNotification(true) + ->replyMarkup((new InlineKeyboardMarkup()) + ->inlineKeyboard([ + (new InlineKeyboardButton('Visit symfony.com')) + ->url('https://symfony.com/'), + ]) + ); + + // Add the custom options to the chat message and send the message + $chatMessage->options($telegramOptions); + + $chatter->send($chatMessage); + +.. _`Block elements`: https://api.slack.com/reference/block-kit/block-elements .. _`Embed elements`: https://discord.com/developers/docs/resources/webhook +.. _`message options`: https://core.telegram.org/bots/api From 8cf987fceb64f0974e0e289a190f9951b1d2d01c Mon Sep 17 00:00:00 2001 From: Steven DUBOIS Date: Mon, 7 Dec 2020 18:09:06 +0100 Subject: [PATCH 652/752] Update experimental_authenticators : add UserBadge --- security/experimental_authenticators.rst | 36 +++++++++++++----------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 382469c4566..2870eab1830 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -295,8 +295,8 @@ method that fits most use-cases:: use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException; - use Symfony\Component\Security\Core\Exception\UsernameNotFoundException; use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator; + use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport; @@ -328,14 +328,7 @@ method that fits most use-cases:: throw new CustomUserMessageAuthenticationException('No API token provided'); } - $user = $this->entityManager->getRepository(User::class) - ->findOneBy(['apiToken' => $apiToken]) - ; - if (null === $user) { - throw new UsernameNotFoundException(); - } - - return new SelfValidatingPassport($user); + return new SelfValidatingPassport(new UserBadge($apiToken)); } public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response @@ -472,12 +465,23 @@ are supported by default: $apiToken )); -.. note:: - If you don't need any credentials to be checked (e.g. a JWT token), you - can use the - :class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\SelfValidatingPassport`. - This class only requires a user and optionally `Passport Badges`_. +Self Validating Passport +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +If you don't need any credentials to be checked (e.g. a JWT token), you can use the +:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\SelfValidatingPassport`. +This class only requires a ``UserBadge`` object and optionally `Passport Badges`_. + +You can also pass a user loader to the ``UserBadge``. This callable receives the +``$userIdentifier`` as argument and must return a ``UserInterface`` object +(otherwise a ``UsernameNotFoundException`` is thrown). If this is not set, +the default user provider will be used with ``$userIdentifier`` as username:: + + // ... + return new SelfValidatingPassport(new UserBadge($email, function ($username) { + return $this->userRepository->findOneBy(['email' => $username]); + }); + Passport Badges ~~~~~~~~~~~~~~~ @@ -547,7 +551,7 @@ authenticator, you would initialize the passport like this:: ``createAuthenticatedToken()``):: // ... - use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; + use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; class LoginAuthenticator extends AbstractAuthenticator { @@ -557,7 +561,7 @@ authenticator, you would initialize the passport like this:: { // ... process the request - $passport = new SelfValidatingPassport($username, []); + $passport = new SelfValidatingPassport(new UserBadge($username), []); // set a custom attribute (e.g. scope) $passport->setAttribute('scope', $oauthScope); From 01cb2b0937d849aeffff344ead36626aaa93d4ea Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Tue, 8 Dec 2020 15:20:20 +0100 Subject: [PATCH 653/752] [#14672] Updated more docs related to the UserBadge --- security/experimental_authenticators.rst | 88 ++++++++++++++++-------- 1 file changed, 61 insertions(+), 27 deletions(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 2870eab1830..35aa1c9c205 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -435,23 +435,61 @@ into a security Security Passports ~~~~~~~~~~~~~~~~~~ +.. versionadded:: 5.2 + + The ``UserBadge`` was introduced in Symfony 5.2. Prior to 5.2, the user + instance was provided directly to the passport. + A passport is an object that contains the user that will be authenticated as well as other pieces of information, like whether a password should be checked or if "remember me" functionality should be enabled. The default :class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Passport` -requires a user object and credentials. The following credential classes -are supported by default: +requires a user and credentials. + +Use the +:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Badge\\UserBadge` +to attach the user to the passport. The ``UserBadge`` requires a user +identifier (e.g. the username or email), which is used to load the user +using :ref:`the user provider `:: + + use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; + + // ... + $passport = new Passport(new UserBadge($email), $credentials); + +.. note:: + You can optionally pass a user loader as second argument to the + ``UserBadge``. This callable receives the ``$userIdentifier`` + and must return a ``UserInterface`` object (otherwise a + ``UsernameNotFoundException`` is thrown):: + + // ... + $passport = new Passport( + new UserBadge($email, function ($userIdentifier) { + return $this->userRepository->findOneBy(['email' => $userIdentifier]); + }), + $credentials + ); + +The following credential classes are supported by default: :class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Credentials\\PasswordCredentials` This requires a plaintext ``$password``, which is validated using the - :ref:`password encoder configured for the user `. + :ref:`password encoder configured for the user `:: + + use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\PasswordCredentials; + + // ... + return new Passport($user, new PasswordCredentials($plaintextPassword)); :class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\Credentials\\CustomCredentials` Allows a custom closure to check credentials:: + use Symfony\Component\Security\Http\Authenticator\Passport\Credentials\CustomCredentials; + // ... return new Passport($user, new CustomCredentials( // If this function returns anything else than `true`, the credentials @@ -467,21 +505,13 @@ are supported by default: Self Validating Passport -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -If you don't need any credentials to be checked (e.g. a JWT token), you can use the -:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\SelfValidatingPassport`. -This class only requires a ``UserBadge`` object and optionally `Passport Badges`_. - -You can also pass a user loader to the ``UserBadge``. This callable receives the -``$userIdentifier`` as argument and must return a ``UserInterface`` object -(otherwise a ``UsernameNotFoundException`` is thrown). If this is not set, -the default user provider will be used with ``$userIdentifier`` as username:: - - // ... - return new SelfValidatingPassport(new UserBadge($email, function ($username) { - return $this->userRepository->findOneBy(['email' => $username]); - }); +........................ +If you don't need any credentials to be checked (e.g. when using API +tokens), you can use the +:class:`Symfony\\Component\\Security\\Http\\Authenticator\\Passport\\SelfValidatingPassport`. +This class only requires a ``UserBadge`` object and optionally `Passport +Badges`_. Passport Badges ~~~~~~~~~~~~~~~ @@ -511,8 +541,13 @@ the following badges are supported: initiated). This skips the :doc:`pre-authentication user checker `. -For instance, if you want to add CSRF and password migration to your custom -authenticator, you would initialize the passport like this:: +.. versionadded:: 5.2 + + Since 5.2, the ``PasswordUpgradeBadge`` is automatically added to + the passport if the passport has ``PasswordCredentials``. + +For instance, if you want to add CSRF to your custom authenticator, you +would initialize the passport like this:: // src/Service/LoginAuthenticator.php namespace App\Service; @@ -520,7 +555,7 @@ authenticator, you would initialize the passport like this:: // ... use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator; use Symfony\Component\Security\Http\Authenticator\Passport\Badge\CsrfTokenBadge; - use Symfony\Component\Security\Http\Authenticator\Passport\Badge\PasswordUpgradeBadge; + use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge; use Symfony\Component\Security\Http\Authenticator\Passport\Passport; use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface; @@ -532,14 +567,13 @@ authenticator, you would initialize the passport like this:: $username = $request->request->get('username'); $csrfToken = $request->request->get('csrf_token'); - // ... get the $user from the $username and validate no - // parameter is empty + // ... validate no parameter is empty - return new Passport($user, new PasswordCredentials($password), [ - // $this->userRepository must implement PasswordUpgraderInterface - new PasswordUpgradeBadge($password, $this->userRepository), - new CsrfTokenBadge('login', $csrfToken), - ]); + return new Passport( + new UserBadge($user), + new PasswordCredentials($password), + [new CsrfTokenBadge('login', $csrfToken)] + ); } } From 1ae411bfcd845af42b14bcd61295f2851009c38b Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Wed, 9 Dec 2020 11:39:05 +0100 Subject: [PATCH 654/752] [#14671] Added example of inline host defaults/requirements --- routing.rst | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/routing.rst b/routing.rst index 39cb575ed8d..bcd6daec811 100644 --- a/routing.rst +++ b/routing.rst @@ -790,11 +790,6 @@ concise, but it can decrease route readability when requirements are complex: // ... }; -.. versionadded:: 5.2 - - Since Symfony 5.2, inline parameter requirements are also supported in the - host. Before Symfony 5.2, they were supported in the path only. - Optional Parameters ~~~~~~~~~~~~~~~~~~~ @@ -989,11 +984,6 @@ parameter: To give a ``null`` default value to any parameter, add nothing after the ``?`` character (e.g. ``/blog/{page?}``). -.. versionadded:: 5.2 - - Since Symfony 5.2, inline parameter default values are also supported in - the host. Before Symfony 5.2, they were supported in the path only. - Priority Parameter ~~~~~~~~~~~~~~~~~~ @@ -2046,6 +2036,16 @@ these routes. // ['HTTP_HOST' => 'm.' . $client->getContainer()->getParameter('domain')] ); +.. tip:: + + You can also use the inline defaults and requirements format in the + ``host`` option: ``{subdomain?m}.example.com`` + +.. versionadded:: 5.2 + + Inline parameter default values support in hosts were introduced in + Symfony 5.2. Prior to Symfony 5.2, they were supported in the path only. + .. _i18n-routing: Localized Routes (i18n) From 6fc13f253eda907f73ef2ededdbb77a3a3521e3f Mon Sep 17 00:00:00 2001 From: Alexander Frolov Date: Wed, 9 Dec 2020 13:00:18 -0500 Subject: [PATCH 655/752] Update setup page for Symfony 5.2 - drop dev Since 5.2 is already released there is no reason to point to `next` version When merged, fixes #14663 --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index 8e8f7c5610e..dbcb153dac7 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --version=next --full + $ symfony new my_project_name --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name --version=next + $ symfony new my_project_name The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton:"5.2.x@dev" my_project_name + $ composer create-project symfony/website-skeleton my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton:"5.2.x@dev" my_project_name + $ composer create-project symfony/skeleton my_project_name 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 2773a4168977aa98371a578759a78df7ae15037c Mon Sep 17 00:00:00 2001 From: Alexander Frolov Date: Wed, 9 Dec 2020 13:07:12 -0500 Subject: [PATCH 656/752] Update setup page for Symfony 5.1 - add version Since 5.2 is now the current version it makes sense to add version to `symfony` and `composer create-project` example commands --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index dbcb153dac7..5ad11c5b693 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --full + $ symfony new my_project_name --version=5.1 --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name + $ symfony new my_project_name --version=5.1 The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton my_project_name + $ composer create-project symfony/website-skeleton:"5.1.*" my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton my_project_name + $ composer create-project symfony/skeleton:"5.1.*" my_project_name 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 8e39f4592c1094898a3abc50728e72c30d2509d9 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Thu, 10 Dec 2020 12:39:49 +0100 Subject: [PATCH 657/752] Updated Composer commands to install 5.3@dev --- setup.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/setup.rst b/setup.rst index dbcb153dac7..0433e8af360 100644 --- a/setup.rst +++ b/setup.rst @@ -50,10 +50,10 @@ application: .. code-block:: terminal # run this if you are building a traditional web application - $ symfony new my_project_name --full + $ symfony new my_project_name --version=next --full # run this if you are building a microservice, console application or API - $ symfony new my_project_name + $ symfony new my_project_name --version=next The only difference between these two commands is the number of packages installed by default. The ``--full`` option installs all the packages that you @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton my_project_name + $ composer create-project symfony/website-skeleton:"5.3.x@dev' my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton my_project_name + $ composer create-project symfony/skeleton:"5.3.x@dev' my_project_name 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 f7ae0fa09d5d4680b12b03cb4112912e98090133 Mon Sep 17 00:00:00 2001 From: Pierre du Plessis Date: Fri, 11 Dec 2020 10:31:38 +0200 Subject: [PATCH 658/752] Fix config keys for rate limiter The `lock` and `storage` keys have been updated to `lock_factory` and `storage_service` respectively. --- rate_limiter.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index f5473607fe7..403aa9c462f 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -260,8 +260,8 @@ Rate Limiter Storage and Locking -------------------------------- Rate limiters use the default cache and locking mechanisms defined in your -Symfony application. If you prefer to change that, use the ``lock`` and -``storage`` options: +Symfony application. If you prefer to change that, use the ``lock_factory`` and +``storage_service`` options: .. code-block:: yaml @@ -274,9 +274,9 @@ Symfony application. If you prefer to change that, use the ``lock`` and cache_pool: 'app.redis_cache' # or define a service implementing StorageInterface to use a different # mechanism to store the limiter information - storage: 'App\RateLimiter\CustomRedisStorage' + storage_service: 'App\RateLimiter\CustomRedisStorage' # the value is the name of any lock defined in your application - lock: 'app.rate_limiter_lock' + lock_factory: 'app.rate_limiter_lock' .. _`token bucket algorithm`: https://en.wikipedia.org/wiki/Token_bucket .. _`PHP date relative formats`: https://www.php.net/datetime.formats.relative From 25e530fba5ce6cb43abbdd0e04aabc1392451e0e Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 11 Dec 2020 16:02:44 +0100 Subject: [PATCH 659/752] Fixed code syntax of previous change --- mercure.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mercure.rst b/mercure.rst index 9222ddc68c5..c533c07fad7 100644 --- a/mercure.rst +++ b/mercure.rst @@ -428,9 +428,9 @@ And here is the controller:: $configuration = Configuration::forSymmetricSigner(new Sha256(), $key); $token = $configuration->builder() - ->withClaim('mercure', ['subscribe' => ["http://example.com/books/1"]]) // can also be a URI template, or * - ->getToken($configuration->signer(), $configuration->signingKey()) - ->toString(); + ->withClaim('mercure', ['subscribe' => ["http://example.com/books/1"]]) // can also be a URI template, or * + ->getToken($configuration->signer(), $configuration->signingKey()) + ->toString(); $response = $this->json(['@id' => '/demo/books/1', 'availability' => 'https://schema.org/InStock']); $cookie = Cookie::create('mercureAuthorization') From 0406cc4c0b38ceb54ec1c43eb3a46c3a227ddaa8 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 11 Dec 2020 17:34:55 +0100 Subject: [PATCH 660/752] [Uid] Mention the Doctrine type hinting of UUID/ULID values --- components/uid.rst | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/components/uid.rst b/components/uid.rst index 287789ac368..e5888c66b88 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -168,6 +168,35 @@ entity primary keys:: The UUID types and generators were introduced in Symfony 5.2. +When using built-in Doctrine repository methods (e.g. ``findOneBy()``), Doctrine +knows how to convert these UUID types to build the SQL query +(e.g. ``->findOneBy(['user' => $user->getUuid()])``). However, when using DQL +queries or building the query yourself, you'll need to set ``uuid`` as the type +of the UUID parameters:: + + // src/Repository/ProductRepository.php + + // ... + class ProductRepository extends ServiceEntityRepository + { + // ... + + public function findUserProducts(User $user): array + { + $qb = $this->createQueryBuilder('p') + // ... + // add 'uuid' as the third argument to tell Doctrine that this is an UUID + ->setParameter('user', $user->getUuid(), 'uuid') + + // alternatively, you can convert it to a value compatible with + // the type inferred by Doctrine + ->setParameter('user', $user->getUuid()->toBinary()) + ; + + // ... + } + } + ULIDs ----- @@ -283,6 +312,35 @@ entity primary keys:: The ULID types and generator were introduced in Symfony 5.2. +When using built-in Doctrine repository methods (e.g. ``findOneBy()``), Doctrine +knows how to convert these ULID types to build the SQL query +(e.g. ``->findOneBy(['user' => $user->getUlid()])``). However, when using DQL +queries or building the query yourself, you'll need to set ``ulid`` as the type +of the ULID parameters:: + + // src/Repository/ProductRepository.php + + // ... + class ProductRepository extends ServiceEntityRepository + { + // ... + + public function findUserProducts(User $user): array + { + $qb = $this->createQueryBuilder('p') + // ... + // add 'ulid' as the third argument to tell Doctrine that this is an ULID + ->setParameter('user', $user->getUlid(), 'ulid') + + // alternatively, you can convert it to a value compatible with + // the type inferred by Doctrine + ->setParameter('user', $user->getUlid()->toBinary()) + ; + + // ... + } + } + .. _`unique identifiers`: https://en.wikipedia.org/wiki/UID .. _`UUIDs`: https://en.wikipedia.org/wiki/Universally_unique_identifier .. _`ULIDs`: https://github.com/ulid/spec From 4f0ff7eaad978853b220f2956b96e6061244bf93 Mon Sep 17 00:00:00 2001 From: Adamo Crespi Date: Sat, 12 Dec 2020 13:46:23 +0100 Subject: [PATCH 661/752] Update normalizers.rst It was indicated a wrong class. The class `Symfony\Component\Serializer\Normalizer\NormalizableInterface` was not mentioned in the part that tells about how to normalize an object that implements the interface. --- serializer/normalizers.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serializer/normalizers.rst b/serializer/normalizers.rst index 002cc02a433..78cc103d763 100644 --- a/serializer/normalizers.rst +++ b/serializer/normalizers.rst @@ -36,10 +36,10 @@ Symfony includes the following normalizers but you can also transform :phpclass:`SplFileInfo` objects in `Data URIs`_ * :class:`Symfony\\Component\\Serializer\\Normalizer\\CustomNormalizer` to normalize PHP object using an object that implements + :class:`Symfony\\Component\\Serializer\\Normalizer\\NormalizableInterface`; * :class:`Symfony\\Component\\Serializer\\Normalizer\\FormErrorNormalizer` for objects implementing the :class:`Symfony\\Component\\Form\\FormInterface` to - normalize form errors. - :class:`Symfony\\Component\\Serializer\\Normalizer\\NormalizableInterface`; + normalize form errors; * :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` to normalize PHP object using the getter and setter methods of the object; * :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` to From 586503b66bbb23c27f218d0082c6b6f4b2a81e7c Mon Sep 17 00:00:00 2001 From: Volodymyr Stelmakh Date: Sat, 12 Dec 2020 15:14:57 +0100 Subject: [PATCH 662/752] fix method name typo in tip --- components/semaphore.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/semaphore.rst b/components/semaphore.rst index 5f26c781164..ebae3df89e8 100644 --- a/components/semaphore.rst +++ b/components/semaphore.rst @@ -76,6 +76,6 @@ already acquired. If you don't release the semaphore explicitly, it will be released automatically on instance destruction. In some cases, it can be useful to lock a resource across several requests. To disable the automatic release - behavior, set the fifth argument of the ``createLock()`` method to ``false``. + behavior, set the fifth argument of the ``createSemaphore()`` method to ``false``. .. _`semaphores`: https://en.wikipedia.org/wiki/Semaphore_(programming) From 912c86df25f7bc10f929f85b285093b010c53ca1 Mon Sep 17 00:00:00 2001 From: Christoph Wieseke Date: Tue, 15 Dec 2020 15:51:52 +0100 Subject: [PATCH 663/752] [PropertyAccess] fixed typos for feature enable/disable fixed typos in comments for feature enable/disable --- components/property_access.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/property_access.rst b/components/property_access.rst index d7890e13c5e..4069719cf41 100644 --- a/components/property_access.rst +++ b/components/property_access.rst @@ -519,10 +519,10 @@ configured to enable extra features. To do that you could use the $propertyAccessorBuilder->enableMagicSet(); // enables magic __set $propertyAccessorBuilder->enableMagicMethods(); // enables magic __get, __set and __call - $propertyAccessorBuilder->disableMagicCall(); // enables magic __call - $propertyAccessorBuilder->disableMagicGet(); // enables magic __get - $propertyAccessorBuilder->disableMagicSet(); // enables magic __set - $propertyAccessorBuilder->disableMagicMethods(); // enables magic __get, __set and __call + $propertyAccessorBuilder->disableMagicCall(); // disables magic __call + $propertyAccessorBuilder->disableMagicGet(); // disables magic __get + $propertyAccessorBuilder->disableMagicSet(); // disables magic __set + $propertyAccessorBuilder->disableMagicMethods(); // disables magic __get, __set and __call // checks if magic __call, __get or __set handling are enabled $propertyAccessorBuilder->isMagicCallEnabled(); // true or false From 7bf71ce65e972e466826e9046318b404e3031318 Mon Sep 17 00:00:00 2001 From: MrYamous Date: Wed, 16 Dec 2020 23:26:59 +0100 Subject: [PATCH 664/752] Remove UuidBinary/UlidBinary usages from documentation --- components/uid.rst | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index e5888c66b88..fef72839f52 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -115,7 +115,7 @@ UUID objects created with the ``Uuid`` class can use the following methods Storing UUIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can store UUID values as any other regular string/binary values in the database. +You can store UUID values as any other regular string values in the database. However, if you :doc:`use Doctrine `, it's more convenient to use the special Doctrine types which convert to/from UUID objects automatically:: @@ -134,14 +134,13 @@ special Doctrine types which convert to/from UUID objects automatically:: */ private $someProperty; - /** - * @ORM\Column(type="uuid_binary") - */ - private $anotherProperty; - // ... } +.. versionadded:: 5.2 + + The UuidBinary type has been removed in Symfony 5.2. + There's also a Doctrine generator to help autogenerate UUID values for the entity primary keys:: @@ -260,7 +259,7 @@ ULID objects created with the ``Ulid`` class can use the following methods:: Storing ULIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can store ULID values as any other regular string/binary values in the database. +You can store ULID values as any other regular string values in the database. However, if you :doc:`use Doctrine `, it's more convenient to use the special Doctrine types which convert to/from ULID objects automatically:: @@ -279,14 +278,13 @@ special Doctrine types which convert to/from ULID objects automatically:: */ private $someProperty; - /** - * @ORM\Column(type="ulid_binary") - */ - private $anotherProperty; - // ... } +.. versionadded:: 5.2 + + The UlidBinary type has been removed in Symfony 5.2. + There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: From 41285f0382e1056edb115c4b55c3f816aec73843 Mon Sep 17 00:00:00 2001 From: Oleksandr Barabolia Date: Mon, 16 Nov 2020 19:42:41 +0200 Subject: [PATCH 665/752] [Notifier] add iqsms bridge support in doc --- notifier.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/notifier.rst b/notifier.rst index b626a79ac39..9fdb9a435a8 100644 --- a/notifier.rst +++ b/notifier.rst @@ -60,6 +60,7 @@ Service Package DSN Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM`` +Iqsms ``symfony/iqsms-notifier`` ``iqsms://LOGIN:PASSWORD@default?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` OvhCloud ``symfony/ovhcloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` @@ -77,6 +78,10 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= The Smsapi, Infobip, Mobyt, Esendex and Sendinblue integrations were introduced in Symfony 5.2. +.. versionadded:: 5.3 + + The Iqsms integration was introduced in Symfony 5.3. + To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From ddd13674681771b2ea316f90eb6a9134a99c990e Mon Sep 17 00:00:00 2001 From: Fouad <48414048+ltlsquare@users.noreply.github.com> Date: Fri, 18 Dec 2020 11:13:39 +0400 Subject: [PATCH 666/752] Update uid.rst Uuid::fromString(); should not be instantiated as "new". The Ulid section is correct the uuid section contains this error. Especially confusing when you are just starting with this newly implemented functionality. --- components/uid.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/uid.rst b/components/uid.rst index c8eee0ece94..9a097a3e675 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -71,7 +71,7 @@ Converting UUIDs Use these methods to transform the UUID object into different bases:: - $uuid = new Uuid::fromString('d9e7a184-5d5b-11ea-a62a-3499710062d0'); + $uuid = Uuid::fromString('d9e7a184-5d5b-11ea-a62a-3499710062d0'); $uuid->toBinary(); // string(16) "..." (binary contents can't be printed) $uuid->toBase32(); // string(26) "6SWYGR8QAV27NACAHMK5RG0RPG" From efea74512cbe0f140de4a6e9409c0221f759a838 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 18 Dec 2020 11:37:52 +0100 Subject: [PATCH 667/752] Update DSN --- notifier.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 3145bce544c..4a587019e57 100644 --- a/notifier.rst +++ b/notifier.rst @@ -59,7 +59,7 @@ Service Package DSN ========== ================================ ==================================================== Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` -Infobip ``symfony/infobip-notifier`` ``infobip://TOKEN@default?from=FROM`` +Infobip ``symfony/infobip-notifier`` ``infobip://ACCESS_TOKEN@HOST?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` OvhCloud ``symfony/ovh-cloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` @@ -147,7 +147,7 @@ Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?chan RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Slack ``symfony/slack-notifier`` ``slack://TOKEN@default?channel=CHANNEL`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` -Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:APIKEY@ENDPOINT?channel=CHANNEL`` +Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:TOKEN@HOST?channel=CHANNEL`` ========== ================================ =========================================================================== .. versionadded:: 5.1 From facf002bb506ca6b811d72797f03ae21498d665e Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 18 Dec 2020 11:44:54 +0100 Subject: [PATCH 668/752] Update DSN --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 3f7d7008de9..c5e8181c22a 100644 --- a/notifier.rst +++ b/notifier.rst @@ -131,7 +131,7 @@ integration with these chat services: ========== ================================ ============================================ Service Package DSN ========== ================================ ============================================ -Mattermost ``symfony/mattermost-notifier`` ``mattermost://TOKEN@ENDPOINT?channel=CHANNEL`` +Mattermost ``symfony/mattermost-notifier`` ``mattermost://ACCESS_TOKEN@HOST/PATH?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Slack ``symfony/slack-notifier`` ``slack://default/ID`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` From dc29127bf23aba45b1ec6cec5b0444fd05fe7139 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 18 Dec 2020 15:16:26 +0100 Subject: [PATCH 669/752] Tweaks --- components/uid.rst | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index b0fd455add0..ccf372ddd96 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -115,9 +115,8 @@ UUID objects created with the ``Uuid`` class can use the following methods Storing UUIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can store UUID values as any other regular string values in the database. -However, if you :doc:`use Doctrine `, it's more convenient to use the -special Doctrine types which convert to/from UUID objects automatically:: +If you :doc:`use Doctrine `, consider using the ``uuid`` Doctrine +type, which converts to/from UUID objects automatically:: // src/Entity/Product.php namespace App\Entity; @@ -137,10 +136,6 @@ special Doctrine types which convert to/from UUID objects automatically:: // ... } -.. versionadded:: 5.2 - - The UuidBinary type has been removed in Symfony 5.2. - There's also a Doctrine generator to help autogenerate UUID values for the entity primary keys:: @@ -165,7 +160,7 @@ entity primary keys:: .. versionadded:: 5.2 - The UUID types and generators were introduced in Symfony 5.2. + The UUID type and generators were introduced in Symfony 5.2. When using built-in Doctrine repository methods (e.g. ``findOneBy()``), Doctrine knows how to convert these UUID types to build the SQL query @@ -259,9 +254,8 @@ ULID objects created with the ``Ulid`` class can use the following methods:: Storing ULIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ -You can store ULID values as any other regular string values in the database. -However, if you :doc:`use Doctrine `, it's more convenient to use the -special Doctrine types which convert to/from ULID objects automatically:: +If you :doc:`use Doctrine `, consider using the ``ulid`` Doctrine +type, which converts to/from ULID objects automatically:: // src/Entity/Product.php namespace App\Entity; @@ -281,10 +275,6 @@ special Doctrine types which convert to/from ULID objects automatically:: // ... } -.. versionadded:: 5.2 - - The UlidBinary type has been removed in Symfony 5.2. - There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: @@ -308,7 +298,7 @@ entity primary keys:: .. versionadded:: 5.2 - The ULID types and generator were introduced in Symfony 5.2. + The ULID type and generator were introduced in Symfony 5.2. When using built-in Doctrine repository methods (e.g. ``findOneBy()``), Doctrine knows how to convert these ULID types to build the SQL query From 4629dba683293de46b4d8a1ae5ca9ec81f394f3f Mon Sep 17 00:00:00 2001 From: Dale Nash Date: Fri, 18 Dec 2020 15:10:56 +0000 Subject: [PATCH 670/752] Update setup.rst Fix incorrect quotation mark type --- setup.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.rst b/setup.rst index 5700c2b8878..30ef0375f20 100644 --- a/setup.rst +++ b/setup.rst @@ -65,10 +65,10 @@ Symfony application using Composer: .. code-block:: terminal # run this if you are building a traditional web application - $ composer create-project symfony/website-skeleton:"5.3.x@dev' my_project_name + $ composer create-project symfony/website-skeleton:"5.3.x@dev" my_project_name # run this if you are building a microservice, console application or API - $ composer create-project symfony/skeleton:"5.3.x@dev' my_project_name + $ composer create-project symfony/skeleton:"5.3.x@dev" my_project_name 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 8250dc71f0cec24f3cc2b7a29431684265e10eca Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 18 Dec 2020 16:20:45 +0100 Subject: [PATCH 671/752] Fix build --- notifier.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 7e50df6c212..10a0a5490aa 100644 --- a/notifier.rst +++ b/notifier.rst @@ -144,7 +144,6 @@ integration with these chat services: ========== ================================ =========================================================================== Service Package DSN -<<<<<<< HEAD ========== ================================ =========================================================================== Discord ``symfony/discord-notifier`` ``discord://TOKEN@default?webhook_id=ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` From 8af100d63a63d2bf22c99117f686d64e1b963ea3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 18 Dec 2020 17:31:00 +0100 Subject: [PATCH 672/752] Mention that Symfony only loads YAML routes by default --- routing.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/routing.rst b/routing.rst index ec6de557b5d..a7d5be18fb6 100644 --- a/routing.rst +++ b/routing.rst @@ -147,6 +147,12 @@ the ``BlogController``: ; }; +.. versionadded:: 5.1 + + Starting from Symfony 5.1, by default Symfony only loads the routes defined + in YAML format. If you define routes in XML and/or PHP formats, update the + ``src/Kernel.php`` file to add support for the ``.xml`` and ``.php`` file extensions. + .. _routing-matching-http-methods: Matching HTTP Methods From 58bcabbd13cfc3f0611736f5d8cf67cc103ae8e4 Mon Sep 17 00:00:00 2001 From: Gawain Lynch Date: Sat, 19 Dec 2020 04:01:02 +0100 Subject: [PATCH 673/752] Correct annotation for ULID type --- components/uid.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/uid.rst b/components/uid.rst index ccf372ddd96..bdeb252bb65 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -287,7 +287,7 @@ entity primary keys:: { /** * @ORM\Id - * @ORM\Column(type="uuid", unique=true) + * @ORM\Column(type="ulid", unique=true) * @ORM\GeneratedValue(strategy="CUSTOM") * @ORM\CustomIdGenerator(class=UlidGenerator::class) */ From 63a4e504fb2e1685618690ebb0348ce8e76366b0 Mon Sep 17 00:00:00 2001 From: Gawain Lynch Date: Sat, 19 Dec 2020 04:14:46 +0100 Subject: [PATCH 674/752] Remove merge conflict header --- notifier.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 057545d1b71..62052eb96dc 100644 --- a/notifier.rst +++ b/notifier.rst @@ -139,7 +139,6 @@ integration with these chat services: ========== ================================ =========================================================================== Service Package DSN -<<<<<<< HEAD ========== ================================ =========================================================================== Discord ``symfony/discord-notifier`` ``discord://TOKEN@default?webhook_id=ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` From d1314646d993de107ed220142630ad99eff8bbab Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 21 Dec 2020 09:30:48 +0100 Subject: [PATCH 675/752] Removed unnecessary versionadded directives --- service_container/service_subscribers_locators.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/service_container/service_subscribers_locators.rst b/service_container/service_subscribers_locators.rst index 8a3f9ec3852..051a0ab592c 100644 --- a/service_container/service_subscribers_locators.rst +++ b/service_container/service_subscribers_locators.rst @@ -300,15 +300,6 @@ argument of type ``service_locator``: ])]); }; -.. versionadded:: 4.2 - - The ability to add services without specifying an array key was introduced - in Symfony 4.2. - -.. versionadded:: 4.2 - - The ``service_locator`` argument type was introduced in Symfony 4.2. - As shown in the previous sections, the constructor of the ``CommandBus`` class must type-hint its argument with ``ContainerInterface``. Then, you can get any of the service locator services via their ID (e.g. ``$this->locator->get('App\FooCommand')``). From a490d10189aad87f89a7e18a0939451276143be1 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Sun, 21 Jun 2020 15:49:19 +0000 Subject: [PATCH 676/752] Add documentation for pull #37371 --- translation/message_format.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/translation/message_format.rst b/translation/message_format.rst index 81bc8320975..e744ab8f757 100644 --- a/translation/message_format.rst +++ b/translation/message_format.rst @@ -165,6 +165,21 @@ you to use literal text in the select statements: #. Inside this block, ``{organizer_name}`` starts "code" mode again, allowing ``organizer_name`` to be processed as variable. +Additionally, it's possible to write the message directly in code:: + + $invitation = '{organizer_gender, select, + female {{organizer_name} has invited you for her party!} + male {{organizer_name} has invited you for his party!} + other {{organizer_name} have invited you for their party!} + }'; + // prints "Ryan has invited you for his party!" + echo $translator->trans($invitation, [ + 'organizer_name' => 'Ryan', + 'organizer_gender' => 'male', + ]); + +This can be used to create a wrapper. + .. tip:: While it might seem more logical to only put ``her``, ``his`` or ``their`` From 064bb18c88def6b3d1eab4a771076c4d3fa12366 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 22 Dec 2020 17:21:14 +0100 Subject: [PATCH 677/752] Tweaks --- translation/message_format.rst | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/translation/message_format.rst b/translation/message_format.rst index e744ab8f757..0a0742e16d0 100644 --- a/translation/message_format.rst +++ b/translation/message_format.rst @@ -165,21 +165,6 @@ you to use literal text in the select statements: #. Inside this block, ``{organizer_name}`` starts "code" mode again, allowing ``organizer_name`` to be processed as variable. -Additionally, it's possible to write the message directly in code:: - - $invitation = '{organizer_gender, select, - female {{organizer_name} has invited you for her party!} - male {{organizer_name} has invited you for his party!} - other {{organizer_name} have invited you for their party!} - }'; - // prints "Ryan has invited you for his party!" - echo $translator->trans($invitation, [ - 'organizer_name' => 'Ryan', - 'organizer_gender' => 'male', - ]); - -This can be used to create a wrapper. - .. tip:: While it might seem more logical to only put ``her``, ``his`` or ``their`` @@ -188,6 +173,22 @@ This can be used to create a wrapper. readable for translators and, as you can see in the ``other`` case, other parts of the sentence might be influenced by the variables. +.. tip:: + + It's possible to translate ICU MessageFormat messages directly in code, + without having to define them in any file:: + + $invitation = '{organizer_gender, select, + female {{organizer_name} has invited you for her party!} + male {{organizer_name} has invited you for his party!} + other {{organizer_name} have invited you for their party!} + }'; + + // prints "Ryan has invited you for his party!" + echo $translator->trans($invitation, [ + 'organizer_name' => 'Ryan', + 'organizer_gender' => 'male', + ]); .. _component-translation-pluralization: From c521f8e54355bce0baa93a66f20a9a3ff1b8edb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 23 Dec 2020 09:59:35 +0100 Subject: [PATCH 678/752] Remove experimental from notifier --- notifier.rst | 3 +-- notifier/chatters.rst | 3 +-- notifier/texters.rst | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/notifier.rst b/notifier.rst index 10a0a5490aa..c7c84eb5977 100644 --- a/notifier.rst +++ b/notifier.rst @@ -6,8 +6,7 @@ Creating and Sending Notifications .. versionadded:: 5.0 - The Notifier component was introduced in Symfony 5.0 as an - :doc:`experimental feature `. + The Notifier component was introduced in Symfony 5.0. Installation ------------ diff --git a/notifier/chatters.rst b/notifier/chatters.rst index da11c8858b9..ffeb6e0dc5e 100644 --- a/notifier/chatters.rst +++ b/notifier/chatters.rst @@ -6,8 +6,7 @@ How to send Chat Messages .. versionadded:: 5.0 - The Notifier component was introduced in Symfony 5.0 as an - :doc:`experimental feature `. + The Notifier component was introduced in Symfony 5.0. The :class:`Symfony\\Component\\Notifier\\ChatterInterface` class allows you to send messages to chat services like Slack or Telegram:: diff --git a/notifier/texters.rst b/notifier/texters.rst index eb663b13726..4cf9b6f2de2 100644 --- a/notifier/texters.rst +++ b/notifier/texters.rst @@ -6,8 +6,7 @@ How to send SMS Messages .. versionadded:: 5.0 - The Notifier component was introduced in Symfony 5.0 as an - :doc:`experimental feature `. + The Notifier component was introduced in Symfony 5.0. The :class:`Symfony\\Component\\Notifier\\TexterInterface` class allows you to send SMS messages:: From 275b6e97ba7edd5eff2d38230d5300270a1d9868 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Wed, 23 Dec 2020 11:46:38 +0100 Subject: [PATCH 679/752] Restore version-added in string --- components/string.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/string.rst b/components/string.rst index 7d2ec49a198..83d73140095 100644 --- a/components/string.rst +++ b/components/string.rst @@ -8,6 +8,10 @@ The String Component The String component provides a single object-oriented API to work with three "unit systems" of strings: bytes, code points and grapheme clusters. +.. versionadded:: 5.0 + + The String component was introduced in Symfony 5.0. + Installation ------------ From b885099d7b7812fa134008cdb00b786da9d775e5 Mon Sep 17 00:00:00 2001 From: Alexander Dubovskoy Date: Wed, 23 Dec 2020 17:48:32 +0300 Subject: [PATCH 680/752] Update lockable_trait.rst Misprint has been fixed: added ":" --- console/lockable_trait.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/console/lockable_trait.rst b/console/lockable_trait.rst index 9c77073d087..54f6e4b051d 100644 --- a/console/lockable_trait.rst +++ b/console/lockable_trait.rst @@ -39,7 +39,7 @@ that adds two convenient methods to lock and release commands:: // automatically when the execution of the command ends $this->release(); - return Command:SUCCESS; + return Command::SUCCESS; } } From c39447ab9ddd33dcd0a68b43eb65f70d23188f17 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Sun, 27 Dec 2020 11:30:56 +0100 Subject: [PATCH 681/752] [RateLimiter] Adding config reference for policy and lock_factory --- rate_limiter.rst | 2 ++ reference/configuration/framework.rst | 36 +++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/rate_limiter.rst b/rate_limiter.rst index 403aa9c462f..63e073a1e92 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -16,6 +16,8 @@ Symfony uses these rate limiters in built-in features like "login throttling", which limits how many failed login attempts a user can make in a given period of time, but you can use them for your own features too. +.. _rate-limiter-policies: + Rate Limiting Policies ---------------------- diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 4bc44ad1f17..cc00ae83c6f 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -211,6 +211,13 @@ Configuration * :ref:`enabled ` +* `rate_limiter`_: + + * :ref:`name ` + + * `lock_factory`_ + * `policy`_ + * `request`_: * `formats`_ @@ -1220,6 +1227,35 @@ dsn The DSN where to store the profiling information. +rate_limiter +~~~~~~~~~~~~ + +.. _reference-rate-limiter-name: + +name +.... + +**type**: ``prototype`` + +Name of the rate limiter you want to create. + +lock_factory +"""""""""""" + +**type**: ``string`` **default:** ``lock.factory`` + +The service that is used to create a lock. The service has to implement the +:class:`Symfony\\Component\\Lock\\LockFactoryInterface`. + +policy +"""""" + +**type**: ``string`` **required** + +The name of the rate limiting algorithm to use. Example names are ``fixed_window``, +``sliding_window`` and ``no_limit``. See :ref:`Rate Limiter Policies `) +for more information. + request ~~~~~~~ From 95d52ea6af091519b911a655db42bcc725ebe67c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 28 Dec 2020 15:24:00 +0100 Subject: [PATCH 682/752] Tweak --- reference/configuration/framework.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index a3bbbe2d7fa..8a126514b9b 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -1250,8 +1250,8 @@ lock_factory **type**: ``string`` **default:** ``lock.factory`` -The service that is used to create a lock. The service has to implement the -:class:`Symfony\\Component\\Lock\\LockFactoryInterface`. +The service that is used to create a lock. The service has to be an instance of +the :class:`Symfony\\Component\\Lock\\LockFactory` class. policy """""" From 3a7985f90472d45a282e82d8ce30de955f3dfa24 Mon Sep 17 00:00:00 2001 From: MrYamous Date: Mon, 28 Dec 2020 02:09:18 +0100 Subject: [PATCH 683/752] Update rounding mode defintion integer type --- reference/forms/types/integer.rst | 45 +++++++++++++++++++------------ 1 file changed, 28 insertions(+), 17 deletions(-) diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index fa5660158bc..80a946a33fd 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -55,31 +55,42 @@ Field Options ``rounding_mode`` ~~~~~~~~~~~~~~~~~ -**type**: ``integer`` **default**: ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` +**type**: ``integer`` **default**: ``\NumberFormatter::ROUND_HALFUP`` -By default, if the user enters a non-integer number, it will be rounded -down. There are several other rounding methods and each is a constant -on the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\IntegerToLocalizedStringTransformer`: +By default, if the users enters a non-integer number, it will be rounded +down. You have several configurable options for that rounding. Each option +is a constant on the :phpclass:`NumberFormatter` class: -* ``IntegerToLocalizedStringTransformer::ROUND_DOWN`` Round towards zero. +* ``\NumberFormatter::ROUND_DOWN`` Round towards zero. It + rounds ``1.4`` to ``1`` and ``-1.4`` to ``-1``. -* ``IntegerToLocalizedStringTransformer::ROUND_FLOOR`` Round towards negative - infinity. +* ``\NumberFormatter::ROUND_FLOOR`` Round towards negative + infinity. It rounds ``1.4`` to ``1`` and ``-1.4`` to ``-2``. -* ``IntegerToLocalizedStringTransformer::ROUND_UP`` Round away from zero. +* ``\NumberFormatter::ROUND_UP`` Round away from zero. It + rounds ``1.4`` to ``2`` and ``-1.4`` to ``-2``. -* ``IntegerToLocalizedStringTransformer::ROUND_CEILING`` Round towards - positive infinity. +* ``\NumberFormatter::ROUND_CEILING`` Round towards positive + infinity. It rounds ``1.4`` to ``2`` and ``-1.4`` to ``-1``. -* ``IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN`` Round towards the - "nearest neighbor". If both neighbors are equidistant, round down. +* ``\NumberFormatter::ROUND_HALFDOWN`` Round towards the + "nearest neighbor". If both neighbors are equidistant, round down. It rounds + ``2.5`` and ``1.6`` to ``2``, ``1.5`` and ``1.4`` to ``1``. -* ``IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN`` Round towards the - "nearest neighbor". If both neighbors are equidistant, round towards the - even neighbor. +* ``\NumberFormatter::ROUND_HALFEVEN`` Round towards the + "nearest neighbor". If both neighbors are equidistant, round towards the even + neighbor. It rounds ``2.5``, ``1.6`` and ``1.5`` to ``2`` and ``1.4`` to ``1``. + +* ``\NumberFormatter::ROUND_HALFUP`` Round towards the + "nearest neighbor". If both neighbors are equidistant, round up. It rounds + ``2.5`` to ``3``, ``1.6`` and ``1.5`` to ``2`` and ``1.4`` to ``1``. + +.. deprecated:: 5.1 + + In Symfony versions prior to 5.1, these constants were also defined as aliases + in the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\IntegerToLocalizedStringTransformer` + class, but they are now deprecated in favor of the :phpclass:`NumberFormatter` constants. -* ``IntegerToLocalizedStringTransformer::ROUND_HALF_UP`` Round towards the - "nearest neighbor". If both neighbors are equidistant, round up. Overridden Options ------------------ From 9436d6337ca5b5d62b86059c72fa3846597046a7 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Mon, 28 Dec 2020 15:56:15 +0100 Subject: [PATCH 684/752] Tweaks --- reference/forms/types/integer.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/reference/forms/types/integer.rst b/reference/forms/types/integer.rst index 80a946a33fd..984aa45ed89 100644 --- a/reference/forms/types/integer.rst +++ b/reference/forms/types/integer.rst @@ -57,7 +57,7 @@ Field Options **type**: ``integer`` **default**: ``\NumberFormatter::ROUND_HALFUP`` -By default, if the users enters a non-integer number, it will be rounded +By default, if the user enters a non-integer number, it will be rounded down. You have several configurable options for that rounding. Each option is a constant on the :phpclass:`NumberFormatter` class: @@ -88,10 +88,9 @@ is a constant on the :phpclass:`NumberFormatter` class: .. deprecated:: 5.1 In Symfony versions prior to 5.1, these constants were also defined as aliases - in the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\IntegerToLocalizedStringTransformer` + in the :class:`Symfony\\Component\\Form\\Extension\\Core\\DataTransformer\\NumberToLocalizedStringTransformer` class, but they are now deprecated in favor of the :phpclass:`NumberFormatter` constants. - Overridden Options ------------------ From 11e670134ae75a228f572279e85fb3f0842b0965 Mon Sep 17 00:00:00 2001 From: MrYamous Date: Tue, 29 Dec 2020 19:03:34 +0100 Subject: [PATCH 685/752] Add Firebase notifier to documentation --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index c5e8181c22a..c5415b465a8 100644 --- a/notifier.rst +++ b/notifier.rst @@ -131,6 +131,7 @@ integration with these chat services: ========== ================================ ============================================ Service Package DSN ========== ================================ ============================================ +Firebase ``symfony/firebase-notifier`` ``firebase://USERNAME:PASSWORD@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://ACCESS_TOKEN@HOST/PATH?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Slack ``symfony/slack-notifier`` ``slack://default/ID`` @@ -139,7 +140,7 @@ Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel .. versionadded:: 5.1 - The Mattermost and RocketChat integrations were introduced in Symfony + The Firebase, Mattermost and RocketChat integrations were introduced in Symfony 5.1. The Slack DSN changed in Symfony 5.1 to use Slack Incoming Webhooks instead of legacy tokens. From f06a712d602844862cb0be976b9f31f6294b599d Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Wed, 30 Dec 2020 14:27:00 +0100 Subject: [PATCH 686/752] Allow to configure trusted proxies and headers using config options --- deployment/proxies.rst | 126 +++++++++++++++++++------- reference/configuration/framework.rst | 23 ++++- 2 files changed, 113 insertions(+), 36 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index cae9e285648..15725b67007 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -22,28 +22,69 @@ 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:: - - // public/index.php - - // ... - $request = Request::createFromGlobals(); - - // tell Symfony about your reverse proxy - Request::setTrustedProxies( - // the IP address (or range) of your proxy - ['192.0.0.1', '10.0.0.0/8'], - - // trust *all* "X-Forwarded-*" headers - Request::HEADER_X_FORWARDED_FOR | Request::HEADER_X_FORWARDED_HOST | Request::HEADER_X_FORWARDED_PORT | Request::HEADER_X_FORWARDED_PROTO - - // or, if your proxy instead uses the "Forwarded" header - // Request::HEADER_FORWARDED - - // or, if you're using a well-known proxy - // Request::HEADER_X_FORWARDED_AWS_ELB - // Request::HEADER_X_FORWARDED_TRAEFIK - ); +and what headers your reverse proxy uses to send information: + +.. configuration-block:: + + .. config-block:: yaml + + # config/packages/framework.yaml + framework: + # ... + // the IP address (or range) of your proxy + trusted_proxies: '192.0.0.1,10.0.0.0/8' + // trust *all* "X-Forwarded-*" headers (the ! prefix means to not trust those headers) + trusted_headers: ['x-forwarded-all', '!x-forwarded-host', '!x-forwarded-prefix'] + // or, if your proxy instead uses the "Forwarded" header + trusted_headers: ['forwarded', '!x-forwarded-host', '!x-forwarded-prefix'] + // or, if you're using a wellknown proxy + trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_AWS_ELB, '!x-forwarded-host', '!x-forwarded-prefix'] + trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_TRAEFIK, '!x-forwarded-host', '!x-forwarded-prefix'] + + .. config-block:: xml + + + + + + + + 192.0.0.1,10.0.0.0/8 + + + x-forwarded-all + !x-forwarded-host + !x-forwarded-prefix + + + forwarded + !x-forwarded-host + !x-forwarded-prefix + + + + .. config-block:: php + + // config/packages/framework.php + use Symfony\Component\HttpFoundation\Request; + + $container->loadFromExtension('framework', [ + // the IP address (or range) of your proxy + 'trusted_proxies' => '192.0.0.1,10.0.0.0/8', + // trust *all* "X-Forwarded-*" headers (the ! prefix means to not trust those headers) + 'trusted_headers' => ['x-forwarded-all', '!x-forwarded-host', '!x-forwarded-prefix'], + // or, if your proxy instead uses the "Forwarded" header + 'trusted_headers' => ['forwarded', '!x-forwarded-host', '!x-forwarded-prefix'], + // or, if you're using a wellknown proxy + 'trusted_headers' => [Request::HEADER_X_FORWARDED_AWS_ELB, '!x-forwarded-host', '!x-forwarded-prefix'], + 'trusted_headers' => [Request::HEADER_X_FORWARDED_TRAEFIK, '!x-forwarded-host', '!x-forwarded-prefix'], + ]); .. deprecated:: 5.2 @@ -61,6 +102,13 @@ The Request object has several ``Request::HEADER_*`` constants that control exac *which* headers from your reverse proxy are trusted. The argument is a bit field, so you can also pass your own value (e.g. ``0b00110``). +.. versionadded:: 5.2 + + The feature to configure trusted proxies and headers with ``trusted_proxies`` + and ``trusted_headers`` options was introduced in Symfony 5.2. In earlier + Symfony versions you needed to use the ``Request::setTrustedProxies()`` + method in the ``public/index.php`` file. + But what if the IP of my Reverse Proxy Changes Constantly! ---------------------------------------------------------- @@ -74,17 +122,17 @@ In this case, you'll need to - *very carefully* - trust *all* proxies. #. Once you've guaranteed that traffic will only come from your trusted reverse proxies, configure Symfony to *always* trust incoming request:: - // public/index.php + .. config-block:: yaml - // ... - Request::setTrustedProxies( - // trust *all* requests (the 'REMOTE_ADDR' string is replaced at - // run time by $_SERVER['REMOTE_ADDR']) - ['127.0.0.1', 'REMOTE_ADDR'], + # config/packages/framework.yaml + framework: + # ... + // trust *all* requests (the 'REMOTE_ADDR' string is replaced at + // run time by $_SERVER['REMOTE_ADDR']) + trusted_proxies: '127.0.0.1,REMOTE_ADDR' - // if you're using ELB, otherwise use a constant from above - Request::HEADER_X_FORWARDED_AWS_ELB - ); + // if you're using ELB, otherwise use another Request::HEADER-* constant + trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_AWS_ELB, '!x-forwarded-host', '!x-forwarded-prefix'] That's it! It's critical that you prevent traffic from all non-trusted sources. If you allow outside traffic, they could "spoof" their true IP address and @@ -100,6 +148,12 @@ other information. # .env TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR + .. config-block:: yaml + + # config/packages/framework.yaml + framework: + # ... + trusted_proxies: '%env(TRUSTED_PROXIES)%' If you are also using a reverse proxy on top of your load balancer (e.g. `CloudFront`_), calling ``$request->server->get('REMOTE_ADDR')`` won't be @@ -111,11 +165,13 @@ trusted proxies. Custom Headers When Using a Reverse Proxy ----------------------------------------- -Some reverse proxies (like `CloudFront`_ with ``CloudFront-Forwarded-Proto``) may force you to use a custom header. -For instance you have ``Custom-Forwarded-Proto`` instead of ``X-Forwarded-Proto``. +Some reverse proxies (like `CloudFront`_ with ``CloudFront-Forwarded-Proto``) +may force you to use a custom header. For instance you have +``Custom-Forwarded-Proto`` instead of ``X-Forwarded-Proto``. -In this case, you'll need to set the header ``X-Forwarded-Proto`` with the value of -``Custom-Forwarded-Proto`` early enough in your application, i.e. before handling the request:: +In this case, you'll need to set the header ``X-Forwarded-Proto`` with the value +of ``Custom-Forwarded-Proto`` early enough in your application, i.e. before +handling the request:: // public/index.php diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index df964b6d0ba..3a26887300e 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -284,6 +284,7 @@ Configuration * `logging`_ * :ref:`paths ` +* `trusted_headers`_ * `trusted_hosts`_ * `trusted_proxies`_ * `validation`_ @@ -380,12 +381,32 @@ named ``kernel.http_method_override``. $request = Request::createFromGlobals(); // ... +.. _reference-framework-trusted-headers: + +trusted_headers +~~~~~~~~~~~~~~~ + +.. versionadded:: 5.2 + + The ``trusted_headers`` option was introduced in Symfony 5.2. + +The ``trusted_headers`` option is needed to configure which client information +should be trusted (e.g. their host) when running Symfony behind a load balancer +or a reverse proxy. See :doc:`/deployment/proxies`. + .. _reference-framework-trusted-proxies: trusted_proxies ~~~~~~~~~~~~~~~ -The ``trusted_proxies`` option was removed in Symfony 3.3. See :doc:`/deployment/proxies`. +.. versionadded:: 5.2 + + The ``trusted_headers`` option was reintroduced in Symfony 5.2 (it had been + removed in Symfony 3.3). + +The ``trusted_proxies`` option is needed to get precise information about the +client (e.g. their IP address) when running Symfony behind a load balancer or a +reverse proxy. See :doc:`/deployment/proxies`. ide ~~~ From 20695d48b693257a6d5fb765210426f4d1144af2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Dec 2020 17:39:09 +0100 Subject: [PATCH 687/752] Fixed a RST syntax issue --- profiler/data_collector.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/profiler/data_collector.rst b/profiler/data_collector.rst index 276d1e88324..6e53fd5203d 100644 --- a/profiler/data_collector.rst +++ b/profiler/data_collector.rst @@ -96,7 +96,7 @@ template that includes some specific blocks. First, add the ``getTemplate()`` method in your data collector class to return the path of the Twig template to use. Then, add some *getters* to give the -template access to the collected information:::: +template access to the collected information:: // src/DataCollector/RequestCollector.php namespace App\DataCollector; From bff0f52a22e35b1893836ce0c4ab3e9f2bac3510 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Dec 2020 17:44:32 +0100 Subject: [PATCH 688/752] Fixed RST syntax issue --- deployment/proxies.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 15725b67007..95112ca616c 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -26,7 +26,7 @@ and what headers your reverse proxy uses to send information: .. configuration-block:: - .. config-block:: yaml + .. code-block:: yaml # config/packages/framework.yaml framework: @@ -41,7 +41,7 @@ and what headers your reverse proxy uses to send information: trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_AWS_ELB, '!x-forwarded-host', '!x-forwarded-prefix'] trusted_headers: [!php/const Symfony\\Component\\HttpFoundation\\Request::HEADER_X_FORWARDED_TRAEFIK, '!x-forwarded-host', '!x-forwarded-prefix'] - .. config-block:: xml + .. code-block:: xml @@ -69,7 +69,7 @@ and what headers your reverse proxy uses to send information: - .. config-block:: php + .. code-block:: php // config/packages/framework.php use Symfony\Component\HttpFoundation\Request; From 156ac65df5e08fa6786dd4365da2a37bbb0008ac Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Wed, 30 Dec 2020 17:50:50 +0100 Subject: [PATCH 689/752] Fixed more RST syntax issues --- deployment/proxies.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deployment/proxies.rst b/deployment/proxies.rst index 95112ca616c..f0e9eca9db2 100644 --- a/deployment/proxies.rst +++ b/deployment/proxies.rst @@ -120,9 +120,9 @@ In this case, you'll need to - *very carefully* - trust *all* proxies. other than your load balancers. For AWS, this can be done with `security groups`_. #. Once you've guaranteed that traffic will only come from your trusted reverse - proxies, configure Symfony to *always* trust incoming request:: + proxies, configure Symfony to *always* trust incoming request: - .. config-block:: yaml + .. code-block:: yaml # config/packages/framework.yaml framework: @@ -148,7 +148,7 @@ other information. # .env TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR - .. config-block:: yaml + .. code-block:: yaml # config/packages/framework.yaml framework: From ce3bbd6a657835d8fd6e7a020bd675c78b8eb289 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pipa?= Date: Fri, 1 Jan 2021 20:40:33 +0100 Subject: [PATCH 690/752] Fix PostgreSqlStore code sample formatting --- components/lock.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/lock.rst b/components/lock.rst index 97de11d0701..3f96ef89586 100644 --- a/components/lock.rst +++ b/components/lock.rst @@ -465,7 +465,8 @@ PostgreSqlStore The PostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL. It requires a `PDO`_ connection, a `Doctrine DBAL Connection`_, or a -`Data Source Name (DSN)`_. It supports native blocking, as well as sharing locks. +`Data Source Name (DSN)`_. It supports native blocking, as well as sharing +locks:: use Symfony\Component\Lock\Store\PostgreSqlStore; From 2931e978d17d6e5cc9738df7d06629cb3a76e82d Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 3 Jan 2021 10:33:54 +0100 Subject: [PATCH 691/752] document the ancestors() method --- components/dom_crawler.rst | 8 ++++++-- testing.rst | 8 ++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/components/dom_crawler.rst b/components/dom_crawler.rst index 55b5d8bc23f..7f2b28ad582 100644 --- a/components/dom_crawler.rst +++ b/components/dom_crawler.rst @@ -187,10 +187,14 @@ Get the same level nodes after or before the current selection:: $crawler->filter('body > p')->nextAll(); $crawler->filter('body > p')->previousAll(); -Get all the child or parent nodes:: +Get all the child or ancestor nodes:: $crawler->filter('body')->children(); - $crawler->filter('body > p')->parents(); + $crawler->filter('body > p')->ancestors(); + +.. versionadded:: 5.3 + + The ``ancestors()`` method was introduced in Symfony 5.3. Get all the direct child nodes matching a CSS selector:: diff --git a/testing.rst b/testing.rst index 2c0535eddfa..261786ff108 100644 --- a/testing.rst +++ b/testing.rst @@ -713,7 +713,7 @@ selects the last one on the page, and then selects its immediate parent element: $newCrawler = $crawler->filter('input[type=submit]') ->last() - ->parents() + ->ancestors() ->first() ; @@ -735,8 +735,8 @@ Many other methods are also available: All following siblings. ``previousAll()`` All preceding siblings. -``parents()`` - Returns the parent nodes. +``ancestors()`` + Returns the ancestor nodes. ``children()`` Returns children nodes. ``reduce($lambda)`` @@ -766,7 +766,7 @@ Extracting Information The Crawler can extract information from the nodes:: use Symfony\Component\DomCrawler\Crawler; - + // returns the attribute value for the first node $crawler->attr('class'); From f872201e9febf6fb2078065d0ff380992e3b4862 Mon Sep 17 00:00:00 2001 From: Gordon Franke Date: Tue, 5 Jan 2021 21:09:48 +0100 Subject: [PATCH 692/752] doc: copy paste trusted_headers vs trusted_proxies --- reference/configuration/framework.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/configuration/framework.rst b/reference/configuration/framework.rst index 3a26887300e..c46b2a469f0 100644 --- a/reference/configuration/framework.rst +++ b/reference/configuration/framework.rst @@ -401,7 +401,7 @@ trusted_proxies .. versionadded:: 5.2 - The ``trusted_headers`` option was reintroduced in Symfony 5.2 (it had been + The ``trusted_proxies`` option was reintroduced in Symfony 5.2 (it had been removed in Symfony 3.3). The ``trusted_proxies`` option is needed to get precise information about the From 0f25dd3cce6ac600bfc7682b09300ebddbea6fc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Tue, 5 Jan 2021 17:02:57 +0100 Subject: [PATCH 693/752] Add documenation for Console Negatable option --- console/input.rst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/console/input.rst b/console/input.rst index ecb7d6e72c3..8bd42ae6c85 100644 --- a/console/input.rst +++ b/console/input.rst @@ -199,7 +199,7 @@ separation at all (e.g. ``-i 5`` or ``-i5``). this situation, always place options after the command name, or avoid using a space to separate the option name from its value. -There are four option variants you can use: +There are five option variants you can use: ``InputOption::VALUE_IS_ARRAY`` This option accepts multiple values (e.g. ``--dir=/foo --dir=/bar``); @@ -216,6 +216,14 @@ There are four option variants you can use: This option may or may not have a value (e.g. ``--yell`` or ``--yell=loud``). +``InputOption::VALUE_NEGATABLE`` + Accept either the flag (e.g. ``--yell``) or its negation (e.g. + ``--no-yell``). + +.. versionadded:: 5.3 + + The ``InputOption::VALUE_NEGATABLE`` constant was introduced in Symfony 5.3. + You can combine ``VALUE_IS_ARRAY`` with ``VALUE_REQUIRED`` or ``VALUE_OPTIONAL`` like this:: From 66d5f497c4e871af5b27db6c23f4fce63193f330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20K=C3=A4fer?= Date: Mon, 16 Nov 2020 23:20:42 +0100 Subject: [PATCH 694/752] [PHPUnitBridge] Add deprecation log file option --- components/phpunit_bridge.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 8be5ef90bb7..ed1fbb5a0b2 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -350,6 +350,16 @@ the compiling and warming up of the container: The ``--deprecations`` option was introduced in Symfony 5.1. +Log Deprecations +~~~~~~~~~~~~~~~~ + +For turning the verbose output off and write it to a log file instead you can use +``SYMFONY_DEPRECATIONS_HELPER='logFile=/path/deprecations.log'``. + +.. versionadded:: 5.3 + + The ``logFile`` option was introduced in Symfony 5.3. + Write Assertions about Deprecations ----------------------------------- From 10f752227da6bca24795534111bd1233d6539995 Mon Sep 17 00:00:00 2001 From: Jacek Date: Tue, 5 Jan 2021 22:47:02 +0100 Subject: [PATCH 695/752] Remove unused imports and properties --- security/experimental_authenticators.rst | 9 --------- 1 file changed, 9 deletions(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index 35aa1c9c205..c84f36ed51d 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -287,8 +287,6 @@ method that fits most use-cases:: // src/Security/ApiKeyAuthenticator.php namespace App\Security; - use App\Entity\User; - use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -302,13 +300,6 @@ method that fits most use-cases:: class ApiKeyAuthenticator extends AbstractAuthenticator { - private $entityManager; - - public function __construct(EntityManagerInterface $entityManager) - { - $this->entityManager = $entityManager; - } - /** * Called on every request to decide if this authenticator should be * used for the request. Returning `false` will cause this authenticator From f3fdf986f270448d8eba3542bd61c24506ab0724 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 7 Jan 2021 17:31:36 +0100 Subject: [PATCH 696/752] [FrameworkBundle] Document assertResponseFormatSame() --- testing/functional_tests_assertions.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 457d8c39021..0e190f0ed90 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -39,6 +39,12 @@ Response - ``assertResponseHasCookie()`` - ``assertResponseNotHasCookie()`` - ``assertResponseCookieValueSame()`` +- ``assertResponseFormatSame()`` (the response format is the value returned by + the :method:`Symfony\Component\HttpFoundation\Response::getFormat` method). + +.. versionadded:: 5.3 + + The ``assertResponseFormatSame()`` method was introduced in Symfony 5.3. Request ~~~~~~~ From f60b89a7253d76358b9e109b24e3833e5226c132 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 8 Jan 2021 09:24:49 +0100 Subject: [PATCH 697/752] Make DOCtor happy --- testing/functional_tests_assertions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/functional_tests_assertions.rst b/testing/functional_tests_assertions.rst index 0e190f0ed90..56f6a1d4c8c 100644 --- a/testing/functional_tests_assertions.rst +++ b/testing/functional_tests_assertions.rst @@ -40,7 +40,7 @@ Response - ``assertResponseNotHasCookie()`` - ``assertResponseCookieValueSame()`` - ``assertResponseFormatSame()`` (the response format is the value returned by - the :method:`Symfony\Component\HttpFoundation\Response::getFormat` method). + the :method:`Symfony\\Component\\HttpFoundation\\Response::getFormat` method). .. versionadded:: 5.3 From d70cd24c15efa79977a2dba363fd7ab1ba1bba63 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 10:04:16 +0100 Subject: [PATCH 698/752] [Ldap] Document the case-insensitive attribute names --- components/ldap.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/components/ldap.rst b/components/ldap.rst index d7cb6ed17cd..89fb39cb8e8 100644 --- a/components/ldap.rst +++ b/components/ldap.rst @@ -142,6 +142,9 @@ delete existing ones:: $phoneNumber = $entry->getAttribute('phoneNumber'); $isContractor = $entry->hasAttribute('contractorCompany'); + // attribute names in getAttribute() and hasAttribute() methods are case-sensitive + // pass FALSE as the second method argument to make them case-insensitive + $isContractor = $entry->hasAttribute('contractorCompany', false); $entry->setAttribute('email', ['fabpot@symfony.com']); $entryManager->update($entry); @@ -153,6 +156,11 @@ delete existing ones:: // Removing an existing entry $entryManager->remove(new Entry('cn=Test User,dc=symfony,dc=com')); +.. versionadded:: 5.3 + + The option to make attribute names case-insensitive in ``getAttribute()`` + and ``hasAttribute()`` was introduce in Symfony 5.3. + Batch Updating ______________ From 202820162b46d4b6ee88eb02a2155b043f1f7c77 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 10:25:50 +0100 Subject: [PATCH 699/752] [Yaml] Documented the github output format for the linter --- translation/lint.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/translation/lint.rst b/translation/lint.rst index d9129a79108..14693f32826 100644 --- a/translation/lint.rst +++ b/translation/lint.rst @@ -33,6 +33,17 @@ The linter results can be exported to JSON using the ``--format`` option: $ php bin/console lint:yaml translations/ --format=json $ php bin/console lint:xliff translations/ --format=json +When running the YAML linter inside `GitHub Actions`_, the output is automatically +adapted to the format required by GitHub, but you can force that format too: + +.. code-block:: terminal + + $ php bin/console lint:yaml translations/ --format=github + +.. versionadded:: 5.3 + + The ``github`` output format was introduced in Symfony 5.3. + .. tip:: The Yaml component provides a stand-alone ``yaml-lint`` binary allowing @@ -45,3 +56,5 @@ The linter results can be exported to JSON using the ``--format`` option: .. versionadded:: 5.1 The ``yaml-lint`` binary was introduced in Symfony 5.1. + +.. _`GitHub Actions`: https://docs.github.com/en/free-pro-team@latest/actions From c3cadab18f3bccd1f5f2a313c0f607292c981960 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 10:33:15 +0100 Subject: [PATCH 700/752] [BrowserKit] Document the jsonRequest() method --- components/browser_kit.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/browser_kit.rst b/components/browser_kit.rst index b73783f95e0..475c84b9365 100644 --- a/components/browser_kit.rst +++ b/components/browser_kit.rst @@ -80,6 +80,20 @@ The value returned by the ``request()`` method is an instance of the :doc:`DomCrawler component `, which allows accessing and traversing HTML elements programmatically. +The :method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::jsonRequest` method, +which defines the same arguments as the ``request()`` method, is a shortcut to +convert the request parameters into a JSON string and set the needed HTTP headers:: + + use Acme\Client; + + $client = new Client(); + // this encodes parameters as JSON and sets the required CONTENT_TYPE and HTTP_ACCEPT headers + $crawler = $client->jsonRequest('GET', '/', ['some_parameter' => 'some_value']); + +.. versionadded:: 5.3 + + The ``jsonRequest()`` method was introduced in Symfony 5.3. + The :method:`Symfony\\Component\\BrowserKit\\AbstractBrowser::xmlHttpRequest` method, which defines the same arguments as the ``request()`` method, is a shortcut to make AJAX requests:: From 83af9a124100c7264cbc25eba7f0cf27bffa7e56 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 11:07:10 +0100 Subject: [PATCH 701/752] [PhpUnitBridge] Document the deprecation baseline file --- components/phpunit_bridge.rst | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index fea473f1229..289346547c7 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -289,6 +289,36 @@ Here is a summary that should help you pick the right configuration: | | cannot afford to use one of the modes above. | +------------------------+-----------------------------------------------------+ +Baseline Deprecations +..................... + +If your application has some deprecations that you can't fix for some reasons, +you can tell Symfony to ignore them. The trick is to create a file with the +allowed deprecations and define it as the "deprecation baseline". Deprecations +inside that file are ignore but the rest of deprecations are still reported. + +First, generate the file with the allowed deprecations (run the same command +whenever you want to update the existing file): + +.. code-block:: terminal + + $ SYMFONY_DEPRECATIONS_HELPER='generateBaseline=true&baselineFile=tests/allowed.json' ./vendor/bin/simple-phpunit + +This command stores all the deprecations reported while running tests in the +given file and encoded in JSON. The file path defined in ``baselineFile`` can +be absolute or relative to your project root. + +Then, you can run the following command to use that file and ignore those deprecations: + +.. code-block:: terminal + + $ SYMFONY_DEPRECATIONS_HELPER='baselineFile=tests/allowed.json' ./vendor/bin/simple-phpunit + +.. versionadded:: 5.2 + + The ``baselineFile`` and ``generateBaseline`` options were introduced in + Symfony 5.2. + Disabling the Verbose Output ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From f156e727eb81fa57b2a58da29a0fea9046650625 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 11:25:48 +0100 Subject: [PATCH 702/752] [Messenger] Documented AMQP confirm_timeout option --- messenger.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/messenger.rst b/messenger.rst index e4d1179da8a..c92bda6733b 100644 --- a/messenger.rst +++ b/messenger.rst @@ -962,6 +962,9 @@ The transport has a number of options: fractional. ``connect_timeout`` Connection timeout. Note: 0 or greater seconds. May be fractional. +``confirm_timeout`` Number of seconds to wait for message sending + confirmation. If not specified, transport won't + wait for confirmation. May be fractional. ``frame_max`` The largest frame size that the server proposes for the connection, including frame header and end-byte. 0 means standard extension limit @@ -1005,6 +1008,10 @@ The transport has a number of options: ``exchange[type]`` Type of exchange ``fanout`` ============================================ ================================================= =================================== +.. versionadded:: 5.2 + + The ``confirm_timeout`` option was introduced in Symfony 5.2. + You can also configure AMQP-specific settings on your message by adding :class:`Symfony\\Component\\Messenger\\Bridge\\Amqp\\Transport\\AmqpStamp` to your Envelope:: From 71e65a1185b787909d76186ea7593d2ed3922dad Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 11:18:16 +0100 Subject: [PATCH 703/752] [Messenger] Mention the WorkerMessageRetriedEvent --- messenger.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/messenger.rst b/messenger.rst index e4d1179da8a..f0e2d742450 100644 --- a/messenger.rst +++ b/messenger.rst @@ -716,6 +716,15 @@ this is configurable for each transport: ], ]); +.. tip:: + + Symfony triggers a :class:`Symfony\\Component\\Messenger\\Event\\WorkerMessageRetriedEvent` + when a message is retried so you can run your own logic. + + .. versionadded:: 5.2 + + The ``WorkerMessageRetriedEvent`` class was introduced in Symfony 5.2. + Avoiding Retrying ~~~~~~~~~~~~~~~~~ From a6f97ce0638f14a3014cb9fd10b6599c40284735 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 10:39:07 +0100 Subject: [PATCH 704/752] [Messenger] Document the debug option of Amazon SQS --- messenger.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/messenger.rst b/messenger.rst index e4d1179da8a..ee274146158 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1342,6 +1342,8 @@ The transport has a number of options: ``auto_setup`` Whether the queue should be created ``true`` automatically during send / get. ``buffer_size`` Number of messages to prefetch 9 +``debug`` If ``true`` it logs all HTTP requests ``false`` + and responses (it impacts performance) ``endpoint`` Absolute URL to the SQS service https://sqs.eu-west-1.amazonaws.com ``poll_timeout`` Wait for new message duration in 0.1 seconds @@ -1353,6 +1355,10 @@ The transport has a number of options: ``wait_time`` `Long polling`_ duration in seconds 20 ====================== ====================================== =================================== +.. versionadded:: 5.3 + + The ``debug`` option was introduced in Symfony 5.3. + .. note:: The ``wait_time`` parameter defines the maximum duration Amazon SQS should From 790d1ecb6aefb9f4104399f6b7a6913a2d748259 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 15:42:55 +0100 Subject: [PATCH 705/752] Restored some wrongly removed contents --- testing/http_authentication.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/testing/http_authentication.rst b/testing/http_authentication.rst index 134f2ad3fb7..a55ae639e0b 100644 --- a/testing/http_authentication.rst +++ b/testing/http_authentication.rst @@ -10,4 +10,8 @@ How to Simulate HTTP Authentication in a Functional Test ease testing secured applications. See :ref:`testing_logging_in_users` for more information about this. + If you are still using an older version of Symfony, view + `previous versions of this article`_ for information on how to simulate + HTTP authentication. + .. _previous versions of this article: https://symfony.com/doc/5.0/testing/http_authentication.html From c20126a152577edf25f60d69ff129245a23de82b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 8 Jan 2021 16:17:29 +0100 Subject: [PATCH 706/752] Tweaks --- workflow.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/workflow.rst b/workflow.rst index ac0451d473d..750d6a2ca5e 100644 --- a/workflow.rst +++ b/workflow.rst @@ -791,7 +791,7 @@ of domain logic in your templates: Returns an array with all the transitions enabled for the given object. ``workflow_transition()`` - Returns a specific transitions enabled for the given object and transition name. + Returns a specific transition enabled for the given object and transition name. ``workflow_marked_places()`` Returns an array with the place names of the given marking. From abd7460c0c7b09056ff532296d2168347dc623ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20MARTIN?= Date: Mon, 4 Jan 2021 11:41:12 +0100 Subject: [PATCH 707/752] Add Octopush in SMS channel --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index be67884c1b2..966124b01bb 100644 --- a/notifier.rst +++ b/notifier.rst @@ -62,6 +62,7 @@ Infobip ``symfony/infobip-notifier`` ``infobip://ACCESS_TOKEN@HOST?from Iqsms ``symfony/iqsms-notifier`` ``iqsms://LOGIN:PASSWORD@default?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` +Octopush ``symfony/octopush-notifier`` ``octopush://USERLOGIN:APIKEY@default?from=FROM&type=TYPE`` OvhCloud ``symfony/ovh-cloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` Sendinblue ``symfony/sendinblue-notifier`` ``sendinblue://API_KEY@default?sender=PHONE`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` @@ -79,7 +80,7 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.3 - The Iqsms integration was introduced in Symfony 5.3. + The Iqsms and Octopush integrations were introduced in Symfony 5.3. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 0470b00dac4042ba82b4be1a628a3018151b629b Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Mon, 18 May 2020 11:53:54 +0200 Subject: [PATCH 708/752] Add choice_translation_parameters option --- reference/forms/types/choice.rst | 3 + .../choice_translation_parameters.rst.inc | 80 +++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 reference/forms/types/options/choice_translation_parameters.rst.inc diff --git a/reference/forms/types/choice.rst b/reference/forms/types/choice.rst index affcce9ab54..d01d90f262d 100644 --- a/reference/forms/types/choice.rst +++ b/reference/forms/types/choice.rst @@ -19,6 +19,7 @@ To use this field, you must specify *either* ``choices`` or ``choice_loader`` op | | - `choice_loader`_ | | | - `choice_name`_ | | | - `choice_translation_domain`_ | +| | - `choice_translation_parameters`_ | | | - `choice_value`_ | | | - `expanded`_ | | | - `group_by`_ | @@ -232,6 +233,8 @@ correct types will be assigned to the model. .. include:: /reference/forms/types/options/choice_translation_domain_enabled.rst.inc +.. include:: /reference/forms/types/options/choice_translation_parameters.rst.inc + .. include:: /reference/forms/types/options/choice_value.rst.inc .. include:: /reference/forms/types/options/expanded.rst.inc diff --git a/reference/forms/types/options/choice_translation_parameters.rst.inc b/reference/forms/types/options/choice_translation_parameters.rst.inc new file mode 100644 index 00000000000..32e66393383 --- /dev/null +++ b/reference/forms/types/options/choice_translation_parameters.rst.inc @@ -0,0 +1,80 @@ +choice_translation_parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +**type**: ``array``, ``callable``, ``string`` or :class:`Symfony\\Component\\PropertyAccess\\PropertyPath` **default**: ``[]`` + +The choice values are translated before displaying it, so it can contain +:ref:`translation placeholders `. +This option defines the values used to replace those placeholders. This can be +an associative array where the keys match the choice keys and the values +are the attributes for each choice, a callable or a property path +(just like `choice_label`_). + +Given this translation message: + +.. configuration-block:: + + .. code-block:: yaml + + # translations/messages.en.yaml + form.order.yes: 'I confirm my order to the company %company%' + form.order.no: 'I cancel my order' + + .. code-block:: xml + + + + + + + + form.order.yes + I confirm my order to the company %company% + + + form.order.no + I cancel my order + + + + + + .. code-block:: php + + // translations/messages.fr.php + return [ + 'form.order.yes' => "I confirm my order to the company %company%", + 'form.order.no' => "I cancel my order", + ]; + +You can specify the placeholder values as follows:: + + $builder->add('id', null, [ + 'choice' => [ + 'form.order.yes' => true, + 'form.order.no' => false, + ], + 'choice_translation_parameters' => function ($choice, $key, $value) { + if (false === $choice) { + return []; + } + + return ['%company%' => 'ACME Inc.'] + }, + ]); + +If an array, the keys of the ``choices`` array must be used as keys:: + + $builder->add('id', null, [ + 'choice' => [ + 'form.order.yes' => true, + 'form.order.no' => false, + ], + 'choice_translation_parameters' => [ + 'form.order.yes' => ['%company%' => 'ACME Inc.'], + 'form.order.no' => [], + ], + ]); + +The translation parameters of child fields are merged with the same option of +their parents, so children can reuse and/or override any of the parent placeholders. From 89d3122981d023c5e373044528f900a0f063814c Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 7 Jan 2021 17:36:22 +0100 Subject: [PATCH 709/752] [Messenger] Deprecated the prefetch_count option --- messenger.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/messenger.rst b/messenger.rst index e4d1179da8a..9f28fca4e1d 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1005,6 +1005,11 @@ The transport has a number of options: ``exchange[type]`` Type of exchange ``fanout`` ============================================ ================================================= =================================== +.. deprecated:: 5.3 + + The ``prefetch_count`` option was deprecated in Symfony 5.3 because it has + no effect on the AMQP Messenger transport. + You can also configure AMQP-specific settings on your message by adding :class:`Symfony\\Component\\Messenger\\Bridge\\Amqp\\Transport\\AmqpStamp` to your Envelope:: From d44c038f925c4cab693995ecf1531206128353a5 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Mon, 11 Jan 2021 10:02:07 +0100 Subject: [PATCH 710/752] Removed 4.2 versionadded directive --- components/serializer.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index ca89cdb58ca..c062fef80c5 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -946,11 +946,6 @@ Option Description generated XML ============================== ================================================= ========================== -.. versionadded:: 4.2 - - The ``decoder_ignored_node_types`` and ``encoder_ignored_node_types`` - options were introduced in Symfony 4.2. - The ``YamlEncoder`` ~~~~~~~~~~~~~~~~~~~ From 8961ebdd978cc42fbf0a1a98d5432b2a5d439a87 Mon Sep 17 00:00:00 2001 From: Sebastian Paczkowski <74934099+sebpacz@users.noreply.github.com> Date: Mon, 11 Jan 2021 22:45:11 +0100 Subject: [PATCH 711/752] [Mailer] Update Twig namespace The examples shown in the "Using External CSS Files" section use/define a Twig namespace called styles, not css. I checked git history and branch 4.4 doesn't have this issue. --- mailer.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mailer.rst b/mailer.rst index 2bbc58d04a5..fbb84dbdd20 100644 --- a/mailer.rst +++ b/mailer.rst @@ -663,7 +663,7 @@ arguments to the filter: You can pass unlimited number of arguments to ``inline_css()`` to load multiple CSS files. For this example to work, you also need to define a new Twig namespace -called ``css`` that points to the directory where ``email.css`` lives: +called ``styles`` that points to the directory where ``email.css`` lives: .. _mailer-css-namespace: @@ -786,11 +786,11 @@ You can combine all filters to create complex email messages: .. code-block:: twig - {% apply inky_to_html|inline_css(source('@css/foundation-emails.css')) %} + {% apply inky_to_html|inline_css(source('@styles/foundation-emails.css')) %} {# ... #} {% endapply %} -This makes use of the :ref:`css Twig namespace ` we created +This makes use of the :ref:`styles Twig namespace ` we created earlier. You could, for example, `download the foundation-emails.css file`_ directly from GitHub and save it in ``assets/styles``. From 5f70432f366e62bdced954c95ef94aa86baa4de2 Mon Sep 17 00:00:00 2001 From: Piergiuseppe Longo Date: Thu, 22 Oct 2020 19:48:29 +0200 Subject: [PATCH 712/752] [Notifier] Add gatewayapi-notifier --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 966124b01bb..56543824d46 100644 --- a/notifier.rst +++ b/notifier.rst @@ -58,6 +58,7 @@ Service Package DSN ========== ================================ ==================================================== Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` +GatewayApi ``symfony/gatewayapi-notifier`` ``gatewayapi://TOKEN@default?from=FROM`` Infobip ``symfony/infobip-notifier`` ``infobip://ACCESS_TOKEN@HOST?from=FROM`` Iqsms ``symfony/iqsms-notifier`` ``iqsms://LOGIN:PASSWORD@default?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` @@ -80,7 +81,7 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.3 - The Iqsms and Octopush integrations were introduced in Symfony 5.3. + The Iqsms, GatewayApi and Octopush integrations were introduced in Symfony 5.3. To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From 7cb4c17cb976950e1a91b22f5d69261d3b1fc3b1 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 14 Jan 2021 14:06:07 +0100 Subject: [PATCH 713/752] Sync with README from the bridge --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index ca6f17ed9a9..d328084c0b8 100644 --- a/notifier.rst +++ b/notifier.rst @@ -59,7 +59,7 @@ Service Package DSN ========== ================================ ==================================================== Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` -Infobip ``symfony/infobip-notifier`` ``infobip://ACCESS_TOKEN@HOST?from=FROM`` +Infobip ``symfony/infobip-notifier`` ``infobip://AUTH_TOKEN@HOST?from=FROM`` Mobyt ``symfony/mobyt-notifier`` ``mobyt://USER_KEY:ACCESS_TOKEN@default?from=FROM`` Nexmo ``symfony/nexmo-notifier`` ``nexmo://KEY:SECRET@default?from=FROM`` OvhCloud ``symfony/ovh-cloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLICATION_SECRET@default?consumer_key=CONSUMER_KEY&service_name=SERVICE_NAME`` From 058dfaaf96a6fe3b255b4076a172afaf50542df1 Mon Sep 17 00:00:00 2001 From: Quentin Dequippe Date: Wed, 23 Dec 2020 15:04:21 +0100 Subject: [PATCH 714/752] [Notifier] Add AllMySms service to list --- notifier.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index e6f2c653996..c27eb8ae51b 100644 --- a/notifier.rst +++ b/notifier.rst @@ -56,6 +56,7 @@ with a couple popular SMS services: ========== ================================ ==================================================== Service Package DSN ========== ================================ ==================================================== +AllMySms ``symfony/allmysms-notifier`` ``allmysms://LOGIN:APIKEY@default?from=FROM`` Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` GatewayApi ``symfony/gatewayapi-notifier`` ``gatewayapi://TOKEN@default?from=FROM`` @@ -81,7 +82,8 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.3 - The Iqsms, GatewayApi and Octopush integrations were introduced in Symfony 5.3. + The Iqsms, GatewayApi, Octopush and AllMySms integrations were introduced in Symfony 5.3. + To enable a texter, add the correct DSN in your ``.env`` file and configure the ``texter_transports``: From debedc3af64757a7ff87e64d643b92f549b465e7 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Fri, 15 Jan 2021 07:58:55 +0100 Subject: [PATCH 715/752] Rename threadKey to thread_key --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index c27eb8ae51b..da02d2a585d 100644 --- a/notifier.rst +++ b/notifier.rst @@ -150,7 +150,7 @@ Service Package DSN ========== ================================ =========================================================================== Discord ``symfony/discord-notifier`` ``discord://TOKEN@default?webhook_id=ID`` Firebase ``symfony/firebase-notifier`` ``firebase://USERNAME:PASSWORD@default`` -GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?threadKey=THREAD_KEY`` +GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?thread_key=THREAD_KEY`` LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://ACCESS_TOKEN@HOST/PATH?channel=CHANNEL`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` From ebdf28d811a8de05d691ed1cfb0c12d302f6fbec Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Thu, 7 Jan 2021 18:35:17 +0100 Subject: [PATCH 716/752] [Serializer] Add UidNormalizer normalization formats --- components/serializer.rst | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 73637fcf1a1..68a7f90f7c7 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -829,21 +829,25 @@ The Serializer component provides several built-in normalizers: :class:`Symfony\\Component\\Serializer\\Normalizer\\UidNormalizer` This normalizer converts objects that implement - :class:`Symfony\\Component\\Uid\\AbstractUid` into strings. Also it can - denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid` - or :class:`Symfony\\Component\\Uid\\Ulid`. + :class:`Symfony\\Component\\Uid\\AbstractUid` into strings. + The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Uuid` + is the `RFC 4122`_ format (example: ``d9e7a184-5d5b-11ea-a62a-3499710062d0``). + The default normalization format for objects that implement :class:`Symfony\\Component\\Uid\\Ulid` + is the Base 32 format (example: ``01E439TP9XJZ9RPFH3T1PYBCR8``). + You can change the string format by setting the serializer context option + ``UidNormalizer::NORMALIZATION_FORMAT_KEY`` to ``UidNormalizer::NORMALIZATION_FORMAT_BASE_58``, + ``UidNormalizer::NORMALIZATION_FORMAT_BASE_32`` or ``UidNormalizer::NORMALIZATION_FORMAT_RFC_4122``. + + Also it can denormalize ``uuid`` or ``ulid`` strings to :class:`Symfony\\Component\\Uid\\Uuid` + or :class:`Symfony\\Component\\Uid\\Ulid`. The format does not matter. .. versionadded:: 5.2 The ``UidNormalizer`` was introduced in Symfony 5.2. -.. note:: - - You can also create your own Normalizer to use another structure. Read more at - :doc:`/serializer/custom_normalizer`. +.. versionadded:: 5.3 -All these normalizers are enabled by default when using the Serializer component -in a Symfony application. + The ``UidNormalizer`` normalization formats were introduced in Symfony 5.3. .. _component-serializer-encoders: @@ -1616,3 +1620,4 @@ Learn more .. _`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 +.. _`RFC 4122`: https://tools.ietf.org/html/rfc4122 From 2755910b95f049af2339920d5f84581b5ea23dc5 Mon Sep 17 00:00:00 2001 From: Sebastian Paczkowski <74934099+sebpacz@users.noreply.github.com> Date: Fri, 15 Jan 2021 21:14:17 +0100 Subject: [PATCH 717/752] [Lock] Use .inner instead of decorating_service_id + '.inner' --- lock.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lock.rst b/lock.rst index a8334a12fa8..728eb85b659 100644 --- a/lock.rst +++ b/lock.rst @@ -293,4 +293,4 @@ you can do it by :doc:`decorating the store Date: Tue, 8 Dec 2020 17:11:20 +0100 Subject: [PATCH 718/752] [Notifier] Add Mercure notifier documentation --- notifier.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/notifier.rst b/notifier.rst index da02d2a585d..73bdf4d86ed 100644 --- a/notifier.rst +++ b/notifier.rst @@ -153,6 +153,7 @@ Firebase ``symfony/firebase-notifier`` ``firebase://USERNAME:PASSWORD@def GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?thread_key=THREAD_KEY`` LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://ACCESS_TOKEN@HOST/PATH?channel=CHANNEL`` +Mercure ``symfony/mercure-notifier`` ``mercure://PUBLISHER_SERVICE_ID?topic=TOPIC`` RocketChat ``symfony/rocket-chat-notifier`` ``rocketchat://TOKEN@ENDPOINT?channel=CHANNEL`` Slack ``symfony/slack-notifier`` ``slack://TOKEN@default?channel=CHANNEL`` Telegram ``symfony/telegram-notifier`` ``telegram://TOKEN@default?channel=CHAT_ID`` @@ -170,6 +171,10 @@ Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:TOKEN@HOST?channel The GoogleChat, LinkedIn, Zulip and Discord integrations were introduced in Symfony 5.2. The Slack DSN changed in Symfony 5.2 to use Slack Web API again same as in 5.0. +.. versionadded:: 5.3 + + The Mercure integration was introduced in Symfony 5.3. + Chatters are configured using the ``chatter_transports`` setting: .. code-block:: bash From 9df0164ebdc1d62d200142b26126a19d2188b466 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 17 Jan 2021 09:45:42 +0100 Subject: [PATCH 719/752] deprecate the NamespacedAttributeBag class --- components/http_foundation/sessions.rst | 10 ++++++++++ session.rst | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/components/http_foundation/sessions.rst b/components/http_foundation/sessions.rst index 9c9479e3e5e..5756a38fc58 100644 --- a/components/http_foundation/sessions.rst +++ b/components/http_foundation/sessions.rst @@ -169,6 +169,11 @@ and "Remember Me" login settings or other user based state information. :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\NamespacedAttributeBag` This implementation allows for attributes to be stored in a structured namespace. + .. deprecated:: 5.3 + + The ``NamespacedAttributeBag`` class is deprecated since Symfony 5.3. + If you need this feature, you will have to implement the class yourself. + :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBagInterface` has the API @@ -237,6 +242,11 @@ So any processing of this might quickly get ugly, even adding a token to the arr $tokens['c'] = $value; $session->set('tokens', $tokens); +.. deprecated:: 5.3 + + The ``NamespacedAttributeBag`` class is deprecated since Symfony 5.3. + If you need this feature, you will have to implement the class yourself. + With structured namespacing, the key can be translated to the array structure like this using a namespace character (which defaults to ``/``):: diff --git a/session.rst b/session.rst index 47e8cc3d269..394cfece78b 100644 --- a/session.rst +++ b/session.rst @@ -167,6 +167,11 @@ By default, session attributes are key-value pairs managed with the :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\AttributeBag` class. +.. deprecated:: 5.3 + + The ``NamespacedAttributeBag`` class is deprecated since Symfony 5.3. + If you need this feature, you will have to implement the class yourself. + If your application needs are complex, you may prefer to use :ref:`namespaced session attributes ` which are managed with the :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\NamespacedAttributeBag` From b11628ac41a4119918b51b38f6c8572704967507 Mon Sep 17 00:00:00 2001 From: Miky Mikolaj Date: Sun, 17 Jan 2021 17:34:39 +0100 Subject: [PATCH 720/752] getId(): ?Uuid missing // need test getId: ?Ulid I added all code as in example, but i had still issue with api-platform that getId() field is wrong defined... I have no experience with ULID !!! Please test my solution for This solved my issue.. and now i am able create, update or delete record without any other issues. I think that this will save lot of time for new users... because fist i thinked that must be public function getId(): ?UuidV4Generator { return $this->id; } but with this my code was still broken... now i know that there must be if you change primary identifier from Int to Uuid use Symfony\Component\Uid\Uuid; public function getId(): ?Uuid { return $this->id; } .... also i think need to done the section of Uuid and Ulid for private $someProperty; getter and setter --- components/uid.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/uid.rst b/components/uid.rst index bdeb252bb65..a7fb95d5d2f 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -141,6 +141,7 @@ entity primary keys:: // there are generators for UUID V1 and V6 too use Symfony\Bridge\Doctrine\IdGenerator\UuidV4Generator; + use Symfony\Component\Uid\Uuid; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -156,6 +157,13 @@ entity primary keys:: private $id; // ... + + public function getId(): ?Uuid + { + return $this->id; + } + + // ... } .. versionadded:: 5.2 @@ -279,6 +287,7 @@ There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator; + use Symfony\Component\Uid\Ulid; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -294,6 +303,14 @@ entity primary keys:: private $id; // ... + + public function getId(): ?Ulid + { + return $this->id; + } + + // ... + } .. versionadded:: 5.2 From b9fe645c2f413143b434d8169b74a518e7b70c40 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 18 Jan 2021 10:05:15 +0100 Subject: [PATCH 721/752] expand code example to clarify usage of the UserRepository --- security/experimental_authenticators.rst | 32 +++++++++++++++++++----- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/security/experimental_authenticators.rst b/security/experimental_authenticators.rst index c84f36ed51d..eb0ffa098e0 100644 --- a/security/experimental_authenticators.rst +++ b/security/experimental_authenticators.rst @@ -457,13 +457,33 @@ using :ref:`the user provider `:: and must return a ``UserInterface`` object (otherwise a ``UsernameNotFoundException`` is thrown):: + // src/Security/CustomAuthenticator.php + namespace App\Security; + + use App\Repository\UserRepository; // ... - $passport = new Passport( - new UserBadge($email, function ($userIdentifier) { - return $this->userRepository->findOneBy(['email' => $userIdentifier]); - }), - $credentials - ); + + class CustomAuthenticator extends AbstractAuthenticator + { + private $userRepository; + + public function __construct(UserRepository $userRepository) + { + $this->userRepository = $userRepository; + } + + public function authenticate(Request $request): PassportInterface + { + // ... + + return new Passport( + new UserBadge($email, function ($userIdentifier) { + return $this->userRepository->findOneBy(['email' => $userIdentifier]); + }), + $credentials + ); + } + } The following credential classes are supported by default: From 7c0db224906e62a43283971d6eac064588159623 Mon Sep 17 00:00:00 2001 From: Christopher Date: Tue, 19 Jan 2021 11:12:38 +0000 Subject: [PATCH 722/752] Added missing Dotenv use --- migration.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/migration.rst b/migration.rst index 6b71a07670b..ec42dfd4a33 100644 --- a/migration.rst +++ b/migration.rst @@ -239,6 +239,7 @@ could look something like this:: use App\Kernel; use App\LegacyBridge; use Symfony\Component\Debug\Debug; + use Symfony\Component\Dotenv\Dotenv; use Symfony\Component\HttpFoundation\Request; require dirname(__DIR__).'/vendor/autoload.php'; From b2be224760b653cfb0aa6f7e0d45e62c27ee0b2f Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Tue, 19 Jan 2021 09:08:55 +0100 Subject: [PATCH 723/752] Use Sf4 + Sf5 instead of Sf3 for bundle best practices --- bundles/best_practices.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bundles/best_practices.rst b/bundles/best_practices.rst index 696c9da58ff..c9dab120c53 100644 --- a/bundles/best_practices.rst +++ b/bundles/best_practices.rst @@ -181,15 +181,15 @@ A bundle should at least test: * All supported major Symfony versions (e.g. both ``4.x`` and ``5.x`` if support is claimed for both). -Thus, a bundle supporting PHP 7.3, 7.4 and 8.0, and Symfony 3.4 and 4.x should +Thus, a bundle supporting PHP 7.3, 7.4 and 8.0, and Symfony 4.4 and 5.x should have at least this test matrix: =========== =============== =================== PHP version Symfony version Composer flags =========== =============== =================== -7.3 ``3.*`` ``--prefer-lowest`` -7.4 ``4.*`` -8.0 ``4.*`` +7.3 ``4.*`` ``--prefer-lowest`` +7.4 ``5.*`` +8.0 ``5.*`` =========== =============== =================== .. tip:: From 26e88f7da3322a594b9eccbdce021bb6cf6fd4d4 Mon Sep 17 00:00:00 2001 From: Christin Gruber Date: Wed, 20 Jan 2021 17:26:23 +0100 Subject: [PATCH 724/752] Add symfony/gitter-notifier docs --- notifier.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 73bdf4d86ed..a2072e79c13 100644 --- a/notifier.rst +++ b/notifier.rst @@ -150,6 +150,7 @@ Service Package DSN ========== ================================ =========================================================================== Discord ``symfony/discord-notifier`` ``discord://TOKEN@default?webhook_id=ID`` Firebase ``symfony/firebase-notifier`` ``firebase://USERNAME:PASSWORD@default`` +Gitter ``symfony/gitter-notifier`` ``GITTER_DSN=gitter://TOKEN@default?room_id=ROOM_ID`` GoogleChat ``symfony/google-chat-notifier`` ``googlechat://ACCESS_KEY:ACCESS_TOKEN@default/SPACE?thread_key=THREAD_KEY`` LinkedIn ``symfony/linked-in-notifier`` ``linkedin://TOKEN:USER_ID@default`` Mattermost ``symfony/mattermost-notifier`` ``mattermost://ACCESS_TOKEN@HOST/PATH?channel=CHANNEL`` @@ -173,7 +174,7 @@ Zulip ``symfony/zulip-notifier`` ``zulip://EMAIL:TOKEN@HOST?channel .. versionadded:: 5.3 - The Mercure integration was introduced in Symfony 5.3. + The Gitter and Mercure integrations were introduced in Symfony 5.3. Chatters are configured using the ``chatter_transports`` setting: From 748bd54c675fbe0aeb6c01f385c5e68d002d1157 Mon Sep 17 00:00:00 2001 From: Wojciech Kania Date: Sat, 14 Nov 2020 15:37:16 +0100 Subject: [PATCH 725/752] [Validator] Document constraints as php 8 Attributes --- reference/constraints/Bic.rst | 13 +++ reference/constraints/Blank.rst | 13 +++ reference/constraints/Callback.rst | 30 +++++++ reference/constraints/CardScheme.rst | 16 ++++ reference/constraints/Choice.rst | 45 ++++++++++ reference/constraints/Count.rst | 18 ++++ reference/constraints/Country.rst | 13 +++ reference/constraints/Currency.rst | 13 +++ reference/constraints/Date.rst | 13 +++ reference/constraints/DateTime.rst | 16 ++++ reference/constraints/DivisibleBy.rst | 18 ++++ reference/constraints/Email.rst | 15 ++++ reference/constraints/EqualTo.rst | 18 ++++ reference/constraints/Expression.rst | 54 ++++++++++++ .../constraints/ExpressionLanguageSyntax.rst | 18 ++++ reference/constraints/File.rst | 17 ++++ reference/constraints/GreaterThan.rst | 57 +++++++++++++ reference/constraints/GreaterThanOrEqual.rst | 57 +++++++++++++ reference/constraints/Hostname.rst | 13 +++ reference/constraints/Iban.rst | 15 ++++ reference/constraints/IdenticalTo.rst | 18 ++++ reference/constraints/Image.rst | 34 ++++++++ reference/constraints/Ip.rst | 13 +++ reference/constraints/IsFalse.rst | 18 ++++ reference/constraints/IsNull.rst | 13 +++ reference/constraints/IsTrue.rst | 18 ++++ reference/constraints/Isbn.rst | 16 ++++ reference/constraints/Isin.rst | 13 +++ reference/constraints/Issn.rst | 13 +++ reference/constraints/Json.rst | 15 ++++ reference/constraints/Language.rst | 13 +++ reference/constraints/Length.rst | 19 +++++ reference/constraints/LessThan.rst | 57 +++++++++++++ reference/constraints/LessThanOrEqual.rst | 57 +++++++++++++ reference/constraints/Locale.rst | 15 ++++ reference/constraints/Luhn.rst | 13 +++ reference/constraints/Negative.rst | 13 +++ reference/constraints/NegativeOrZero.rst | 13 +++ reference/constraints/NotBlank.rst | 13 +++ .../constraints/NotCompromisedPassword.rst | 13 +++ reference/constraints/NotEqualTo.rst | 18 ++++ reference/constraints/NotIdenticalTo.rst | 18 ++++ reference/constraints/NotNull.rst | 13 +++ reference/constraints/Positive.rst | 13 +++ reference/constraints/PositiveOrZero.rst | 13 +++ reference/constraints/Range.rst | 65 +++++++++++++++ reference/constraints/Regex.rst | 46 +++++++++++ reference/constraints/Time.rst | 16 ++++ reference/constraints/Timezone.rst | 13 +++ reference/constraints/Traverse.rst | 82 +++++++++++++++++++ reference/constraints/Type.rst | 25 ++++++ reference/constraints/Ulid.rst | 13 +++ reference/constraints/Unique.rst | 13 +++ reference/constraints/UniqueEntity.rst | 54 ++++++++++++ reference/constraints/Url.rst | 58 +++++++++++++ reference/constraints/UserPassword.rst | 15 ++++ reference/constraints/Uuid.rst | 13 +++ reference/constraints/Valid.rst | 47 +++++++++++ 58 files changed, 1404 insertions(+) diff --git a/reference/constraints/Bic.rst b/reference/constraints/Bic.rst index 029a322e294..076cbf29b6c 100644 --- a/reference/constraints/Bic.rst +++ b/reference/constraints/Bic.rst @@ -41,6 +41,19 @@ will contain a Business Identifier Code (BIC). protected $businessIdentifierCode; } + .. code-block:: php-attributes + + // src/Entity/Transaction.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Transaction + { + #[Assert\Bic] + protected $businessIdentifierCode; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Blank.rst b/reference/constraints/Blank.rst index 8a5ba13671a..fbbd693e013 100644 --- a/reference/constraints/Blank.rst +++ b/reference/constraints/Blank.rst @@ -45,6 +45,19 @@ of an ``Author`` class were blank, you could do the following: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Blank] + protected $firstName; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Callback.rst b/reference/constraints/Callback.rst index 6985f3953e1..d15337ba9b5 100644 --- a/reference/constraints/Callback.rst +++ b/reference/constraints/Callback.rst @@ -50,6 +50,23 @@ Configuration } } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + use Symfony\Component\Validator\Context\ExecutionContextInterface; + + class Author + { + #[Assert\Callback] + public function validate(ExecutionContextInterface $context, $payload) + { + // ... + } + } + .. code-block:: yaml # config/validator/validation.yaml @@ -178,6 +195,19 @@ You can then use the following configuration to invoke this validator: { } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Acme\Validator; + use Symfony\Component\Validator\Constraints as Assert; + + #[Assert\Callback([Validator::class, 'validate'])] + class Author + { + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index 64d6157e2c8..d93224e1a5a 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -41,6 +41,22 @@ on an object that will contain a credit card number. protected $cardNumber; } + .. code-block:: php-attributes + + // src/Entity/Transaction.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Transaction + { + #[Assert\CardScheme( + schemes: [Assert\CardScheme::VISA], + message: 'Your credit card number is invalid.', + )] + protected $cardNumber; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Choice.rst b/reference/constraints/Choice.rst index fd8481d6152..4afa6b516d9 100644 --- a/reference/constraints/Choice.rst +++ b/reference/constraints/Choice.rst @@ -58,6 +58,24 @@ If your valid choice list is simple, you can pass them in directly via the protected $genre; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + const GENRES = ['fiction', 'non-fiction']; + + #[Assert\Choice(['New York', 'Berlin', 'Tokyo'])] + protected $city; + + #[Assert\Choice(choices: Author::GENRES, message: 'Choose a valid genre.')] + protected $genre; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -160,6 +178,19 @@ constraint. protected $genre; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Choice(callback: 'getGenres')] + protected $genre; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -225,6 +256,20 @@ you can pass the class name and the method as an array. protected $genre; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use App\Entity\Genre + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Choice(callback: [Genre::class, 'getGenres'])] + protected $genre; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Count.rst b/reference/constraints/Count.rst index 4ce4691c6c9..c40294a8684 100644 --- a/reference/constraints/Count.rst +++ b/reference/constraints/Count.rst @@ -47,6 +47,24 @@ you might add the following: protected $emails = []; } + .. code-block:: php-attributes + + // src/Entity/Participant.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Participant + { + #[Assert\Count( + min: 1, + max: 5, + minMessage: 'You must specify at least one email', + maxMessage: 'You cannot specify more than {{ limit }} emails', + )] + protected $emails = []; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Country.rst b/reference/constraints/Country.rst index 744de6dd0fb..62bf38bf2ba 100644 --- a/reference/constraints/Country.rst +++ b/reference/constraints/Country.rst @@ -33,6 +33,19 @@ Basic Usage protected $country; } + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class User + { + #[Assert\Country] + protected $country; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Currency.rst b/reference/constraints/Currency.rst index 651af1b1a92..e481c0ce01d 100644 --- a/reference/constraints/Currency.rst +++ b/reference/constraints/Currency.rst @@ -35,6 +35,19 @@ a valid currency, you could do the following: protected $currency; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\Currency] + protected $currency; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Date.rst b/reference/constraints/Date.rst index 4b1e99c3ed1..7376195960a 100644 --- a/reference/constraints/Date.rst +++ b/reference/constraints/Date.rst @@ -34,6 +34,19 @@ Basic Usage protected $birthday; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Date] + protected $birthday; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/DateTime.rst b/reference/constraints/DateTime.rst index 582f93aeac8..7e5501b5515 100644 --- a/reference/constraints/DateTime.rst +++ b/reference/constraints/DateTime.rst @@ -35,6 +35,22 @@ Basic Usage protected $createdAt; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + /** + * @var string A "Y-m-d H:i:s" formatted value + */ + #[Assert\DateTime] + protected $createdAt; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/DivisibleBy.rst b/reference/constraints/DivisibleBy.rst index 4503959aa57..d08e22c241c 100644 --- a/reference/constraints/DivisibleBy.rst +++ b/reference/constraints/DivisibleBy.rst @@ -53,6 +53,24 @@ The following constraints ensure that: protected $quantity; } + .. code-block:: php-attributes + + // src/Entity/Item.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Item + { + #[Assert\DivisibleBy(0.25)] + protected $weight; + + #[Assert\DivisibleBy( + value: 5, + )] + protected $quantity; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Email.rst b/reference/constraints/Email.rst index 468051004a0..fd2f2576a90 100644 --- a/reference/constraints/Email.rst +++ b/reference/constraints/Email.rst @@ -37,6 +37,21 @@ Basic Usage protected $email; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Email( + message: 'The email {{ value }} is not a valid email.', + )] + protected $email; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/EqualTo.rst b/reference/constraints/EqualTo.rst index 153d13a3098..75d80043cda 100644 --- a/reference/constraints/EqualTo.rst +++ b/reference/constraints/EqualTo.rst @@ -52,6 +52,24 @@ and that the ``age`` is ``20``, you could do the following: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\EqualTo("Mary")] + protected $firstName; + + #[Assert\EqualTo( + value: 20, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Expression.rst b/reference/constraints/Expression.rst index 2ed816f3a03..264ae3b02fc 100644 --- a/reference/constraints/Expression.rst +++ b/reference/constraints/Expression.rst @@ -78,6 +78,22 @@ One way to accomplish this is with the Expression constraint: // ... } + .. code-block:: php-attributes + + // src/Model/BlogPost.php + namespace App\Model; + + use Symfony\Component\Validator\Constraints as Assert; + + #[Assert\Expression( + "this.getCategory() in ['php', 'symfony'] or !this.isTechnicalPost()", + message: 'If this is a tech post, the category should be either php or symfony!', + )] + class BlogPost + { + // ... + } + .. code-block:: yaml # config/validator/validation.yaml @@ -163,6 +179,26 @@ more about the expression language syntax, see // ... } + .. code-block:: php-attributes + + // src/Model/BlogPost.php + namespace App\Model; + + use Symfony\Component\Validator\Constraints as Assert; + + class BlogPost + { + // ... + + #[Assert\Expression( + "this.getCategory() in ['php', 'symfony'] or value == false", + message: 'If this is a tech post, the category should be either php or symfony!', + )] + private $isTechnicalPost; + + // ... + } + .. code-block:: yaml # config/validator/validation.yaml @@ -299,6 +335,24 @@ type (numeric, boolean, strings, null, etc.) // ... } + .. code-block:: php-attributes + + // src/Model/Analysis.php + namespace App\Model; + + use Symfony\Component\Validator\Constraints as Assert; + + class Analysis + { + #[Assert\Expression( + 'value + error_margin < threshold', + values: ['error_margin' => 0.25, 'threshold' => 1.5], + )] + private $metric; + + // ... + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/ExpressionLanguageSyntax.rst b/reference/constraints/ExpressionLanguageSyntax.rst index 2ca0355dfaf..218d68d4f69 100644 --- a/reference/constraints/ExpressionLanguageSyntax.rst +++ b/reference/constraints/ExpressionLanguageSyntax.rst @@ -52,6 +52,24 @@ The following constraints ensure that: protected $shippingOptions; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\ExpressionLanguageSyntax] + protected $promotion; + + #[Assert\ExpressionLanguageSyntax( + allowedVariables: ['user', 'shipping_centers'], + )] + protected $shippingOptions; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/File.rst b/reference/constraints/File.rst index f1a27ac8f20..7bce9dce533 100644 --- a/reference/constraints/File.rst +++ b/reference/constraints/File.rst @@ -93,6 +93,23 @@ below a certain file size and a valid PDF, add the following: protected $bioFile; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\File( + maxSize: '1024k', + mimeTypes: ['application/pdf', 'application/x-pdf'], + mimeTypesMessage: 'Please upload a valid PDF', + )] + protected $bioFile; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/GreaterThan.rst b/reference/constraints/GreaterThan.rst index d27017fdbe5..617fc71f2a0 100644 --- a/reference/constraints/GreaterThan.rst +++ b/reference/constraints/GreaterThan.rst @@ -49,6 +49,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\GreaterThan(5)] + protected $siblings; + + #[Assert\GreaterThan( + value: 18, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -126,6 +144,19 @@ that a date must at least be the next day: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThan('today')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -185,6 +216,19 @@ dates. If you want to fix the timezone, append it to the date string: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThan('today UTC')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -245,6 +289,19 @@ current time: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThan('+5 hours')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/GreaterThanOrEqual.rst b/reference/constraints/GreaterThanOrEqual.rst index 8a054e6bbb9..c09d4e250e0 100644 --- a/reference/constraints/GreaterThanOrEqual.rst +++ b/reference/constraints/GreaterThanOrEqual.rst @@ -48,6 +48,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\GreaterThanOrEqual(5)] + protected $siblings; + + #[Assert\GreaterThanOrEqual( + value: 18, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -125,6 +143,19 @@ that a date must at least be the current day: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThanOrEqual('today')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -184,6 +215,19 @@ dates. If you want to fix the timezone, append it to the date string: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThanOrEqual('today UTC')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -244,6 +288,19 @@ current time: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\GreaterThanOrEqual('+5 hours')] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Hostname.rst b/reference/constraints/Hostname.rst index 9e67fb3c8fc..7b6cf07af21 100644 --- a/reference/constraints/Hostname.rst +++ b/reference/constraints/Hostname.rst @@ -42,6 +42,19 @@ will contain a host name. protected $name; } + .. code-block:: php-attributes + + // src/Entity/ServerSettings.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class ServerSettings + { + #[Assert\Hostname(message: 'The server name must be a valid hostname.')] + protected $name; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Iban.rst b/reference/constraints/Iban.rst index 709270f7b12..dcd60e3f408 100644 --- a/reference/constraints/Iban.rst +++ b/reference/constraints/Iban.rst @@ -40,6 +40,21 @@ will contain an International Bank Account Number. protected $bankAccountNumber; } + .. code-block:: php-attributes + + // src/Entity/Transaction.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Transaction + { + #[Assert\Iban( + message: 'This is not a valid International Bank Account Number (IBAN).', + )] + protected $bankAccountNumber; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/IdenticalTo.rst b/reference/constraints/IdenticalTo.rst index 10f1fb52342..7dc71b475f0 100644 --- a/reference/constraints/IdenticalTo.rst +++ b/reference/constraints/IdenticalTo.rst @@ -54,6 +54,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\IdenticalTo("Mary")] + protected $firstName; + + #[Assert\IdenticalTo( + value: 20, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Image.rst b/reference/constraints/Image.rst index e8b492bf4ae..5ffded599b5 100644 --- a/reference/constraints/Image.rst +++ b/reference/constraints/Image.rst @@ -100,6 +100,24 @@ that it is between a certain size, add the following: protected $headshot; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Image( + minWidth: 200, + maxWidth: 400, + minHeight: 200, + maxHeight: 400, + )] + protected $headshot; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -180,6 +198,22 @@ following code: protected $headshot; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Image( + allowLandscape: false, + allowPortrait: false, + )] + protected $headshot; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Ip.rst b/reference/constraints/Ip.rst index 9d744d54c09..3686d6bfc41 100644 --- a/reference/constraints/Ip.rst +++ b/reference/constraints/Ip.rst @@ -36,6 +36,19 @@ Basic Usage protected $ipAddress; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Ip] + protected $ipAddress; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/IsFalse.rst b/reference/constraints/IsFalse.rst index 17881aa9a75..07f25396c66 100644 --- a/reference/constraints/IsFalse.rst +++ b/reference/constraints/IsFalse.rst @@ -58,6 +58,24 @@ method returns **false**: } } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\IsFalse( + message: "You've entered an invalid state." + )] + public function isStateInvalid() + { + // ... + } + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/IsNull.rst b/reference/constraints/IsNull.rst index 252c23d934b..6fcd1e462ad 100644 --- a/reference/constraints/IsNull.rst +++ b/reference/constraints/IsNull.rst @@ -39,6 +39,19 @@ of an ``Author`` class exactly equal to ``null``, you could do the following: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\IsNull] + protected $firstName; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/IsTrue.rst b/reference/constraints/IsTrue.rst index 2698ad233e9..dea5d9c5468 100644 --- a/reference/constraints/IsTrue.rst +++ b/reference/constraints/IsTrue.rst @@ -60,6 +60,24 @@ Then you can validate this method with ``IsTrue`` as follows: } } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + protected $token; + + #[Assert\IsTrue(message: 'The token is invalid.')] + public function isTokenValid() + { + return $this->token == $this->generateToken(); + } + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index e30d4e96040..fa042eb131e 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -43,6 +43,22 @@ on an object that will contain an ISBN. protected $isbn; } + .. code-block:: php-attributes + + // src/Entity/Book.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Book + { + #[Assert\Isbn( + type: Assert\Isbn::ISBN_10, + message: 'This value is not valid.', + )] + protected $isbn; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Isin.rst b/reference/constraints/Isin.rst index c646f33a53a..3efab915437 100644 --- a/reference/constraints/Isin.rst +++ b/reference/constraints/Isin.rst @@ -33,6 +33,19 @@ Basic Usage protected $isin; } + .. code-block:: php-attributes + + // src/Entity/UnitAccount.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class UnitAccount + { + #[Assert\Isin] + protected $isin; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Issn.rst b/reference/constraints/Issn.rst index 6cc5734aaa2..8b8d0826610 100644 --- a/reference/constraints/Issn.rst +++ b/reference/constraints/Issn.rst @@ -35,6 +35,19 @@ Basic Usage protected $issn; } + .. code-block:: php-attributes + + // src/Entity/Journal.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Journal + { + #[Assert\Issn] + protected $issn; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Json.rst b/reference/constraints/Json.rst index 6e8318077da..cd1abf69d6c 100644 --- a/reference/constraints/Json.rst +++ b/reference/constraints/Json.rst @@ -35,6 +35,21 @@ The ``Json`` constraint can be applied to a property or a "getter" method: private $chapters; } + .. code-block:: php-attributes + + // src/Entity/Book.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Book + { + #[Assert\Json( + message: "You've entered an invalid Json." + )] + private $chapters; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Language.rst b/reference/constraints/Language.rst index dac3e2819db..0d9522dc882 100644 --- a/reference/constraints/Language.rst +++ b/reference/constraints/Language.rst @@ -34,6 +34,19 @@ Basic Usage protected $preferredLanguage; } + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class User + { + #[Assert\Language] + protected $preferredLanguage; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Length.rst b/reference/constraints/Length.rst index 365aedfb585..13800f7daea 100644 --- a/reference/constraints/Length.rst +++ b/reference/constraints/Length.rst @@ -48,6 +48,25 @@ and "50", you might add the following: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Participant.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Participant + { + #[Assert\Length( + min: 2, + max: 50, + minMessage: 'Your first name must be at least {{ limit }} characters long', + maxMessage: 'Your first name cannot be longer than {{ limit }} characters', + )] + protected $firstName; + } + + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/LessThan.rst b/reference/constraints/LessThan.rst index abd0aab721c..495d3f4356a 100644 --- a/reference/constraints/LessThan.rst +++ b/reference/constraints/LessThan.rst @@ -49,6 +49,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThan(5)] + protected $siblings; + + #[Assert\LessThan( + value: 80, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -126,6 +144,19 @@ that a date must be in the past like this: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThan('today')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -185,6 +216,19 @@ dates. If you want to fix the timezone, append it to the date string: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThan('today UTC')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -244,6 +288,19 @@ can check that a person must be at least 18 years old like this: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThan('-18 years')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/LessThanOrEqual.rst b/reference/constraints/LessThanOrEqual.rst index 42ec3e939e5..47d06cfc601 100644 --- a/reference/constraints/LessThanOrEqual.rst +++ b/reference/constraints/LessThanOrEqual.rst @@ -48,6 +48,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThanOrEqual(5)] + protected $siblings; + + #[Assert\LessThanOrEqual( + value: 80, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -125,6 +143,19 @@ that a date must be today or in the past like this: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThanOrEqual('today')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -184,6 +215,19 @@ dates. If you want to fix the timezone, append it to the date string: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThanOrEqual('today UTC')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -243,6 +287,19 @@ can check that a person must be at least 18 years old like this: protected $dateOfBirth; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\LessThanOrEqual('-18 years')] + protected $dateOfBirth; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Locale.rst b/reference/constraints/Locale.rst index f5f381629e3..936cfd24089 100644 --- a/reference/constraints/Locale.rst +++ b/reference/constraints/Locale.rst @@ -43,6 +43,21 @@ Basic Usage protected $locale; } + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class User + { + #[Assert\Locale( + canonicalize: true, + )] + protected $locale; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Luhn.rst b/reference/constraints/Luhn.rst index 2bee41d5f2c..24eb9b91947 100644 --- a/reference/constraints/Luhn.rst +++ b/reference/constraints/Luhn.rst @@ -37,6 +37,19 @@ will contain a credit card number. protected $cardNumber; } + .. code-block:: php-attributes + + // src/Entity/Transaction.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Transaction + { + #[Assert\Luhn(message: 'Please check your credit card number.')] + protected $cardNumber; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Negative.rst b/reference/constraints/Negative.rst index 7468b4bfc4a..0ee0bdcf3ea 100644 --- a/reference/constraints/Negative.rst +++ b/reference/constraints/Negative.rst @@ -37,6 +37,19 @@ The following constraint ensures that the ``withdraw`` of a bank account protected $withdraw; } + .. code-block:: php-attributes + + // src/Entity/TransferItem.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class TransferItem + { + #[Assert\Negative] + protected $withdraw; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NegativeOrZero.rst b/reference/constraints/NegativeOrZero.rst index f010acda0b1..8559a57babf 100644 --- a/reference/constraints/NegativeOrZero.rst +++ b/reference/constraints/NegativeOrZero.rst @@ -36,6 +36,19 @@ is a negative number or equal to zero: protected $level; } + .. code-block:: php-attributes + + // src/Entity/TransferItem.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class UnderGroundGarage + { + #[Assert\NegativeOrZero] + protected $level; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NotBlank.rst b/reference/constraints/NotBlank.rst index f5711e001c3..2d302f5fc20 100644 --- a/reference/constraints/NotBlank.rst +++ b/reference/constraints/NotBlank.rst @@ -40,6 +40,19 @@ class were not blank, you could do the following: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\NotBlank] + protected $firstName; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NotCompromisedPassword.rst b/reference/constraints/NotCompromisedPassword.rst index bcd1c61b560..236dfbf5d9b 100644 --- a/reference/constraints/NotCompromisedPassword.rst +++ b/reference/constraints/NotCompromisedPassword.rst @@ -38,6 +38,19 @@ The following constraint ensures that the ``rawPassword`` property of the protected $rawPassword; } + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class User + { + #[Assert\NotCompromisedPassword] + protected $rawPassword; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NotEqualTo.rst b/reference/constraints/NotEqualTo.rst index e1436657ae8..ec5fa5000b5 100644 --- a/reference/constraints/NotEqualTo.rst +++ b/reference/constraints/NotEqualTo.rst @@ -53,6 +53,24 @@ the following: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\NotEqualTo('Mary')] + protected $firstName; + + #[Assert\NotEqualTo( + value: 15, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NotIdenticalTo.rst b/reference/constraints/NotIdenticalTo.rst index 66ccb871670..ab96bde3806 100644 --- a/reference/constraints/NotIdenticalTo.rst +++ b/reference/constraints/NotIdenticalTo.rst @@ -54,6 +54,24 @@ The following constraints ensure that: protected $age; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\NotIdenticalTo('Mary')] + protected $firstName; + + #[Assert\NotIdenticalTo( + value: 15, + )] + protected $age; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/NotNull.rst b/reference/constraints/NotNull.rst index 56d088c4cba..ccf8839434d 100644 --- a/reference/constraints/NotNull.rst +++ b/reference/constraints/NotNull.rst @@ -37,6 +37,19 @@ class were not strictly equal to ``null``, you would: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\NotNull] + protected $firstName; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Positive.rst b/reference/constraints/Positive.rst index af76f205e53..6e5d80c9250 100644 --- a/reference/constraints/Positive.rst +++ b/reference/constraints/Positive.rst @@ -37,6 +37,19 @@ positive number (greater than zero): protected $income; } + .. code-block:: php-attributes + + // src/Entity/Employee.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Employee + { + #[Assert\Positive] + protected $income; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/PositiveOrZero.rst b/reference/constraints/PositiveOrZero.rst index ea762e78f90..08435c2054f 100644 --- a/reference/constraints/PositiveOrZero.rst +++ b/reference/constraints/PositiveOrZero.rst @@ -36,6 +36,19 @@ is positive or zero: protected $siblings; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\PositiveOrZero] + protected $siblings; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Range.rst b/reference/constraints/Range.rst index d5b473362dd..c499187ee66 100644 --- a/reference/constraints/Range.rst +++ b/reference/constraints/Range.rst @@ -47,6 +47,23 @@ you might add the following: protected $height; } + .. code-block:: php-attributes + + // src/Entity/Participant.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Participant + { + #[Assert\Range( + min: 120, + max: 180, + notInRangeMessage: 'You must be between {{ min }}cm and {{ max }}cm tall to enter', + )] + protected $height; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -125,6 +142,22 @@ date must lie within the current year like this: protected $startDate; } + .. code-block:: php-attributes + + // src/Entity/Event.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Event + { + #[Assert\Range( + min: 'first day of January', + max: 'first day of January next year', + )] + protected $startDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -195,6 +228,22 @@ dates. If you want to fix the timezone, append it to the date string: protected $startDate; } + .. code-block:: php-attributes + + // src/Entity/Event.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Event + { + #[Assert\Range( + min: 'first day of January UTC', + max: 'first day of January next year UTC', + )] + protected $startDate; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -265,6 +314,22 @@ can check that a delivery date starts within the next five hours like this: protected $deliveryDate; } + .. code-block:: php-attributes + + // src/Entity/Order.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Order + { + #[Assert\Range( + min: 'now', + max: '+5 hours', + )] + protected $deliveryDate; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Regex.rst b/reference/constraints/Regex.rst index 642a1fc180d..a6217c892f7 100644 --- a/reference/constraints/Regex.rst +++ b/reference/constraints/Regex.rst @@ -41,6 +41,19 @@ more word characters at the beginning of your string: protected $description; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Regex('/^\w+/')] + protected $description; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -110,6 +123,23 @@ it a custom message: protected $firstName; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Regex( + pattern: '/\d/', + match: false, + message: 'Your name cannot contain a number', + )] + protected $firstName; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -203,6 +233,22 @@ need to specify the HTML5 compatible pattern in the ``htmlPattern`` option: protected $name; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Regex( + pattern: '/^[a-z]+$/i', + match: '^[a-zA-Z]+$' + )] + protected $name; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Time.rst b/reference/constraints/Time.rst index e94613e1f6f..fb8a9b337fb 100644 --- a/reference/constraints/Time.rst +++ b/reference/constraints/Time.rst @@ -37,6 +37,22 @@ of the day when the event starts: protected $startsAt; } + .. code-block:: php-attributes + + // src/Entity/Event.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Event + { + /** + * @var string A "H:i:s" formatted value + */ + #[Assert\Time] + protected $startsAt; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Timezone.rst b/reference/constraints/Timezone.rst index 98ca73c156a..36ebdd0b86b 100644 --- a/reference/constraints/Timezone.rst +++ b/reference/constraints/Timezone.rst @@ -38,6 +38,19 @@ string which contains any of the `PHP timezone identifiers`_ (e.g. ``America/New protected $timezone; } + .. code-block:: php-attributes + + // src/Entity/UserSettings.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class UserSettings + { + #[Assert\Timezone] + protected $timezone; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Traverse.rst b/reference/constraints/Traverse.rst index fd329bd38a3..9301afc445a 100644 --- a/reference/constraints/Traverse.rst +++ b/reference/constraints/Traverse.rst @@ -89,6 +89,73 @@ that all have constraints on their properties. } } + .. code-block:: php-attributes + + // src/Entity/BookCollection.php + namespace App\Entity; + + use Doctrine\Common\Collections\ArrayCollection; + use Doctrine\Common\Collections\Collection + use Doctrine\ORM\Mapping as ORM; + use Symfony\Component\Validator\Constraints as Assert; + + /** + * @ORM\Entity + */ + #[Assert\Traverse] + class BookCollection implements \IteratorAggregate + { + /** + * @var string + * + * @ORM\Column + */ + #[Assert\NotBlank] + protected $name = ''; + + /** + * @var Collection|Book[] + * + * @ORM\ManyToMany(targetEntity="App\Entity\Book") + */ + protected $books; + + // some other properties + + public function __construct() + { + $this->books = new ArrayCollection(); + } + + // ... setter for name, adder and remover for books + + // the name can be validated by calling the getter + public function getName(): string + { + return $this->name; + } + + /** + * @return \Generator|Book[] The books for a given author + */ + public function getBooksForAuthor(Author $author): iterable + { + foreach ($this->books as $book) { + if ($book->isAuthoredBy($author)) { + yield $book; + } + } + } + + // neither the method above nor any other specific getter + // could be used to validated all nested books; + // this object needs to be traversed to call the iterator + public function getIterator() + { + return $this->books->getIterator(); + } + } + .. code-block:: yaml # config/validator/validation.yaml @@ -168,6 +235,21 @@ disable validating: // ... } + .. code-block:: php-attributes + + // src/Entity/BookCollection.php + + // ... same as above + + /** + * ... + */ + #[Assert\Traverse(false)] + class BookCollection implements \IteratorAggregate + { + // ... + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Type.rst b/reference/constraints/Type.rst index 1962dffa284..61189e7f989 100644 --- a/reference/constraints/Type.rst +++ b/reference/constraints/Type.rst @@ -59,6 +59,31 @@ This will check if ``id`` is an instance of ``Ramsey\Uuid\UuidInterface``, protected $accessCode; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Type('Ramsey\Uuid\UuidInterface')] + protected $id; + + #[Assert\Type('string')] + protected $firstName; + + #[Assert\Type( + type: 'integer', + message: 'The value {{ value }} is not a valid {{ type }}.', + )] + protected $age; + + #[Assert\Type(type: ['alpha', 'digit'])] + protected $accessCode; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Ulid.rst b/reference/constraints/Ulid.rst index 7bcae08e961..92315089350 100644 --- a/reference/constraints/Ulid.rst +++ b/reference/constraints/Ulid.rst @@ -37,6 +37,19 @@ Basic Usage protected $identifier; } + .. code-block:: php-attributes + + // src/Entity/File.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class File + { + #[Assert\Ulid] + protected $identifier; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Unique.rst b/reference/constraints/Unique.rst index 97cb6ff8602..497156ed9b4 100644 --- a/reference/constraints/Unique.rst +++ b/reference/constraints/Unique.rst @@ -50,6 +50,19 @@ strings: protected $contactEmails; } + .. code-block:: php-attributes + + // src/Entity/Person.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Person + { + #[Assert\Unique] + protected $contactEmails; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/UniqueEntity.rst b/reference/constraints/UniqueEntity.rst index 2bf2533f57e..c76a31e6a4c 100644 --- a/reference/constraints/UniqueEntity.rst +++ b/reference/constraints/UniqueEntity.rst @@ -59,6 +59,31 @@ between all of the rows in your user table: protected $email; } + .. code-block:: php-attributes + + // src/Entity/User.php + namespace App\Entity; + + use Doctrine\ORM\Mapping as ORM; + + // DON'T forget the following use statement!!! + use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + + use Symfony\Component\Validator\Constraints as Assert; + + /** + * @ORM\Entity + */ + #[UniqueEntity('email')] + class User + { + /** + * @ORM\Column(name="email", type="string", length=255, unique=true) + */ + #[Assert\Email] + protected $email; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -188,6 +213,35 @@ Consider this example: public $port; } + .. code-block:: php-attributes + + // src/Entity/Service.php + namespace App\Entity; + + use Doctrine\ORM\Mapping as ORM; + use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; + + /** + * @ORM\Entity + */ + #[UniqueEntity( + fields: ['host', 'port'], + errorPath: 'port', + message: 'This port is already in use on that host.', + )] + class Service + { + /** + * @ORM\ManyToOne(targetEntity="App\Entity\Host") + */ + public $host; + + /** + * @ORM\Column(type="integer") + */ + public $port; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Url.rst b/reference/constraints/Url.rst index 5f4ac23245f..91714131294 100644 --- a/reference/constraints/Url.rst +++ b/reference/constraints/Url.rst @@ -35,6 +35,19 @@ Basic Usage protected $bioUrl; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Url] + protected $bioUrl; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -124,6 +137,21 @@ Parameter Description protected $bioUrl; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Url( + message: 'The url {{ value }} is not a valid url', + )] + protected $bioUrl; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -200,6 +228,21 @@ the ``ftp://`` type URLs to be valid, redefine the ``protocols`` array, listing protected $bioUrl; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Url( + protocols: ['http', 'https', 'ftp'], + )] + protected $bioUrl; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -275,6 +318,21 @@ also relative URLs that contain no protocol (e.g. ``//example.com``). protected $bioUrl; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Url( + relativeProtocol: true, + )] + protected $bioUrl; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/UserPassword.rst b/reference/constraints/UserPassword.rst index 9655380bf95..03c992e66e6 100644 --- a/reference/constraints/UserPassword.rst +++ b/reference/constraints/UserPassword.rst @@ -51,6 +51,21 @@ the user's current password: protected $oldPassword; } + .. code-block:: php-attributes + + // src/Form/Model/ChangePassword.php + namespace App\Form\Model; + + use Symfony\Component\Security\Core\Validator\Constraints as SecurityAssert; + + class ChangePassword + { + #[SecurityAssert\UserPassword( + message: 'Wrong value for your current password', + )] + protected $oldPassword; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Uuid.rst b/reference/constraints/Uuid.rst index 427a373f788..c7b2d94900b 100644 --- a/reference/constraints/Uuid.rst +++ b/reference/constraints/Uuid.rst @@ -38,6 +38,19 @@ Basic Usage protected $identifier; } + .. code-block:: php-attributes + + // src/Entity/File.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class File + { + #[Assert\Uuid] + protected $identifier; + } + .. code-block:: yaml # config/validator/validation.yaml diff --git a/reference/constraints/Valid.rst b/reference/constraints/Valid.rst index 1cb992128ac..8378f34cbec 100644 --- a/reference/constraints/Valid.rst +++ b/reference/constraints/Valid.rst @@ -87,6 +87,40 @@ stores an ``Address`` instance in the ``$address`` property:: protected $address; } + .. code-block:: php-attributes + + // src/Entity/Address.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Address + { + #[Assert\NotBlank] + protected $street; + + #[Assert\NotBlank] + #[Assert\Length(max: 5)] + protected $zipCode; + } + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\NotBlank] + #[Assert\Length(min: 4)] + protected $firstName; + + #[Assert\NotBlank] + protected $lastName; + + protected $address; + } + .. code-block:: yaml # config/validator/validation.yaml @@ -196,6 +230,19 @@ an invalid address. To prevent that, add the ``Valid`` constraint to the protected $address; } + .. code-block:: php-attributes + + // src/Entity/Author.php + namespace App\Entity; + + use Symfony\Component\Validator\Constraints as Assert; + + class Author + { + #[Assert\Valid] + protected $address; + } + .. code-block:: yaml # config/validator/validation.yaml From b703a22e5c286c2a1f10369d97a00ede143e590b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 22 Jan 2021 16:59:27 +0100 Subject: [PATCH 726/752] Tweaks --- components/phpunit_bridge.rst | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/phpunit_bridge.rst b/components/phpunit_bridge.rst index 289346547c7..674c5d1c519 100644 --- a/components/phpunit_bridge.rst +++ b/components/phpunit_bridge.rst @@ -302,17 +302,16 @@ whenever you want to update the existing file): .. code-block:: terminal - $ SYMFONY_DEPRECATIONS_HELPER='generateBaseline=true&baselineFile=tests/allowed.json' ./vendor/bin/simple-phpunit + $ SYMFONY_DEPRECATIONS_HELPER='generateBaseline=true&baselineFile=./tests/allowed.json' ./vendor/bin/simple-phpunit This command stores all the deprecations reported while running tests in the -given file and encoded in JSON. The file path defined in ``baselineFile`` can -be absolute or relative to your project root. +given file path and encoded in JSON. Then, you can run the following command to use that file and ignore those deprecations: .. code-block:: terminal - $ SYMFONY_DEPRECATIONS_HELPER='baselineFile=tests/allowed.json' ./vendor/bin/simple-phpunit + $ SYMFONY_DEPRECATIONS_HELPER='baselineFile=./tests/allowed.json' ./vendor/bin/simple-phpunit .. versionadded:: 5.2 From 78c0441a5b370c6789e0f399bbc896ef86d542c4 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 22 Jan 2021 17:31:27 +0100 Subject: [PATCH 727/752] Tweaks --- messenger.rst | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/messenger.rst b/messenger.rst index e73498c6c84..edd43cd7881 100644 --- a/messenger.rst +++ b/messenger.rst @@ -1309,6 +1309,16 @@ during a request:: } } +The transport has a number of options: + +``serialize`` (boolean, default: ``false``) + Whether to serialize messages or not. This is useful to test an additional + layer, especially when you use your own message serializer. + +.. versionadded:: 5.3 + + The ``serialize`` option was introduced in Symfony 5.3. + .. note:: All ``in-memory`` transports will be reset automatically after each test **in** @@ -1316,15 +1326,6 @@ during a request:: :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase` or :class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase`. -.. tip:: - - Using ``in-memory://?serialize=true`` as dsn will perform message serialization as real asynchronous transport will do. - Useful to test an additional layer, especially when you use your own message serializer. - -.. versionadded:: 5.3 - - The ``in-memory://?serialize=true`` dsn was introduced in Symfony 5.3. - Amazon SQS ~~~~~~~~~~ From 9db655a618a1421fe879ab215b9396b6324fe882 Mon Sep 17 00:00:00 2001 From: Wojciech Kania Date: Sat, 23 Jan 2021 11:08:47 +0100 Subject: [PATCH 728/752] [Validator] Use constant instead of magic string --- reference/constraints/CardScheme.rst | 2 +- reference/constraints/Isbn.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/reference/constraints/CardScheme.rst b/reference/constraints/CardScheme.rst index d93224e1a5a..1a196970525 100644 --- a/reference/constraints/CardScheme.rst +++ b/reference/constraints/CardScheme.rst @@ -101,7 +101,7 @@ on an object that will contain a credit card number. { $metadata->addPropertyConstraint('cardNumber', new Assert\CardScheme([ 'schemes' => [ - 'VISA', + Assert\CardScheme::VISA, ], 'message' => 'Your credit card number is invalid.', ])); diff --git a/reference/constraints/Isbn.rst b/reference/constraints/Isbn.rst index 2865ceffafe..9bfab789825 100644 --- a/reference/constraints/Isbn.rst +++ b/reference/constraints/Isbn.rst @@ -100,7 +100,7 @@ on an object that will contain an ISBN. public static function loadValidatorMetadata(ClassMetadata $metadata) { $metadata->addPropertyConstraint('isbn', new Assert\Isbn([ - 'type' => 'isbn10', + 'type' => Assert\Isbn::ISBN_10, 'message' => 'This value is not valid.', ])); } From 0b715dee94dab45fca4c414153427c40b5254335 Mon Sep 17 00:00:00 2001 From: wkania <57155526+wkania@users.noreply.github.com> Date: Sun, 24 Jan 2021 19:08:00 +0100 Subject: [PATCH 729/752] [Validator] Use single quotes for string --- reference/constraints/Sequentially.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/constraints/Sequentially.rst b/reference/constraints/Sequentially.rst index 39424a6c523..21e088ba689 100644 --- a/reference/constraints/Sequentially.rst +++ b/reference/constraints/Sequentially.rst @@ -120,7 +120,7 @@ You can validate each of these constraints sequentially to solve these issues: { $metadata->addPropertyConstraint('address', new Assert\Sequentially([ new Assert\NotNull(), - new Assert\Type("string"), + new Assert\Type('string'), new Assert\Length(['min' => 10]), new Assert\Regex(self::ADDRESS_REGEX), new AcmeAssert\Geolocalizable(), From a423947869694a15b914431373643a1b25b62b73 Mon Sep 17 00:00:00 2001 From: wkania <57155526+wkania@users.noreply.github.com> Date: Sun, 24 Jan 2021 19:33:51 +0100 Subject: [PATCH 730/752] [Validator] Change the example to be consistent with the rest Other examples do not use key 'value'. --- reference/constraints/AtLeastOneOf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reference/constraints/AtLeastOneOf.rst b/reference/constraints/AtLeastOneOf.rst index b69894184d6..fb29a86f8d8 100644 --- a/reference/constraints/AtLeastOneOf.rst +++ b/reference/constraints/AtLeastOneOf.rst @@ -141,7 +141,7 @@ The following constraints ensure that: new Assert\Count(['min' => 3]), new Assert\All([ 'constraints' => [ - new Assert\GreaterThanOrEqual(['value' => 5]), + new Assert\GreaterThanOrEqual(5), ], ]), ], From a1c303bfb4dbd0586763ad4f8232673d5b042f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Sat, 23 Jan 2021 21:37:54 +0100 Subject: [PATCH 731/752] Add documentation about breach --- security/csrf.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/security/csrf.rst b/security/csrf.rst index ac8e840c978..7058fb88478 100644 --- a/security/csrf.rst +++ b/security/csrf.rst @@ -85,7 +85,7 @@ this can be customized on a form-by-form basis:: // src/Form/TaskType.php namespace App\Form; - + // ... use App\Entity\Task; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -162,4 +162,19 @@ to check its validity:: } } +CSRF Tokens and Compression Side-Channel Attacks +------------------------------------------------ + +`BREACH`_ and `CRIME`_ are security exploits against HTTPS when using HTTP +compression. Attacker can leverage information leaked by compression to recover +targeted parts of the plaintext. To mitigate these attacks, and prevent an +attacker from guessing the CSRF tokens, a random mask is prepended to the token +and used to scramble it. + +.. versionadded:: 5.3 + + The randomization of tokens was introduced in Symfony 5.3 + .. _`Cross-site request forgery`: https://en.wikipedia.org/wiki/Cross-site_request_forgery +.. _`BREACH`: https://en.wikipedia.org/wiki/BREACH +.. _`CRIME`: https://en.wikipedia.org/wiki/CRIME From 56add0114806c646c7a78b2ee85a52ae86f32eae Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Mon, 25 Jan 2021 17:38:42 +0100 Subject: [PATCH 732/752] [Notifier] Add clickatell Fix #14880. --- notifier.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index a2072e79c13..7231080d47e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -57,6 +57,7 @@ with a couple popular SMS services: Service Package DSN ========== ================================ ==================================================== AllMySms ``symfony/allmysms-notifier`` ``allmysms://LOGIN:APIKEY@default?from=FROM`` +Clickatell ``symfony/clickatell-notifier`` ``clickatell://ACCESS_TOKEN@default?from=FROM`` Esendex ``symfony/esendex-notifier`` ``esendex://USER_NAME:PASSWORD@default?accountreference=ACCOUNT_REFERENCE&from=FROM`` FreeMobile ``symfony/free-mobile-notifier`` ``freemobile://LOGIN:PASSWORD@default?phone=PHONE`` GatewayApi ``symfony/gatewayapi-notifier`` ``gatewayapi://TOKEN@default?from=FROM`` @@ -82,7 +83,8 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.3 - The Iqsms, GatewayApi, Octopush and AllMySms integrations were introduced in Symfony 5.3. + The Iqsms, GatewayApi, Octopush, AllMySms and Clickatell integrations were + introduced in Symfony 5.3. To enable a texter, add the correct DSN in your ``.env`` file and From 0770446f44fc64ce450dc7780f4dd0c02d5011d1 Mon Sep 17 00:00:00 2001 From: Frankie Wittevrongel Date: Tue, 26 Jan 2021 12:44:07 +0000 Subject: [PATCH 733/752] Add bright colors to console. --- console/coloring.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/console/coloring.rst b/console/coloring.rst index 913805b5cea..9412511e11f 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -46,7 +46,9 @@ It is possible to define your own styles using the $output->writeln('foo'); Any hex color is supported for foreground and background colors. Besides that, these named colors are supported: -``black``, ``red``, ``green``, ``yellow``, ``blue``, ``magenta``, ``cyan`` and ``white``. +``black``, ``red``, ``green``, ``yellow``, ``blue``, ``magenta``, ``cyan``, ``white``, +``gray``, ``bright-red``, ``bright-green``, ``bright-yellow``, ``bright-blue``, +``bright-magenta``, ``bright-cyan`` and ``bright-white``. .. versionadded:: 5.2 From ff3b2443c29f6fe91c71bbd38b0aed269d96c5d3 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Tue, 26 Jan 2021 16:52:46 +0100 Subject: [PATCH 734/752] Minor tweak --- security/csrf.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/csrf.rst b/security/csrf.rst index 7058fb88478..47b9396d285 100644 --- a/security/csrf.rst +++ b/security/csrf.rst @@ -166,7 +166,7 @@ CSRF Tokens and Compression Side-Channel Attacks ------------------------------------------------ `BREACH`_ and `CRIME`_ are security exploits against HTTPS when using HTTP -compression. Attacker can leverage information leaked by compression to recover +compression. Attackers can leverage information leaked by compression to recover targeted parts of the plaintext. To mitigate these attacks, and prevent an attacker from guessing the CSRF tokens, a random mask is prepended to the token and used to scramble it. From 55c567603856bc0e353e774645b3a047d84b8177 Mon Sep 17 00:00:00 2001 From: Yoann Renard Date: Thu, 21 Jan 2021 22:15:50 +0100 Subject: [PATCH 735/752] [Validator] Use PHP attributes when creating custom validation constraints --- validation/custom_constraint.rst | 72 +++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 11 deletions(-) diff --git a/validation/custom_constraint.rst b/validation/custom_constraint.rst index c6c588452c4..9cecde12b8a 100644 --- a/validation/custom_constraint.rst +++ b/validation/custom_constraint.rst @@ -12,20 +12,43 @@ alphanumeric characters. Creating the Constraint Class ----------------------------- -First you need to create a Constraint class and extend :class:`Symfony\\Component\\Validator\\Constraint`:: +First you need to create a Constraint class and extend :class:`Symfony\\Component\\Validator\\Constraint`: - // src/Validator/ContainsAlphanumeric.php - namespace App\Validator; +.. configuration-block:: - use Symfony\Component\Validator\Constraint; + .. code-block:: php-annotations - /** - * @Annotation - */ - class ContainsAlphanumeric extends Constraint - { - public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.'; - } + // src/Validator/ContainsAlphanumeric.php + namespace App\Validator; + + use Symfony\Component\Validator\Constraint; + + /** + * @Annotation + */ + class ContainsAlphanumeric extends Constraint + { + public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.'; + } + + .. code-block:: php-attributes + + // src/Validator/ContainsAlphanumeric.php + namespace App\Validator; + + use Symfony\Component\Validator\Constraint; + + #[\Attribute] + class ContainsAlphanumeric extends Constraint + { + public $message = 'The string "{{ string }}" contains an illegal character: it can only contain letters or numbers.'; + } + +.. versionadded:: 5.2 + + The ability to use PHP attributes to configure constraints was introduced in + Symfony 5.2. Prior to this, Doctrine Annotations were the only way to + annotate constraints. .. note:: @@ -128,6 +151,25 @@ You can use custom validators like the ones provided by Symfony itself: // ... } + .. code-block:: php-attributes + + // src/Entity/AcmeEntity.php + namespace App\Entity; + + use App\Validator as AcmeAssert; + use Symfony\Component\Validator\Constraints as Assert; + + class AcmeEntity + { + // ... + + #[Assert\NotBlank] + #[AcmeAssert\ContainsAlphanumeric] + protected $name; + + // ... + } + .. code-block:: yaml # config/validator/validation.yaml @@ -241,6 +283,14 @@ not to the property: // ... } + .. code-block:: php-attributes + + #[AcmeAssert\ProtocolClass] + class AcmeEntity + { + // ... + } + .. code-block:: yaml # config/validator/validation.yaml From f0e6261484a12c68f8b500ac9495ccf602c13b38 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Jan 2021 07:57:37 +0100 Subject: [PATCH 736/752] Remove experimental for UID Fix #14890 --- components/uid.rst | 15 +++++++-------- notifier.rst | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index a7fb95d5d2f..076946c7756 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -10,8 +10,7 @@ The UID Component .. versionadded:: 5.1 - The UID component was introduced in Symfony 5.1 as an - :doc:`experimental feature `. + The UID component was introduced in Symfony 5.1. Installation ------------ @@ -157,12 +156,12 @@ entity primary keys:: private $id; // ... - + public function getId(): ?Uuid { return $this->id; } - + // ... } @@ -287,7 +286,7 @@ There's also a Doctrine generator to help autogenerate ULID values for the entity primary keys:: use Symfony\Bridge\Doctrine\IdGenerator\UlidGenerator; - use Symfony\Component\Uid\Ulid; + use Symfony\Component\Uid\Ulid; /** * @ORM\Entity(repositoryClass="App\Repository\ProductRepository") @@ -303,14 +302,14 @@ entity primary keys:: private $id; // ... - + public function getId(): ?Ulid { return $this->id; } - + // ... - + } .. versionadded:: 5.2 diff --git a/notifier.rst b/notifier.rst index 7231080d47e..6845900b11b 100644 --- a/notifier.rst +++ b/notifier.rst @@ -16,7 +16,7 @@ the users (e.g. SMS, Slack messages, emails, push notifications, etc.). The Notifier component in Symfony is an abstraction on top of all these channels. It provides a dynamic way to manage how the messages are sent. Get the Notifier installed using: - +uid .. code-block:: terminal $ composer require symfony/notifier From 1c6c658627db640955982e8e2aad1265924e97b2 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 28 Jan 2021 08:54:34 +0100 Subject: [PATCH 737/752] Removed unneeded text --- notifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notifier.rst b/notifier.rst index 6845900b11b..7231080d47e 100644 --- a/notifier.rst +++ b/notifier.rst @@ -16,7 +16,7 @@ the users (e.g. SMS, Slack messages, emails, push notifications, etc.). The Notifier component in Symfony is an abstraction on top of all these channels. It provides a dynamic way to manage how the messages are sent. Get the Notifier installed using: -uid + .. code-block:: terminal $ composer require symfony/notifier From 5ff7cc7486530647a46951b6189bee23717f09f7 Mon Sep 17 00:00:00 2001 From: Oskar Stark Date: Thu, 28 Jan 2021 09:06:50 +0100 Subject: [PATCH 738/752] Remove experimental mention in lowest branch Follows #14891 --- components/uid.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index 9a097a3e675..b0ba7259b87 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -10,8 +10,7 @@ The UID Component .. versionadded:: 5.1 - The UID component was introduced in Symfony 5.1 as an - :doc:`experimental feature `. + The UID component was introduced in Symfony 5.1. Installation ------------ From d0c1a24752df5048a3910e67985884da8a41e618 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 28 Jan 2021 09:15:02 +0100 Subject: [PATCH 739/752] [Uid] Document the getDateTime() method --- components/uid.rst | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/components/uid.rst b/components/uid.rst index 076946c7756..adda64b8029 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -96,9 +96,9 @@ UUID objects created with the ``Uuid`` class can use the following methods $uuid = Uuid::v4(); $uuid instanceof UuidV4; // true - // getting the UUID time (it's only available in certain UUID types) + // getting the UUID datetime (it's only available in certain UUID types) $uuid = Uuid::v1(); - $uuid->getTime(); // e.g. float(1584111384.2613) + $uuid->getDateTime(); // returns a \DateTimeImmutable instance // comparing UUIDs and checking for equality $uuid1 = Uuid::v1(); @@ -111,6 +111,11 @@ UUID objects created with the ``Uuid`` class can use the following methods // * int < 0 if $uuid1 is less than $uuid4 $uuid1->compare($uuid4); // e.g. int(4) +.. versionadded:: 5.3 + + The ``getDateTime()`` method was introduced in Symfony 5.3. In previous + versions it was called ``getTime()``. + Storing UUIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -250,14 +255,19 @@ ULID objects created with the ``Ulid`` class can use the following methods:: // checking if a given value is valid as ULID $isValid = Ulid::isValid($ulidValue); // true or false - // getting the ULID time - $ulid1->getTime(); // e.g. float(1584111384.2613) + // getting the ULID datetime + $ulid1->getDateTime(); // returns a \DateTimeImmutable instance // comparing ULIDs and checking for equality $ulid1->equals($ulid2); // false // this method returns $ulid1 <=> $ulid2 $ulid1->compare($ulid2); // e.g. int(-1) +.. versionadded:: 5.3 + + The ``getDateTime()`` method was introduced in Symfony 5.3. In previous + versions it was called ``getTime()``. + Storing ULIDs in Databases ~~~~~~~~~~~~~~~~~~~~~~~~~~ From 1b61792e5e7ce891264f80b6c466efc3a0a7825b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Thu, 28 Jan 2021 09:20:38 +0100 Subject: [PATCH 740/752] [Uid] Mentioned the Uuid::NAMESPACE_* constants --- components/uid.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/components/uid.rst b/components/uid.rst index 076946c7756..51f8b4021a2 100644 --- a/components/uid.rst +++ b/components/uid.rst @@ -53,11 +53,22 @@ to create each type of UUID:: $uuid = Uuid::v3($namespace, $name); // $uuid is an instance of Symfony\Component\Uid\UuidV3 $uuid = Uuid::v5($namespace, $name); // $uuid is an instance of Symfony\Component\Uid\UuidV5 + // the namespaces defined by RFC 4122 are available as constants + // (see https://tools.ietf.org/html/rfc4122#appendix-C) + $uuid = Uuid::v3(Uuid::NAMESPACE_DNS, $name); + $uuid = Uuid::v3(Uuid::NAMESPACE_URL, $name); + $uuid = Uuid::v3(Uuid::NAMESPACE_OID, $name); + $uuid = Uuid::v3(Uuid::NAMESPACE_X500, $name); + // UUID type 6 is not part of the UUID standard. It's lexicographically sortable // (like ULIDs) and contains a 60-bit timestamp and 63 extra unique bits. // It's defined in http://gh.peabody.io/uuidv6/ $uuid = Uuid::v6(); // $uuid is an instance of Symfony\Component\Uid\UuidV6 +.. versionadded:: 5.3 + + The ``Uuid::NAMESPACE_*`` constants were introduced in Symfony 5.3. + If your UUID is generated by another system, use the ``fromString()`` method to create an object and make use of the utilities available for Symfony UUIDs:: From 70fe3795c8bb33fcabe016f5a2a8c91cd158f803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 28 Jan 2021 15:41:22 +0100 Subject: [PATCH 741/752] Mark semaphore exeperimental --- components/semaphore.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/semaphore.rst b/components/semaphore.rst index ebae3df89e8..614c38a6bd9 100644 --- a/components/semaphore.rst +++ b/components/semaphore.rst @@ -10,7 +10,8 @@ The Semaphore Component .. versionadded:: 5.2 - The Semaphore Component was introduced in Symfony 5.2. + The Semaphore Component was introduced in Symfony 5.2 as an + :doc:`experimental feature `. Installation ------------ From be512a89aa9fc34116b51d2ae8c1fce74ec88eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Deruss=C3=A9?= Date: Thu, 28 Jan 2021 19:20:54 +0100 Subject: [PATCH 742/752] Update documentation for deprecated session service --- components/http_foundation.rst | 3 +- controller.rst | 2 +- logging/processors.rst | 23 +++++++------ quick_tour/the_architecture.rst | 3 -- security/access_denied_handler.rst | 7 ++-- security/form_login_setup.rst | 10 +----- service_container.rst | 8 +---- session.rst | 55 +++++++++++++++++++++--------- session/locale_sticky_session.rst | 10 +++--- 9 files changed, 64 insertions(+), 57 deletions(-) diff --git a/components/http_foundation.rst b/components/http_foundation.rst index 23d8e9a6809..e00f9dabb7b 100644 --- a/components/http_foundation.rst +++ b/components/http_foundation.rst @@ -247,7 +247,8 @@ Accessing the Session ~~~~~~~~~~~~~~~~~~~~~ If you have a session attached to the request, you can access it via the -:method:`Symfony\\Component\\HttpFoundation\\Request::getSession` method; +:method:`Symfony\\Component\\HttpFoundation\\Request::getSession` method or the +:method:`Symfony\\Component\\HttpFoundation\\RequestStack::getSession` method; the :method:`Symfony\\Component\\HttpFoundation\\Request::hasPreviousSession` method tells you if the request contains a session which was started in one of diff --git a/controller.rst b/controller.rst index 212d0a2b509..a5017452832 100644 --- a/controller.rst +++ b/controller.rst @@ -394,7 +394,7 @@ Request object. Managing the Session -------------------- -Symfony provides a session service that you can use to store information +Symfony provides a session object that you can use to store information about the user between requests. Session is enabled by default, but will only be started if you read or write from it. diff --git a/logging/processors.rst b/logging/processors.rst index 8ba965327b2..c0a3eb33bbf 100644 --- a/logging/processors.rst +++ b/logging/processors.rst @@ -19,30 +19,33 @@ using a processor:: // src/Logger/SessionRequestProcessor.php namespace App\Logger; - use Symfony\Component\HttpFoundation\Session\SessionInterface; + use Symfony\Component\HttpFoundation\Exception\SessionNotFoundException; + use Symfony\Component\HttpFoundation\RequestStack; class SessionRequestProcessor { - private $session; - private $sessionId; + private $requestStack; - public function __construct(SessionInterface $session) + public function __construct(RequestStack $requestStack) { - $this->session = $session; + $this->requestStack = $requestStack; } // this method is called for each log record; optimize it to not hurt performance public function __invoke(array $record) { - if (!$this->session->isStarted()) { + try { + $session = $requestStack->getSession(); + } catch (SessionNotFoundException $e) { + return; + } + if (!$session->isStarted()) { return $record; } - if (!$this->sessionId) { - $this->sessionId = substr($this->session->getId(), 0, 8) ?: '????????'; - } + $sessionId = substr($session->getId(), 0, 8) ?: '????????'; - $record['extra']['token'] = $this->sessionId.'-'.substr(uniqid('', true), -8); + $record['extra']['token'] = $sessionId.'-'.substr(uniqid('', true), -8); return $record; } diff --git a/quick_tour/the_architecture.rst b/quick_tour/the_architecture.rst index d88bb5d32ed..e3b388a0bc4 100644 --- a/quick_tour/the_architecture.rst +++ b/quick_tour/the_architecture.rst @@ -72,9 +72,6 @@ What other possible classes or interfaces could you use? Find out by running: Request stack that controls the lifecycle of requests. Symfony\Component\HttpFoundation\RequestStack (request_stack) - Interface for the session. - Symfony\Component\HttpFoundation\Session\SessionInterface (session) - RouterInterface is the interface that all Router classes must implement. Symfony\Component\Routing\RouterInterface (router.default) diff --git a/security/access_denied_handler.rst b/security/access_denied_handler.rst index 42ee7fe5dd9..2a7566fafed 100644 --- a/security/access_denied_handler.rst +++ b/security/access_denied_handler.rst @@ -28,7 +28,6 @@ unauthenticated user tries to access a protected resource:: use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; - use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; use Symfony\Component\Security\Core\Exception\AuthenticationException; use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface; @@ -36,18 +35,16 @@ unauthenticated user tries to access a protected resource:: class AuthenticationEntryPoint implements AuthenticationEntryPointInterface { private $urlGenerator; - private $session; - public function __construct(UrlGeneratorInterface $urlGenerator, SessionInterface $session) + public function __construct(UrlGeneratorInterface $urlGenerator) { $this->urlGenerator = $urlGenerator; - $this->session = $session; } public function start(Request $request, AuthenticationException $authException = null): RedirectResponse { // add a custom flash message and redirect to the login page - $this->session->getFlashBag()->add('note', 'You have to login in order to access this page.'); + $request->getSession()->getFlashBag()->add('note', 'You have to login in order to access this page.'); return new RedirectResponse($this->urlGenerator->generate('security_login')); } diff --git a/security/form_login_setup.rst b/security/form_login_setup.rst index c7ea359c459..1d269eba380 100644 --- a/security/form_login_setup.rst +++ b/security/form_login_setup.rst @@ -477,7 +477,6 @@ whenever the user browses a page:: namespace App\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; - use Symfony\Component\HttpFoundation\Session\SessionInterface; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\Security\Http\Util\TargetPathTrait; @@ -486,13 +485,6 @@ whenever the user browses a page:: { use TargetPathTrait; - private $session; - - public function __construct(SessionInterface $session) - { - $this->session = $session; - } - public function onKernelRequest(RequestEvent $event): void { $request = $event->getRequest(); @@ -504,7 +496,7 @@ whenever the user browses a page:: return; } - $this->saveTargetPath($this->session, 'main', $request->getUri()); + $this->saveTargetPath($request->getSession(), 'main', $request->getUri()); } public static function getSubscribedEvents() diff --git a/service_container.rst b/service_container.rst index e3db328033b..98fb5e61318 100644 --- a/service_container.rst +++ b/service_container.rst @@ -62,9 +62,6 @@ What other services are available? Find out by running: Request stack that controls the lifecycle of requests. Symfony\Component\HttpFoundation\RequestStack (request_stack) - Interface for the session. - Symfony\Component\HttpFoundation\Session\SessionInterface (session) - RouterInterface is the interface that all Router classes must implement. Symfony\Component\Routing\RouterInterface (router.default) @@ -80,7 +77,7 @@ in the container. .. tip:: There are actually *many* more services in the container, and each service has - a unique id in the container, like ``session`` or ``router.default``. For a full + a unique id in the container, like ``request_stack`` or ``router.default``. For a full list, you can run ``php bin/console debug:container``. But most of the time, you won't need to worry about this. See :ref:`services-wire-specific-service`. See :doc:`/service_container/debug`. @@ -283,9 +280,6 @@ type-hints by running: Request stack that controls the lifecycle of requests. Symfony\Component\HttpFoundation\RequestStack (request_stack) - Interface for the session. - Symfony\Component\HttpFoundation\Session\SessionInterface (session) - RouterInterface is the interface that all Router classes must implement. Symfony\Component\Routing\RouterInterface (router.default) diff --git a/session.rst b/session.rst index 394cfece78b..3ccf47460b6 100644 --- a/session.rst +++ b/session.rst @@ -127,25 +127,26 @@ Check out the Symfony config reference to learn more about the other available Basic Usage ----------- -Symfony provides a session service that is injected in your services and +The sessions is available througth the Request and the RequestStack. +Symfony provides a request_stack service that is injected in your services and controllers if you type-hint an argument with -:class:`Symfony\\Component\\HttpFoundation\\Session\\SessionInterface`:: +:class:`Symfony\\Component\\HttpFoundation\\RequestStack`:: - use Symfony\Component\HttpFoundation\Session\SessionInterface; + use Symfony\Component\HttpFoundation\RequestStack; class SomeService { - private $session; + private $requestStack; - public function __construct(SessionInterface $session) + public function __construct(RequestStack $requestStack) { - $this->session = $session; + $this->requestStack = $requestStack; } public function someMethod() { // stores an attribute in the session for later reuse - $this->session->set('attribute-name', 'attribute-value'); + $this->requestStack->getSession()->set('attribute-name', 'attribute-value'); // gets an attribute by name $foo = $this->session->get('foo'); @@ -157,10 +158,10 @@ controllers if you type-hint an argument with } } -.. tip:: +.. deprecated:: 5.3 - Every ``SessionInterface`` implementation is supported. If you have your - own implementation, type-hint this in the argument instead. + The ``SessionInterface`` and ``session`` service are deprecated since + Symfony 5.3. Inject a request stack instead. Stored attributes remain in the session for the remainder of that user's session. By default, session attributes are key-value pairs managed with the @@ -175,22 +176,44 @@ class. If your application needs are complex, you may prefer to use :ref:`namespaced session attributes ` which are managed with the :class:`Symfony\\Component\\HttpFoundation\\Session\\Attribute\\NamespacedAttributeBag` -class. Before using them, override the ``session`` service definition to replace -the default ``AttributeBag`` by the ``NamespacedAttributeBag``: +class. Before using them, override the ``session_listener`` service definition to build +your ``Session`` object with the default ``AttributeBag`` by the ``NamespacedAttributeBag``: .. configuration-block:: .. code-block:: yaml # config/services.yaml - session: - public: true - class: Symfony\Component\HttpFoundation\Session\Session - arguments: ['@session.storage', '@session.namespacedattributebag'] + session_listener: + autoconfigure: true + class: App\EventListener\SessionListener + arguments: + - !service_locator + logger: '@?logger' + session_collector: '@?data_collector.request.session_collector' + session_storage: '@session.storage' + session_attributes: '@session.namespacedattributebag' + - '%kernel.debug%' session.namespacedattributebag: class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag +.. code-block:: php + + namespace App\EventListener; + + use Symfony\Component\HttpFoundation\Session\Session; + use Symfony\Component\HttpFoundation\Session\SessionInterface; + use Symfony\Component\HttpKernel\EventListener\AbstractSessionListener; + + class SessionListener extends AbstractSessionListener + { + protected function getSession(): ?SessionInterface + { + return new Session($this->container->get('session_storage'), $this->container->get('session_attributes')); + } + } + .. _session-avoid-start: Avoid Starting Sessions for Anonymous Users diff --git a/session/locale_sticky_session.rst b/session/locale_sticky_session.rst index 056f2a674cb..13d620381aa 100644 --- a/session/locale_sticky_session.rst +++ b/session/locale_sticky_session.rst @@ -146,7 +146,7 @@ event:: namespace App\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; - use Symfony\Component\HttpFoundation\Session\SessionInterface; + use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\Security\Http\Event\InteractiveLoginEvent; use Symfony\Component\Security\Http\SecurityEvents; @@ -156,11 +156,11 @@ event:: */ class UserLocaleSubscriber implements EventSubscriberInterface { - private $session; + private $requestStack; - public function __construct(SessionInterface $session) + public function __construct(RequestStack $requestStack) { - $this->session = $session; + $this->requestStack = $requestStack; } public function onInteractiveLogin(InteractiveLoginEvent $event) @@ -168,7 +168,7 @@ event:: $user = $event->getAuthenticationToken()->getUser(); if (null !== $user->getLocale()) { - $this->session->set('_locale', $user->getLocale()); + $this->requestStack->getSession()->set('_locale', $user->getLocale()); } } From 98ebace2ecae3d409ce8e229b066fd9da21f5cd9 Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Jan 2021 10:04:23 +0100 Subject: [PATCH 743/752] Tweak --- session.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/session.rst b/session.rst index 3ccf47460b6..da265d739b9 100644 --- a/session.rst +++ b/session.rst @@ -160,8 +160,9 @@ controllers if you type-hint an argument with .. deprecated:: 5.3 - The ``SessionInterface`` and ``session`` service are deprecated since - Symfony 5.3. Inject a request stack instead. + The ``SessionInterface`` and ``session`` service were deprecated in + Symfony 5.3. Instead, inject the ``RequestStack`` service to get the session + object of the current request. Stored attributes remain in the session for the remainder of that user's session. By default, session attributes are key-value pairs managed with the From 8673801703a7ca8625357234a43e645bb9c49d6b Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Jan 2021 10:16:07 +0100 Subject: [PATCH 744/752] Added the versionadded directive --- console/coloring.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/console/coloring.rst b/console/coloring.rst index 9412511e11f..7e77a090b25 100644 --- a/console/coloring.rst +++ b/console/coloring.rst @@ -54,6 +54,10 @@ Any hex color is supported for foreground and background colors. Besides that, t True (hex) color support was introduced in Symfony 5.2 +.. versionadded:: 5.3 + + Support for bright colors was introduced in Symfony 5.3. + .. note:: If the terminal doesn't support true colors, the nearest named color is used. From 9d03c8f616eb9b9b473a51c7e8c0647e616a440f Mon Sep 17 00:00:00 2001 From: Javier Eguiluz Date: Fri, 29 Jan 2021 10:19:15 +0100 Subject: [PATCH 745/752] [Semaphore] The component is no longer experimental in Symfony 5.3. --- components/semaphore.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/components/semaphore.rst b/components/semaphore.rst index 614c38a6bd9..ebae3df89e8 100644 --- a/components/semaphore.rst +++ b/components/semaphore.rst @@ -10,8 +10,7 @@ The Semaphore Component .. versionadded:: 5.2 - The Semaphore Component was introduced in Symfony 5.2 as an - :doc:`experimental feature `. + The Semaphore Component was introduced in Symfony 5.2. Installation ------------ From 36a5c1a2820bdcd9bd3aa65bb2774d99228c0495 Mon Sep 17 00:00:00 2001 From: Jon Green Date: Sun, 3 Jan 2021 17:22:23 +0000 Subject: [PATCH 746/752] [String] Feature 39178 Documentation update for [String] Feature 39178 "AsciiSlugger's symbolsMap should apply to all locales for a language". --- components/string.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/string.rst b/components/string.rst index 97988fc0970..48f17f0b3e9 100644 --- a/components/string.rst +++ b/components/string.rst @@ -477,6 +477,12 @@ that only includes safe ASCII characters:: $slug = $slugger->slug('10% or 5€'); // $slug = '10-percent-or-5-euro' + // if there is no symbols map for your locale (e.g. 'en_GB') then the parent locale's symbols map + // will be used instead (i.e. 'en') + $slugger = new AsciiSlugger('en_GB', ['en' => ['%' => 'percent', '€' => 'euro']]); + $slug = $slugger->slug('10% or 5€'); + // $slug = '10-percent-or-5-euro' + // for more dynamic substitutions, pass a PHP closure instead of an array $slugger = new AsciiSlugger('en', function ($string, $locale) { return str_replace('❤️', 'love', $string); @@ -490,6 +496,10 @@ that only includes safe ASCII characters:: The feature to use a PHP closure to define substitutions was introduced in Symfony 5.2. +.. versionadded:: 5.3 + + The feature to fallback to the parent locale's symbols map was introduced in Symfony 5.3. + The separator between words is a dash (``-``) by default, but you can define another separator as the second argument:: From 1cdb6cb9079f5c0e2b709ab90294b08218b50831 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 17 Oct 2020 15:19:01 +0200 Subject: [PATCH 747/752] Added limiter diagrams --- _images/rate_limiter/fixed_window.svg | 84 ++++++++++++++++++ _images/rate_limiter/sliding_window.svg | 65 ++++++++++++++ _images/rate_limiter/token_bucket.svg | 83 +++++++++++++++++ _images/sources/rate_limiter/fixed_window.dia | Bin 0 -> 2356 bytes .../sources/rate_limiter/sliding_window.dia | Bin 0 -> 2190 bytes _images/sources/rate_limiter/token_bucket.dia | Bin 0 -> 2752 bytes rate_limiter.rst | 52 +++++++++-- 7 files changed, 275 insertions(+), 9 deletions(-) create mode 100644 _images/rate_limiter/fixed_window.svg create mode 100644 _images/rate_limiter/sliding_window.svg create mode 100644 _images/rate_limiter/token_bucket.svg create mode 100644 _images/sources/rate_limiter/fixed_window.dia create mode 100644 _images/sources/rate_limiter/sliding_window.dia create mode 100644 _images/sources/rate_limiter/token_bucket.dia diff --git a/_images/rate_limiter/fixed_window.svg b/_images/rate_limiter/fixed_window.svg new file mode 100644 index 00000000000..83d5f6e79ac --- /dev/null +++ b/_images/rate_limiter/fixed_window.svg @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + 10:00 + + + 10:30 + + + 11:00 + + + 11:30 + + + 12:00 + + + + + + + + 12:30 + + + 13:00 + + + + + + + + + + + + + + + + + + + + + + 1 hour window + + + 1 hour window + + + + + + 1 hour window + + + + + 13:15 + + + diff --git a/_images/rate_limiter/sliding_window.svg b/_images/rate_limiter/sliding_window.svg new file mode 100644 index 00000000000..2c565615441 --- /dev/null +++ b/_images/rate_limiter/sliding_window.svg @@ -0,0 +1,65 @@ + + + + + + + + + + 10:00 + + + 10:30 + + + 11:00 + + + 11:30 + + + 12:00 + + + + + + 12:30 + + + 13:00 + + + + + + + + + + + + + + + + + + + + + + 1 hour window + + + + + + 13:15 + + + + + + diff --git a/_images/rate_limiter/token_bucket.svg b/_images/rate_limiter/token_bucket.svg new file mode 100644 index 00000000000..29d6fc8f103 --- /dev/null +++ b/_images/rate_limiter/token_bucket.svg @@ -0,0 +1,83 @@ + + + + 10:00 + + + 10:30 + + + 11:00 + + + 11:30 + + + 12:00 + + + + + + + + 12:30 + + + 13:00 + + + + + + + + + + + + + + + + + + + + + + + + + + + 13:15 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/_images/sources/rate_limiter/fixed_window.dia b/_images/sources/rate_limiter/fixed_window.dia new file mode 100644 index 0000000000000000000000000000000000000000..16282a2dcce2dc3cf58a40be13992366c2a10f48 GIT binary patch literal 2356 zcmV-43Cs2$iwFP!000021MQt#liD~I$KUfQT;#ReSQp>Y=}ygT)$BfO?WQW3=PrTO z;2C2xwrRpV>}OxuTpElG23hKuI#eYAB6KYI==VRCb>z=qe#|1{m8V&l#E%1HS_6Z} z<0J^<$>ZSn@4wx9gD+1XJ_jNDB>qfNHZ#O8;;i`eIGE=7{L^r_TrSOMm9acY%_v-$ z86Wic8q{$)<2J2Fra^oaQ zQsb3HkAsgdo7Z5tsc3jm(}~*WY{Ew=XMZ+VZi$!gUsw5@r`3vQ^CSyJk$g2jD$-C- z@%LVtO{q*2iYHGWf1w}OhqU?Pt**KQZ8Vb4SUL&gV>_aEqIFkb)592x?y!B&w_NI? zZJ%6jZlu>-q}N=k*IbxA&yzGyS(qQ293@G_S-iIT!lH~{ZzvnHNch;Pc1bkjCCu}r zqXw+M-VL`)hwdZ|gVQ7TphQD0!Akraj@6!%Wfi5qx!R{ZoJ{i*)n8ZlC`kjJo;!BSMArI+sBadA zb(xU@0M9j-f9J>jC00Z{%b&A+74fP89xrC=+Ua#w&sh*0M$1R%<4RY``Hy^XCN8Oz zY3k(iqVb?y<@&PW>hc86o5K4f&g%>n-y1I?P>xpOcvzebjPiVxtXu!|Up#u{c{pbK zY`^>njs{=tIq|H+7nL)5NZ~qcQEU>|zN03k)NB_=J6JP38uAfa+iYNencpCF$gpCF$d$tQ74 z5KrymiDktTJF2A<+or#fPHbArrBkXwAe0=WGHr)uDTxmABI@shKu*vHen=r&p8rkFmn|i^ffAVC;#jnN!PG5QY zQvA=izZNXzHJI|`?y~zDtYFUKr*J|+xiq(JEv`ZN}WH#`jlR-okP+IQIu$a6U7H` zqWyvsfyHwg;Y0vVx3_o>$tOp78s<*D-Q1~v3v;I)%$>reGh8~urL*cw=YNZHR=0bl zblMp%(|jCL^-dzf1hpTiYm&m)mDY-#w4Zq#9Bl*MqE$74kSo=6F;>R&>M_(kOyK>& z*^#rk-RxWAsNL=j-xXWFJ&1S31(BuP)v9f3D&m5hwR5vB@<7~TU}MFJAZ}r!*cr(a zZ#>n0R@12FQZ7KPrMLOrYn_7oc{5n>iia9o7IfZwoa~57fL?Q1bw4mwB7p&4NyqP%A8~p(fsGf!a}< znu-9_TDqC^jRJ}^K&>!RLQTBU0kyhDHJ1XYwe>c?n}wiCp+n{oh>tB001yD}0?^T37)1F_7-jVD+(7g%)nNdCi2eco0RL{_PrAwGB+7F+ zOZfY@0DlkQ5AcV`AK?Ekn;;SS2QT|~*44N3+NL}a&mnjBmWe%zy>jWcgNS=4Xw#Fe zMvSQ#_r@}egJcO?j_7&@bJaCrzmZ;UhD797D>|mF8dHRrUIkOWi4gGsQ-GQ$^@4JXM6iQ$^r%8s<{ra{4EjOLe_7^0`{;|}Zrn`uBa`fdM<%&_dt?%_A>h&#a5?bEq@OP0T7Qn% ail)*r;5Ny=tVAN~(zH@RP^pI)w3?7e? zAdJTky+6NwzN5X5k2fEJki8dw#wnW`;u~>Re0u0j@_hEb-(M^iX0*&$o}^|J&drSX z|7B6c`l3+3_jqF%yA=d1XT`PkRhH*zIGpF)h}o1s^oDHoeViuqIOwfPt;>y)C`pZH z7CrRdJ*{88{<@<6UQMsmK4W7(OgZ~rU%4e-zJFQeGoBt+Je?(3D2n9E*-??2dWyey z%B)LeqEI}3eD@Q1x4NbEg_pXjZnRcNK4s}RjF07r-icOSVVl&pZP6W$PkqZH9@_Lt zb8$nx;v&7`QoZ8BY%ojGJY`{iEOMA65ohsA>Jy7Hez~A*#3G?%ueD2}8BbxJCoMH# zb$L77nhxD@8V0YA+`SStwFFD?Z#Yu>Ocr5~PX<3;dnT4?JF)_n>I6K8SvZV%RU5)M zmsYDy^~-juKU9R$R=j*&Qt?)`)f%IKa)&#Y7^Cq#40v`zr}xX$)HGQa>!0fP!*Y^c z6NK3;V$0W?a9F6OE*9sZKpD$;pqQ93o89Hf-2pDDB<1P61wqO1FFwlEikc(~4Gk)! zjFLDO%@N+{-7FEKHPdV!R+kPu)l#fbGM=t)_0x-wYOHCqZoRQ?0Nc65M0=h$pLX

^@POa0-qFbJ>flzQUI2+@d{l z*Y#GNfZ_14{ZA_gj zQT2p}<4N9n-NPgeczWu_EfZO*7b3oekc;fg#Dzkm)4{%>s+yDq!P9W~Vyc=6DMtUG zV(xdEGfkujXO<7Ld>QdW0X&{hSGAMNs-CeR*msqWp2vk+n)4rd?}SrwP^PYv%NgTd zxr51N&D8Q0me=|ANt{;+Dy|z(!b^^p;(l11^^Ed)l$=|A^;aG}^E@1}U9LC3gQLM$ z`An#_{~~fi_X%8yEG&>kOhSm|%E>w$k+rKCmbE)7FA*hNr*S;x)sOUL=%6#DR9fRY z*RcO$E9;EsS7CwzmIlIhek%sT&WhIBcp_QjX*0pc4|9^BK>%C>^<;RzA##ez5<9C*($>NwKKPU4v_KR0o^9JvRAWV-p58X=4)wHeCsuu=Jt>(!eHc?Xn5m z-C`30zeyjPs`L@q)JZlGX*LlZY{GkNa=OMQ@SF6pi2$3fgiVe#n>-zCa`)IoyTv9O z{3eZT@_3c0 zMxJ-;m>2Gxik@Mo_!NYrT;-m%WS5<@XKk6j>v@6;*dY{C4^gUc7aN%eduYDI=B%zw z?NV65ocXJp+Q%enBIGHIqBDdH?SSwr*g3b3Lc}V=L>u*B6wU^dBn|%&c9=!4Htrx6 zsIeG9$70u6nUHKgEaGW-@8V8so&R17F-4wg{tFrIn*Ye8o#($~mtDkvLUi(<0RMsi z!2b^LpGx!JQSbi?85{rKy#oJVvde(~z<=OB@c;6)XsK?Pr`VDVyC+%95*6 z)r5pw$Ml_h@vg9kmU2})Y*Sqk57g{DHIt6;w%uYs!&RJpB7_t&iljIy-cZ$gR?(>X zQXW9

    3WvpyqF&=Ieo)e-_kyfLb$cbK6Oh zQVF#}!U}5QoffDawW+QMKVO*EK#l5w8a)eY6rk2j+w6AYc~nBJkg$T9c&7zwM{TMr0#G|s&7?O9 z2+{zxLP!ZU@kR&Ksv1>a3ZQnbwvl$?fRsWFZ=r@YK@FdV8V0CclnP-x?c_pZ<(bg7 z>2EWkiHW+N35_8S0`edr4+8Qa-Y^f&cH2pW#>&&6OZczTpgRqJsSdjc{s^grKd>HH z53KJ3>%Df8p0VO1wg?uOVN1nQyBadwF8jd`5;mA`k05Agp1Mo&i9%1>w&*Eo0 zt&0OV&RyZB)Wx@VmT6OBQ>SqM5yDjX&Q?dx7BMDbw`{s4b~|C_^KJ~71Cu;J!!Hr$AH4I6GgY`B2|00RI9K-vJTK1XcH)5n|D2k~c| QvgzZ^e}s1x_UWns01%r;Gynhq literal 0 HcmV?d00001 diff --git a/_images/sources/rate_limiter/token_bucket.dia b/_images/sources/rate_limiter/token_bucket.dia new file mode 100644 index 0000000000000000000000000000000000000000..16761971337dbf6890ce0d2255b6d7c75bb125ca GIT binary patch literal 2752 zcmY+Gc{r47AIE1A<20DYiENpWNjb%sv4pHKI@XjD(#RxCwqjl;jAR|tv6RWKWF0Y4 zwhWF$gpoaa_MFCGQ1%y{^Iqq@|9P(K{@u_0``(}L_qne}ngRjr4G@@}=5TlX!{Knw z%oWR4_7S?yGNyFZCca=&{t2PSw8#PETv!+z30qYc-5BiBhwwn4%Y0aWZA_`^;JksF zF(<1laDA5M7;HW<;{LQP3++Ff5Yod5Yd#@m+&uYgr&v0e$z88K7qpI-JmC0#)I`LT zG_Dr!zu0B4bDZVk$l;8RjPNdQXnp7+z>Fz>YE|#ZMox@fM^|xlg63A{q+&v~PF%NR zick8B2#EUk|Ng-BM~5_T)+o}p3fs6<(o-;eg4$L1UA#ePi^ZZBZ*LW3ZM;l>w0!QM z{1>Hzp`$`XkEk=FwS`>Ur))p1v}`UG-8||-G80_3-n4Tsb;F2K&-9(pOl z7a&$k*)fu3W;ENO+a1$`j&7J10^i^Ts{c}15O2%ENvcwhUGQ-&FQ^K>(zR72t7!Xb z&DW&q6iE}3^-6T$Ss;ImJmt1zyUxN_wklshfGy_j&g~K6pow{#dNON#Z0iTiPeN+; z6m|)VwN(;oNDb`kJZa?v>>*p> zzvy_Wipq22Z4vVxopPQfHq|2}k?;JA8wNY&(oBvXinAsAp=9~xXvz#HY$8&r@Z02> zuQHVS!uc;VwFxw(K*I-_zN zfHKL!aht^DDX#CB@0AY|I$v;$9`#Mx4KUBCdWHpheR^^xQU6{g>X0jb33?*oZMJF9 z;NvL0q!@(+KKxub%E}h+WLS$*rWcvUl>MFrnNMm}unyJKPr8U>DHbtWfQ9ZQ}?W-EXztVVwU#%Y(f8zW(o#e1M$?~fJ=CB6gw2RsbGj-A4%?z2O*FuguDn0w zkBk+I)fJj6)$xJr07?L81(3I*lX5r_h8l*#j8db4&SP&ffF-58yky`Fz>&;{z;ra2 z0QM#;l{^Bco^JTRQjIt-Oc;vrpEvIFBPXFJC$_x z+=}YQ+#qD4g|=db%)Q1X1$`IxGw$en7aQv!`o*BHD!1?X&o+HZ)kVhqs#@bstZPsk z!IwqXD_Y=CBd1Q?ZOIg$53{d)Mxo%*gMp%EQ~5>3snOL`dcNZX;mJ{J&YjiH!CAFM zvqK`v!y~;)c?K_sC=uH`Gj~o3MpnG%%UZi1dCJu5ZQkR_C{|yI@7uxcJVA`l7q{HX zId{QwtKO#nM3~uq7sGyWBj3D3583D|S&7NxnpI)cEA@?S z5D6WVe)WfJEl=5Be1umHrZ7cR2V)tZb0H}LIL&uGdC3FXRbg!}AGTp+3G*iP)B64G zT-BT#GgoUF{<}J${3*ofJ#{MfRC@DLw;~}dE}IeMX$rCH$`pL_fRQ$Tr!$2wbyl>j z-bjHkt|?pJt5je>MG%lx$yxHom&zHhF7!VY!`(#kON25Ul2?r#Fg*!Rryc0{6*>8B z+bb61;NJB)6BsE@}K(%nsYq0`XFo+C5cpZdgx~=luGX{Os4ne`MviV(vq8!LrQ-nmt@=*>(l}{x%?n(~xu3StE-+QYwe}g+@EK)!Vb*SnJc=43=C%Y9 zTPJHYkyACA9|Cpg;%axh|C2K9HneJk@hHF3QxQdV8_Fs0*34@hu5=q}y=+p` z+&c;Yk{3cQ<^@&B0&Cjew@E(B>2{NF(TbKMak_W2|&y+*;6r0ae>hR|@|-wgnALm&bbjU!7!w1LD@d(0($}!A89X^HFx4;7k>O_Vo-F$wDR;n=Ym*4I)l#2VO zl>Pu|W6g%ajIfuB;}S_Ab~yRpFqWfm$6D59fjDP}*EHW_@Yu9}d_4|h{Dy&bR3k0* zZ&V^J^)iP^pxxVQFGB!CCNIcP?+_9EQSW}Kq%(0>?M)5HJ}o;k;4&CE90zcu#TV@Z z&U%dA&%;k14Tf^Mb8!H+t{nO9PaO6Vpe5FFsTlz}m_o(n3QN3GRSgIJ4+bKWr14>d z0M$(EKT`He8M-H+?l;{!D=^SW298+4lKl|yIv?22%!QNb)6Y(7h?ac-0LZTFUF>2QFQ=|r-nO`hk=6rWS sZe+aRi%1#x{%58u2%2JfFC4w~M@EZu!`^?Rw9b|g99k(euLlJD7hTW&ssI20 literal 0 HcmV?d00001 diff --git a/rate_limiter.rst b/rate_limiter.rst index 63e073a1e92..1d54faba331 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -28,22 +28,44 @@ Fixed Window Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~ This is the simplest technique and it's based on setting a limit for a given -interval of time. For example: 5,000 requests per hour or 3 login attempts -every 15 minutes. +interval of time (e.g. 5,000 requests per hour or 3 login attempts every 15 +minutes). + +In the diagram below, the limit is set to "5 tokens per hour". Each window +starts at the first hit (i.e. 10:15, 11:30 and 12:30). As soon as there are +5 hits (the blue squares) in a window, all others will be rejected (red +squares). + +.. raw:: html + + Its main drawback is that resource usage is not evenly distributed in time and -it can overload the server at the window edges. In the previous example, a user -could make the 4,999 requests in the last minute of some hour and another 5,000 -requests during the first minute of the next hour, making 9,999 requests in -total in two minutes and possibly overloading the server. These periods of -excessive usage are called "bursts". +it can overload the server at the window edges. In the previous example, +there are 6 accepted requests between 11:00 and 12:00. + +This is more significant with bigger limits. For instance, with 5,000 requests +per hour, a user could make the 4,999 requests in the last minute of some +hour and another 5,000 requests during the first minute of the next hour, +making 9,999 requests in total in two minutes and possibly overloading the +server. These periods of excessive usage are called "bursts". Sliding Window Rate Limiter ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The sliding window algorithm is an alternative to the fixed window algorithm -designed to reduce bursts. To do that, the rate limit is calculated based on -the current window and the previous window. +designed to reduce bursts. This is the same example as above, but then +using a 1 hour window that slides over the timeline: + +.. raw:: html + + + +As you can see, this removes the edges of the window and would prevent the +6th request at 11:45. + +To achieve this, the rate limit is approximated based on the current window and +the previous window. For example: the limit is 5,000 requests per hour; a user made 4,000 requests the previous hour and 500 requests this hour. 15 minutes in to the current hour @@ -66,6 +88,18 @@ continuously updating budget of resource usage. It roughly works like this: * If the bucket still contains tokens, the event is allowed; otherwise, it's denied; * If the bucket is at full capacity, new tokens are discarded. +The below diagram shows a token bucket of size 4 that is filled with a rate +of 1 token per 15 minutes: + +.. raw:: html + + + +This algorithm handles more complex back-off algorithm to manage bursts. +For instance, it can allow a user to try a password 5 times and then only +allow 1 every 15 minutes (unless the user waits 75 minutes and they will be +allowed 5 tries again). + Installation ------------ From dab721b1c22f3d6dbdc0bcdaed9252fa8fcfa450 Mon Sep 17 00:00:00 2001 From: Sebastian Paczkowski <74934099+sebpacz@users.noreply.github.com> Date: Fri, 29 Jan 2021 19:33:12 +0100 Subject: [PATCH 748/752] [Console] Update comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The info() method was introduced in Symfony 5.2. I updated comments that were probably copied from the success() method example. --- console/style.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/style.rst b/console/style.rst index a8cdad20004..66db35011b1 100644 --- a/console/style.rst +++ b/console/style.rst @@ -331,12 +331,12 @@ Result Methods It's meant to be used once to display the final result of executing the given command, without showing the result as a successful or failed one:: - // use simple strings for short success messages + // use simple strings for short info messages $io->info('Lorem ipsum dolor sit amet'); // ... - // consider using arrays when displaying long success messages + // consider using arrays when displaying long info messages $io->info([ 'Lorem ipsum dolor sit amet', 'Consectetur adipiscing elit', From 5c64519c3e3e75abfa37fed52626f6a6d2c492e9 Mon Sep 17 00:00:00 2001 From: Wouter de Jong Date: Sat, 30 Jan 2021 15:56:52 +0100 Subject: [PATCH 749/752] Fixed image path --- rate_limiter.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rate_limiter.rst b/rate_limiter.rst index 1d54faba331..4b6fc27d4ab 100644 --- a/rate_limiter.rst +++ b/rate_limiter.rst @@ -38,7 +38,7 @@ squares). .. raw:: html - + Its main drawback is that resource usage is not evenly distributed in time and it can overload the server at the window edges. In the previous example, @@ -59,7 +59,7 @@ using a 1 hour window that slides over the timeline: .. raw:: html - + As you can see, this removes the edges of the window and would prevent the 6th request at 11:45. @@ -93,7 +93,7 @@ of 1 token per 15 minutes: .. raw:: html - + This algorithm handles more complex back-off algorithm to manage bursts. For instance, it can allow a user to try a password 5 times and then only From 1bb5c085463299c25a10c1007e4d5a5bc443b7d6 Mon Sep 17 00:00:00 2001 From: Dale Nash Date: Tue, 2 Feb 2021 10:30:23 +0000 Subject: [PATCH 750/752] Update conventions page to show correct function --- contributing/code/conventions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contributing/code/conventions.rst b/contributing/code/conventions.rst index d2325f5fc8b..18ea420b841 100644 --- a/contributing/code/conventions.rst +++ b/contributing/code/conventions.rst @@ -167,7 +167,7 @@ A deprecation must also be triggered to help people with the migration trigger_deprecation('symfony/package-name', '5.1', 'The "%s" class is deprecated, use "%s" instead.', Deprecated::class, Replacement::class); -When deprecating a whole class the ``trigger_error()`` call should be placed +When deprecating a whole class the ``trigger_deprecation()`` call should be placed after the use declarations, like in this example from `ServiceRouterLoader`_:: namespace Symfony\Component\Routing\Loader\DependencyInjection; From edb9b438bf2ae9ed91ddffff914d1be5d11706b3 Mon Sep 17 00:00:00 2001 From: James Hemery Date: Sat, 23 Jan 2021 01:47:38 +0100 Subject: [PATCH 751/752] [Notifier] Add SpotHit bridge --- notifier.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/notifier.rst b/notifier.rst index 7231080d47e..0e55317c31f 100644 --- a/notifier.rst +++ b/notifier.rst @@ -70,6 +70,7 @@ OvhCloud ``symfony/ovh-cloud-notifier`` ``ovhcloud://APPLICATION_KEY:APPLI Sendinblue ``symfony/sendinblue-notifier`` ``sendinblue://API_KEY@default?sender=PHONE`` Sinch ``symfony/sinch-notifier`` ``sinch://ACCOUNT_ID:AUTH_TOKEN@default?from=FROM`` Smsapi ``symfony/smsapi-notifier`` ``smsapi://TOKEN@default?from=FROM`` +SpotHit ``symfony/spothit-notifier`` ``spothit://TOKEN@default?from=FROM`` Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from=FROM`` ========== ================================ ==================================================== @@ -83,8 +84,8 @@ Twilio ``symfony/twilio-notifier`` ``twilio://SID:TOKEN@default?from= .. versionadded:: 5.3 - The Iqsms, GatewayApi, Octopush, AllMySms and Clickatell integrations were - introduced in Symfony 5.3. + The Iqsms, GatewayApi, Octopush, AllMySms, Clickatell and SpotHit integrations + were introduced in Symfony 5.3. To enable a texter, add the correct DSN in your ``.env`` file and From bb629f71bce7e28c649ad9f4762e79178c75a3ac Mon Sep 17 00:00:00 2001 From: wickedOne Date: Thu, 4 Feb 2021 09:18:34 +0100 Subject: [PATCH 752/752] role_names instead of roles corrected wrong attribute name relates to symfony/symfony#40087 --- security/expressions.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/expressions.rst b/security/expressions.rst index fefee9bac17..cd8a0f36941 100644 --- a/security/expressions.rst +++ b/security/expressions.rst @@ -38,7 +38,7 @@ 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`` +``role_names`` 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).