Skip to content
Snippets Groups Projects
Commit e2158bfa authored by catch's avatar catch
Browse files

Issue #2514582 by Mile23, joachim, sahil.goyal, jhodgdon, Fabianx, dawehner:...

Issue #2514582 by Mile23, joachim, sahil.goyal, jhodgdon, Fabianx, dawehner: Document lazy services and fix script doxygen

(cherry picked from commit 85b4d86c)
parent e9d8f474
No related branches found
No related tags found
17 merge requests!8506Draft: Issue #3456536 by ibrahim tameme,!5646Issue #3350972 by nod_: [random test failure]...,!5600Issue #3350972 by nod_: [random test failure]...,!5343Issue #3305066 by quietone, Rename RedirectLeadingSlashesSubscriber,!3603#ISSUE 3346218 Add a different message on edit comment,!3555Issue #2473873: Views entity operations lack cacheability support, resulting in incorrect dropbuttons,!3494Issue #3327018 by Spokje, longwave, xjm, mondrake: Update PHPStan to 1.9.3 and...,!3410Issue #3340128: UserLoginForm::submitForm has some dead code,!3389Issue #3325184 by Spokje, andypost, xjm, smustgrave: $this->configFactory is...,!3381Issue #3332363: Refactor Claro's menus-and-lists stylesheet,!3307Issue #3326193: CKEditor 5 can grow past the viewport when there is a lot of content,!3236Issue #3332419: Refactor Claro's messages stylesheet,!3231Draft: Issue #3049525 by longwave, fougere, larowlan, kim.pepper, AaronBauman, Wim...,!3212Issue #3294003: Refactor Claro's entity-meta stylesheet,!3194Issue #3330981: Fix PHPStan L1 error "Relying on entity queries to check access by default is deprecated...",!3143Issue #3313342: [PHP 8.1] Deprecated function: strpos(): Passing null to parameter #1 LayoutBuilderUiCacheContext.php on line 28,!2972Issue #1845004: Replace custom password hashing library with PHP 5.5 password_hash()
...@@ -886,6 +886,10 @@ ...@@ -886,6 +886,10 @@
* Note that $container here is an instance of * Note that $container here is an instance of
* \Drupal\Core\DependencyInjection\ContainerBuilder. * \Drupal\Core\DependencyInjection\ContainerBuilder.
* *
* @section lazy_services Lazy services
* Some services can be declared as lazy to improve performance. See @link
* lazy_services Lazy Services @endlink for details.
*
* @see https://www.drupal.org/node/2133171 * @see https://www.drupal.org/node/2133171
* @see core.services.yml * @see core.services.yml
* @see \Drupal * @see \Drupal
...@@ -2489,6 +2493,32 @@ function hook_validation_constraint_alter(array &$definitions) { ...@@ -2489,6 +2493,32 @@ function hook_validation_constraint_alter(array &$definitions) {
* @} * @}
*/ */
/**
* @defgroup lazy_services Lazy Services
* @{
* Lazy services overview
*
* A service can be declared as lazy in order to improve performance. Classes
* that inject a lazy service receive a proxy class instead, and when a method
* on the lazy service is called, the proxy class gets the service from the
* container and forwards the method call. This means that the lazy service is
* only instantiated when it is needed.
*
* This is useful because some classes may inject a service which is expensive
* to instantiate (because it has multiple dependencies of its own), but is only
* used in exceptional cases. This would make the class dependent on the
* expensive service and all of the expensive service's dependencies.
*
* Making the expensive service lazy means that the class is only dependent on
* the proxy service, and not on all the dependencies of the lazy service.
*
* To define a service as lazy, add @code lazy: true @endcode to the service
* definition, and use the @code core/scripts/generate-proxy.sh @endcode script
* to generate the proxy class.
*
* @see core/scripts/generate-proxy.sh
*/
/** /**
* @defgroup events Events * @defgroup events Events
* @{ * @{
......
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
/** /**
* Provides a console command to generate proxy classes. * Provides a console command to generate proxy classes.
*
* @see lazy_services
* @see core/scripts/generate-proxy.sh
*/ */
class GenerateProxyClassApplication extends Application { class GenerateProxyClassApplication extends Application {
......
...@@ -10,6 +10,9 @@ ...@@ -10,6 +10,9 @@
/** /**
* Provides a console command to generate proxy classes. * Provides a console command to generate proxy classes.
*
* @see lazy_services
* @see core/scripts/generate-proxy.sh
*/ */
class GenerateProxyClassCommand extends Command { class GenerateProxyClassCommand extends Command {
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
/** /**
* Replaces all services with a lazy flag. * Replaces all services with a lazy flag.
*
* @see lazy_services
*/ */
class ProxyServicesPass implements CompilerPassInterface { class ProxyServicesPass implements CompilerPassInterface {
......
...@@ -3,7 +3,14 @@ ...@@ -3,7 +3,14 @@
/** /**
* @file * @file
* A command line application to generate proxy classes. * A script to generate proxy classes for lazy services.
*
* For help, type this command from the root directory of an installed Drupal
* site: php core/scripts/generate-proxy-class.php -h generate-proxy-class
*
* @ingroup container
*
* @see lazy_services
*/ */
use Drupal\Core\Command\GenerateProxyClassApplication; use Drupal\Core\Command\GenerateProxyClassApplication;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment