From 97957d679250c642969a09b002f4125889a5f4fa Mon Sep 17 00:00:00 2001 From: David King Date: Sun, 21 Oct 2012 16:37:03 -0400 Subject: [feature/controller-new] Rename kernel compiler pass class PHPBB3-10864 --- phpBB/common.php | 1 + phpBB/includes/di/pass/kernel.php | 69 +++++++++++++++++++++++++++ phpBB/includes/event/kernel_compiler_pass.php | 69 --------------------------- 3 files changed, 70 insertions(+), 69 deletions(-) create mode 100644 phpBB/includes/di/pass/kernel.php delete mode 100644 phpBB/includes/event/kernel_compiler_pass.php (limited to 'phpBB') diff --git a/phpBB/common.php b/phpBB/common.php index 986f0a8839..b0bc281b45 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -93,6 +93,7 @@ $phpbb_container = phpbb_create_dumped_container_unless_debug( ), array( new phpbb_di_pass_collection_pass(), + new phpbb_di_pass_kernel(), ), $phpbb_root_path, $phpEx diff --git a/phpBB/includes/di/pass/kernel.php b/phpBB/includes/di/pass/kernel.php new file mode 100644 index 0000000000..7b190a6236 --- /dev/null +++ b/phpBB/includes/di/pass/kernel.php @@ -0,0 +1,69 @@ +getDefinition('dispatcher'); + $user = $container->get('user'); + + foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events) + { + foreach ($events as $event) + { + $priority = isset($event['priority']) ? $event['priority'] : 0; + + if (!isset($event['event'])) + { + throw new InvalidArgumentException($user->lang('NO_EVENT_ATTRIBUTE', $id)); + } + + if (!isset($event['method'])) + { + throw new InvalidArgumentException($user->lang('NO_METHOD_ATTRIBUTE', $id)); + } + + $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); + } + } + + foreach ($container->findTaggedServiceIds('kernel.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 + $class = $container->getDefinition($id)->getClass(); + + $refClass = new ReflectionClass($class); + $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; + if (!$refClass->implementsInterface($interface)) + { + throw new InvalidArgumentException($user->lang('SUBSCRIBER_WRONG_TYPE', $id, $interface)); + } + + $definition->addMethodCall('addSubscriberService', array($id, $class)); + } + } +} diff --git a/phpBB/includes/event/kernel_compiler_pass.php b/phpBB/includes/event/kernel_compiler_pass.php deleted file mode 100644 index 9a650bc404..0000000000 --- a/phpBB/includes/event/kernel_compiler_pass.php +++ /dev/null @@ -1,69 +0,0 @@ -getDefinition('dispatcher'); - $user = $container->get('user'); - - foreach ($container->findTaggedServiceIds('kernel.event_listener') as $id => $events) - { - foreach ($events as $event) - { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) - { - throw new InvalidArgumentException($user->lang('NO_EVENT_ATTRIBUTE', $id)); - } - - if (!isset($event['method'])) - { - throw new InvalidArgumentException($user->lang('NO_METHOD_ATTRIBUTE', $id)); - } - - $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); - } - } - - foreach ($container->findTaggedServiceIds('kernel.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 - $class = $container->getDefinition($id)->getClass(); - - $refClass = new ReflectionClass($class); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - if (!$refClass->implementsInterface($interface)) - { - throw new InvalidArgumentException($user->lang('SUBSCRIBER_WRONG_TYPE', $id, $interface)); - } - - $definition->addMethodCall('addSubscriberService', array($id, $class)); - } - } -} -- cgit v1.2.1