Skip to content

Commit

Permalink
Merge branch '7.2' into 7.3
Browse files Browse the repository at this point in the history
* 7.2:
  Fix minor syntax issues
  Rename variable to stay consistent
  Update http_client.rst
  [Routing] Add example of Requirement enum
  • Loading branch information
javiereguiluz committed Dec 2, 2024
2 parents 01203e9 + a61f328 commit fb28238
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 54 deletions.
2 changes: 1 addition & 1 deletion configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ a new ``locale`` parameter is added to the ``config/services.yaml`` file).

By convention, parameters whose names start with a dot ``.`` (for example,
``.mailer.transport``), are available only during the container compilation.
They are useful when working with :ref:`Compiler Passes </service_container/compiler_passes>`
They are useful when working with :doc:`Compiler Passes </service_container/compiler_passes>`
to declare some temporary parameters that won't be available later in the application.

Configuration parameters are usually validation-free, but you can ensure that
Expand Down
4 changes: 2 additions & 2 deletions http_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2355,11 +2355,11 @@ First, use a browser or HTTP client to perform the HTTP request(s) you want to
test. Then, save that information as a ``.har`` file somewhere in your application::

// ExternalArticleServiceTest.php
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Symfony\Component\HttpClient\MockHttpClient;
use Symfony\Component\HttpClient\Response\MockResponse;

final class ExternalArticleServiceTest extends TestCase
final class ExternalArticleServiceTest extends KernelTestCase
{
public function testSubmitData(): void
{
Expand Down
2 changes: 1 addition & 1 deletion messenger.rst
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ Rate Limited Transport
~~~~~~~~~~~~~~~~~~~~~~

Sometimes you might need to rate limit your message worker. You can configure a
rate limiter on a transport (requires the :doc:`RateLimiter component </rate-limiter>`)
rate limiter on a transport (requires the :doc:`RateLimiter component </rate_limiter>`)
by setting its ``rate_limiter`` option:

.. configuration-block::
Expand Down
2 changes: 1 addition & 1 deletion reference/attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Dependency Injection
* :ref:`Autowire <autowire-attribute>`
* :ref:`AutowireCallable <autowiring_closures>`
* :doc:`AutowireDecorated </service_container/service_decoration>`
* :doc:`AutowireIterator <service-locator_autowire-iterator>`
* :ref:`AutowireIterator <service-locator_autowire-iterator>`
* :ref:`AutowireLocator <service-locator_autowire-locator>`
* :ref:`AutowireMethodOf <autowiring_closures>`
* :ref:`AutowireServiceClosure <autowiring_closures>`
Expand Down
2 changes: 0 additions & 2 deletions reference/configuration/framework.rst
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,6 @@ named ``kernel.http_method_override``.
$request = Request::createFromGlobals();
// ...

.. _configuration-framework-http_method_override:

trust_x_sendfile_type_header
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
6 changes: 4 additions & 2 deletions reference/constraints/Callback.rst
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,16 @@ callback method:
* A closure.

Concrete callbacks receive an :class:`Symfony\\Component\\Validator\\Context\\ExecutionContextInterface`
instance as the first argument and the :ref:`payload option <reference-constraints-payload>`
instance as the first argument and the :ref:`payload option <reference-constraints-callback-payload>`
as the second argument.

Static or closure callbacks receive the validated object as the first argument,
the :class:`Symfony\\Component\\Validator\\Context\\ExecutionContextInterface`
instance as the second argument and the :ref:`payload option <reference-constraints-payload>`
instance as the second argument and the :ref:`payload option <reference-constraints-callback-payload>`
as the third argument.

.. include:: /reference/constraints/_groups-option.rst.inc

.. _reference-constraints-callback-payload:

.. include:: /reference/constraints/_payload-option.rst.inc
2 changes: 0 additions & 2 deletions reference/constraints/_payload-option.rst.inc
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
.. _reference-constraints-payload:

``payload``
~~~~~~~~~~~

Expand Down
2 changes: 1 addition & 1 deletion reference/dic_tags.rst
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ controller.argument_value_resolver
Value resolvers implement the
:class:`Symfony\\Component\\HttpKernel\\Controller\\ValueResolverInterface`
and are used to resolve argument values for controllers as described here:
:doc:`/controller/argument_value_resolver`.
:doc:`/controller/value_resolver`.

data_collector
--------------
Expand Down
55 changes: 50 additions & 5 deletions routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,51 @@ URL Route Parameters
contains a collection of commonly used regular-expression constants such as
digits, dates and UUIDs which can be used as route parameter requirements.

.. configuration-block::

.. code-block:: php-attributes
// src/Controller/BlogController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Routing\Requirement\Requirement;
class BlogController extends AbstractController
{
#[Route('/blog/{page}', name: 'blog_list', requirements: ['page' => Requirement::DIGITS])]
public function list(int $page): Response
{
// ...
}
}
.. code-block:: yaml
# config/routes.yaml
blog_list:
path: /blog/{page}
controller: App\Controller\BlogController::list
requirements:
page: !php/const Symfony\Component\Routing\Requirement\Requirement::DIGITS
.. code-block:: php
// config/routes.php
use App\Controller\BlogController;
use Symfony\Component\Routing\Loader\Configurator\RoutingConfigurator;
use Symfony\Component\Routing\Requirement\Requirement;
return static function (RoutingConfigurator $routes): void {
$routes->add('blog_list', '/blog/{page}')
->controller([BlogController::class, 'list'])
->requirements(['page' => Requirement::DIGITS])
;
// ...
};
.. tip::

Route requirements (and route paths too) can include
Expand Down Expand Up @@ -2327,7 +2372,7 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
class SomeService
{
public function __construct(
private UrlGeneratorInterface $router,
private UrlGeneratorInterface $urlGenerator,
) {
}

Expand All @@ -2336,20 +2381,20 @@ the :class:`Symfony\\Component\\Routing\\Generator\\UrlGeneratorInterface` class
// ...

// generate a URL with no route arguments
$signUpPage = $this->router->generate('sign_up');
$signUpPage = $this->urlGenerator->generate('sign_up');

// generate a URL with route arguments
$userProfilePage = $this->router->generate('user_profile', [
$userProfilePage = $this->urlGenerator->generate('user_profile', [
'username' => $user->getUserIdentifier(),
]);

// generated URLs are "absolute paths" by default. Pass a third optional
// argument to generate different URLs (e.g. an "absolute URL")
$signUpPage = $this->router->generate('sign_up', [], UrlGeneratorInterface::ABSOLUTE_URL);
$signUpPage = $this->urlGenerator->generate('sign_up', [], UrlGeneratorInterface::ABSOLUTE_URL);

// when a route is localized, Symfony uses by default the current request locale
// pass a different '_locale' value if you want to set the locale explicitly
$signUpPageInDutch = $this->router->generate('sign_up', ['_locale' => 'nl']);
$signUpPageInDutch = $this->urlGenerator->generate('sign_up', ['_locale' => 'nl']);
}
}

Expand Down
74 changes: 37 additions & 37 deletions service_container/service_decoration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -289,35 +289,35 @@ the ``decoration_priority`` option. Its value is an integer that defaults to

.. configuration-block::

.. code-block:: php-attributes
.. code-block:: php-attributes
// ...
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
// ...
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
#[AsDecorator(decorates: Foo::class, priority: 5)]
class Bar
{
public function __construct(
#[AutowireDecorated]
private $inner,
) {
}
// ...
#[AsDecorator(decorates: Foo::class, priority: 5)]
class Bar
{
public function __construct(
#[AutowireDecorated]
private $inner,
) {
}
// ...
}
#[AsDecorator(decorates: Foo::class, priority: 1)]
class Baz
{
public function __construct(
#[AutowireDecorated]
private $inner,
) {
}
// ...
#[AsDecorator(decorates: Foo::class, priority: 1)]
class Baz
{
public function __construct(
#[AutowireDecorated]
private $inner,
) {
}
// ...
}
.. code-block:: yaml
# config/services.yaml
Expand Down Expand Up @@ -609,24 +609,24 @@ Three different behaviors are available:

.. configuration-block::

.. code-block:: php-attributes
// ...
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
use Symfony\Component\DependencyInjection\ContainerInterface;
.. code-block:: php-attributes
#[AsDecorator(decorates: Mailer::class, onInvalid: ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]
class Bar
{
public function __construct(
#[AutowireDecorated] private $inner,
) {
}
// ...
use Symfony\Component\DependencyInjection\Attribute\AsDecorator;
use Symfony\Component\DependencyInjection\Attribute\AutowireDecorated;
use Symfony\Component\DependencyInjection\ContainerInterface;
// ...
#[AsDecorator(decorates: Mailer::class, onInvalid: ContainerInterface::IGNORE_ON_INVALID_REFERENCE)]
class Bar
{
public function __construct(
#[AutowireDecorated] private $inner,
) {
}
// ...
}
.. code-block:: yaml
# config/services.yaml
Expand Down

0 comments on commit fb28238

Please sign in to comment.