diff options
author | Oleg Pudeyev <oleg@bsdpower.com> | 2012-12-06 21:49:24 -0500 |
---|---|---|
committer | Oleg Pudeyev <oleg@bsdpower.com> | 2012-12-06 21:49:24 -0500 |
commit | 26fd70d9cdffe0107635db5f3846dbe5ea6e3fae (patch) | |
tree | 641a33e35665c3b8198fd2d641a687560342ba56 /phpBB/includes/di/pass/kernel_pass.php | |
parent | 74093d0fd383619ec8b58914ebe2edd68145e070 (diff) | |
parent | 2364d4b2172c9f54520f04001b29c517d7138b69 (diff) | |
download | forums-26fd70d9cdffe0107635db5f3846dbe5ea6e3fae.tar forums-26fd70d9cdffe0107635db5f3846dbe5ea6e3fae.tar.gz forums-26fd70d9cdffe0107635db5f3846dbe5ea6e3fae.tar.bz2 forums-26fd70d9cdffe0107635db5f3846dbe5ea6e3fae.tar.xz forums-26fd70d9cdffe0107635db5f3846dbe5ea6e3fae.zip |
Merge remote-tracking branch 'upstream/develop' into ticket/11015
* upstream/develop: (196 commits)
[ticket/11219] Coding guidelines and naming consistency changes
[ticket/10841] Revert more whitespace changes.
[ticket/10841] Revert whitespace changes.
[ticket/10841] adding space after if
[ticket/10841] removing unnecessary spacing
[ticket/10841] changing affectedrows check to COUNT in sql
[ticket/10841] Modifying style and language selectors in UCP
[ticket/11247] Fix wrong property reference in flock class.
[ticket/10602] Avoid a race condition.
[ticket/10602] Use last_queue_run for its intended purpose.
[ticket/10716] Collect standard error from executed php process.
[ticket/10716] Skip test if php is not in PATH.
[ticket/10716] Exclude our dependencies from linting.
[ticket/10103] New and improved wording.
[ticket/10716] Only lint on php 5.3+.
[ticket/10103] Assert with messages.
[ticket/10103] assertLessThan/assertGreaterThan.
[ticket/10103] Inline assignment is bad?
[ticket/10103] $rv had too few characters.
[ticket/10103] Correct flock class documentation.
...
Conflicts:
phpBB/includes/functions.php
tests/cache/cache_test.php
Diffstat (limited to 'phpBB/includes/di/pass/kernel_pass.php')
-rw-r--r-- | phpBB/includes/di/pass/kernel_pass.php | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/phpBB/includes/di/pass/kernel_pass.php b/phpBB/includes/di/pass/kernel_pass.php new file mode 100644 index 0000000000..a701ebcfa6 --- /dev/null +++ b/phpBB/includes/di/pass/kernel_pass.php @@ -0,0 +1,68 @@ +<?php +/** +* +* @package phpBB3 +* @copyright (c) 2012 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +/** +* @ignore +*/ +if (!defined('IN_PHPBB')) +{ + exit; +} + +use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; + +class phpbb_di_pass_kernel_pass implements CompilerPassInterface +{ + /** + * Modify the container before it is passed to the rest of the code + * + * @param ContainerBuilder $container ContainerBuilder object + * @return null + */ + public function process(ContainerBuilder $container) + { + $definition = $container->getDefinition('dispatcher'); + + 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(sprintf('Service "%1$s" must define the "event" attribute on "kernel.event_listener" tags.', $id)); + } + + if (!isset($event['method'])) + { + throw new InvalidArgumentException(sprintf('Service "%1$s" must define the "method" attribute on "kernel.event_listener" tags.', $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(sprintf('Service "%1$s" must implement interface "%2$s".', $id, $interface)); + } + + $definition->addMethodCall('addSubscriberService', array($id, $class)); + } + } +} |