summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2015-05-18 22:29:32 (GMT)
committerxjm2015-05-18 22:29:32 (GMT)
commit3542d9a526dbb36c8b8d9de89580e57fc4dc33ba (patch)
tree198700903603ee38c198c1d656cc0f5fb1247a31
parent02f6ab22dcd38b532360538f59106a92dd256829 (diff)
Issue #2447365 by JacobSanford, klausi, dawehner, jhodgdon, webchick: Let's explain in DestructableInterface why it is useful
-rw-r--r--core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php2
-rw-r--r--core/lib/Drupal/Core/DestructableInterface.php7
-rw-r--r--core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php2
-rw-r--r--core/modules/system/core.api.php3
4 files changed, 13 insertions, 1 deletions
diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
index ab89658..479fbd5 100644
--- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
+++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterServicesForDestructionPass.php
@@ -13,6 +13,8 @@ use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* Adds services tagged "needs_destruction" to the "kernel_destruct_subscriber"
* service.
+ *
+ * @see \Drupal\Core\DestructableInterface
*/
class RegisterServicesForDestructionPass implements CompilerPassInterface {
diff --git a/core/lib/Drupal/Core/DestructableInterface.php b/core/lib/Drupal/Core/DestructableInterface.php
index e06c6ec..abfec7a 100644
--- a/core/lib/Drupal/Core/DestructableInterface.php
+++ b/core/lib/Drupal/Core/DestructableInterface.php
@@ -9,6 +9,13 @@ namespace Drupal\Core;
/**
* The interface for services that need explicit destruction.
+ *
+ * This is useful for services that need to perform additional tasks to
+ * finalize operations or clean up after the response is sent and before the
+ * service is terminated.
+ *
+ * Services using this interface need to be registered with the
+ * "needs_destruction" tag.
*/
interface DestructableInterface {
diff --git a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
index 7cedb1c..9c3cfae 100644
--- a/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
+++ b/core/lib/Drupal/Core/EventSubscriber/KernelDestructionSubscriber.php
@@ -14,6 +14,8 @@ use Symfony\Component\HttpKernel\KernelEvents;
/**
* Destructs services that are initiated and tagged with "needs_destruction".
+ *
+ * @see \Drupal\Core\DestructableInterface
*/
class KernelDestructionSubscriber implements EventSubscriberInterface, ContainerAwareInterface {
diff --git a/core/modules/system/core.api.php b/core/modules/system/core.api.php
index 14c894a..dacffed 100644
--- a/core/modules/system/core.api.php
+++ b/core/modules/system/core.api.php
@@ -2152,7 +2152,8 @@ function hook_config_schema_info_alter(&$definitions) {
* for more information.
* - needs_destruction: Indicates that a destruct() method needs to be called
* at the end of a request to finalize operations, if this service was
- * instantiated.
+ * instantiated. Services should implement \Drupal\Core\DestructableInterface
+ * in this case.
*
* Creating a tag for a service does not do anything on its own, but tags
* can be discovered or queried in a compiler pass when the container is built,