Skip to content

Commit 317e973

Browse files
committed
Merge remote-tracking branch 'upstream/7.0' into 7.0
* upstream/7.0: - [Console] Add more examples for lazy commands [Reference] Fix assets links have wrong label some tweaks for the Webhook docs fix headline [Security] Update request matcher doc
2 parents 75bf7b9 + 717aee7 commit 317e973

File tree

8 files changed

+51
-16
lines changed

8 files changed

+51
-16
lines changed

console/commands_as_services.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,5 @@ only when the ``app:sunshine`` command is actually called.
133133
.. caution::
134134

135135
Calling the ``list`` command will instantiate all commands, including lazy commands.
136+
However, if the command is a ``Symfony\Component\Console\Command\LazyCommand``, then
137+
the underlying command factory will not be executed.

console/lazy_commands.rst

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ The traditional way of adding commands to your application is to use
1010
:method:`Symfony\\Component\\Console\\Application::add`, which expects a
1111
``Command`` instance as an argument.
1212

13+
This approach can have downsides as some commands might be expensive to
14+
instantiate in which case you may want to lazy-load them. Note however that lazy-loading
15+
is not absolute. Indeed a few commands such as `list`, `help` or `_complete` can
16+
require to instantiate other commands although they are lazy. For example `list` needs
17+
to get the name and description of all commands, which might require the command to be
18+
instantiated to get.
19+
1320
In order to lazy-load commands, you need to register an intermediate loader
1421
which will be responsible for returning ``Command`` instances::
1522

@@ -19,7 +26,9 @@ which will be responsible for returning ``Command`` instances::
1926
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
2027

2128
$commandLoader = new FactoryCommandLoader([
22-
'app:heavy' => function (): Command { return new HeavyCommand(); },
29+
// Note that the `list` command will still instantiate that command
30+
// in this example.
31+
'app:heavy' => static fn(): Command => new HeavyCommand(),
2332
]);
2433

2534
$application = new Application();
@@ -36,6 +45,28 @@ method accepts any
3645
:class:`Symfony\\Component\\Console\\CommandLoader\\CommandLoaderInterface`
3746
instance so you can use your own implementation.
3847

48+
Another way to do so is to take advantage of ``Symfony\Component\Console\Command\LazyCommand``::
49+
50+
use App\Command\HeavyCommand;
51+
use Symfony\Component\Console\Application;
52+
use Symfony\Component\Console\Command\Command;
53+
use Symfony\Component\Console\CommandLoader\FactoryCommandLoader;
54+
55+
// In this case although the command is instantiated, the underlying command factory
56+
// will not be executed unless the command is actually executed or one tries to access
57+
// to its input definition to know its argument or option inputs.
58+
$lazyCommand = new LazyCommand(
59+
'app:heavy',
60+
[],
61+
'This is another more complete form of lazy command.',
62+
false,
63+
static fn (): Command => new HeavyCommand(),
64+
);
65+
66+
$application = new Application();
67+
$application->add($lazyCommand);
68+
$application->run();
69+
3970
Built-in Command Loaders
4071
------------------------
4172

mailer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ party provider:
272272
273273
.. tip::
274274

275-
Some third party mailers, when using the API, support status callback
275+
Some third party mailers, when using the API, support status callbacks
276276
via webhooks. See the :doc:`Webhook documentation </webhook>` for more
277277
details.
278278

messenger.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ running the ``messenger:consume`` command.
881881

882882
.. _messenger-retries-failures:
883883

884-
Rate limited transport
884+
Rate Limited Transport
885885
~~~~~~~~~~~~~~~~~~~~~~
886886

887887
Sometimes you might need to rate limit your message worker. You can configure a

notifier.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Service Package DSN
104104

105105
.. tip::
106106

107-
Some third party transports, when using the API, support status callback
107+
Some third party transports, when using the API, support status callbacks
108108
via webhooks. See the :doc:`Webhook documentation </webhook>` for more
109109
details.
110110

reference/twig_reference.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,10 @@ the application is installed (e.g. in case the project is accessed in a host
116116
subdirectory) and the optional asset package base path.
117117

118118
Symfony provides various cache busting implementations via the
119-
:ref:`reference-framework-assets-version`, :ref:`reference-assets-version-strategy`,
120-
and :ref:`reference-assets-json-manifest-path` configuration options.
119+
:ref:`assets.version <reference-framework-assets-version>`,
120+
:ref:`assets.version_strategy <reference-assets-version-strategy>`,
121+
and :ref:`assets.json_manifest_path <reference-assets-json-manifest-path>`
122+
configuration options.
121123

122124
.. seealso::
123125

security/access_control.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ things:
1919
1. Matching Options
2020
-------------------
2121

22-
Symfony creates an instance of :class:`Symfony\\Component\\HttpFoundation\\RequestMatcher`
23-
for each ``access_control`` entry, which determines whether or not a given
24-
access control should be used on this request. The following ``access_control``
25-
options are used for matching:
22+
Symfony uses :class:`Symfony\\Component\\HttpFoundation\\ChainRequestMatcher` for
23+
each ``access_control`` entry, which determines which implementation of
24+
:class:`Symfony\\Component\\HttpFoundation\\RequestMatcherInterface` should be used
25+
on this request. The following ``access_control`` options are used for matching:
2626

2727
* ``path``: a regular expression (without delimiters)
2828
* ``ip`` or ``ips``: netmasks are also supported (can be a comma-separated string)

webhook.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ Installation
1212
1313
$ composer require symfony/webhook
1414
15-
Usage in combination with the Mailer component
15+
Usage in Combination with the Mailer Component
1616
----------------------------------------------
1717

1818
When using a third-party mailer, you can use the Webhook component to receive
1919
webhook calls from the third-party mailer.
2020

21-
In this example Mailgun is used with ``'mailer_mailgun'`` as webhook type.
22-
Any type name can be used as long as it's unique. Make sure to use it in the
21+
In this example Mailgun is used with ``'mailer_mailgun'`` as the webhook type.
22+
Any type name can be used as long as it is unique. Make sure to use it in the
2323
routing configuration, the webhook URL and the RemoteEvent consumer.
2424

25-
Install the third party mailer as described in the documentation of the
25+
Install the third-party mailer as described in the documentation of the
2626
:ref:`Mailer component <mailer_3rd_party_transport>`.
2727

2828
The Webhook component routing needs to be defined:
@@ -130,13 +130,13 @@ With this done, you can now add a RemoteEvent consumer to react to the webhooks:
130130
}
131131
}
132132

133-
Usage in combination with the Notifier component
133+
Usage in Combination with the Notifier Component
134134
------------------------------------------------
135135

136136
The usage of the Webhook component when using a third-party transport in
137137
the Notifier is very similar to the usage with the Mailer.
138138

139-
Currently, the following third-party sms transports support webhooks:
139+
Currently, the following third-party SMS transports support webhooks:
140140

141141
============ ==========================================
142142
SMS service Parser service name

0 commit comments

Comments
 (0)