Commit 62248090 authored by catch's avatar catch

Issue #2237101 by Mile23, cordoval, YesCT, dawehner, tim.plunkett: clean up...

Issue #2237101 by Mile23, cordoval, YesCT, dawehner, tim.plunkett: clean up for Core/DependencyInjection CompilerPasses
parent 0f76f79c
......@@ -24,6 +24,7 @@ public function process(ContainerBuilder $container) {
if (!$container->has('kernel')) {
return;
}
$kernel = $container->get('kernel');
if (!($kernel instanceof DrupalKernelInterface)) {
return;
......
......@@ -16,14 +16,13 @@
class RegisterAccessChecksPass implements CompilerPassInterface {
/**
* Implements CompilerPassInterface::process().
*
* Adds services tagged 'access_check' to the access_manager service.
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
if (!$container->hasDefinition('access_manager')) {
return;
}
// Add services tagged 'access_check' to the access_manager service.
$access_manager = $container->getDefinition('access_manager.check_provider');
foreach ($container->findTaggedServiceIds('access_check') as $id => $attributes) {
$applies = array();
......@@ -43,4 +42,5 @@ public function process(ContainerBuilder $container) {
$access_manager->addMethodCall('addCheckService', array($id, $method, $applies, $needs_incoming_request));
}
}
}
......@@ -14,6 +14,10 @@
* Registers all event subscribers to the event dispatcher.
*/
class RegisterEventSubscribersPass implements CompilerPassInterface {
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container) {
if (!$container->hasDefinition('event_dispatcher')) {
return;
......@@ -24,7 +28,8 @@ public function process(ContainerBuilder $container) {
$event_subscriber_info = [];
foreach ($container->findTaggedServiceIds('event_subscriber') as $id => $attributes) {
// We must assume that the class value has been correctly filled, even if the service is created by a factory
// We must assume that the class value has been correctly filled, even if
// the service is created by a factory.
$class = $container->getDefinition($id)->getClass();
$refClass = new \ReflectionClass($class);
......@@ -58,4 +63,5 @@ public function process(ContainerBuilder $container) {
$definition->addArgument($event_subscriber_info);
}
}
......@@ -27,10 +27,10 @@ public function process(ContainerBuilder $container) {
}
$definition = $container->getDefinition('kernel_destruct_subscriber');
$services = $container->findTaggedServiceIds('needs_destruction');
foreach ($services as $id => $attributes) {
$definition->addMethodCall('registerService', array($id));
}
}
}
......@@ -34,5 +34,4 @@ public function __sleep() {
assert(FALSE, 'The container was serialized.');
return array_keys(get_object_vars($this));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment