diff options
| author | Marc Alexander <admin@m-a-styles.de> | 2012-12-09 21:02:31 +0100 |
|---|---|---|
| committer | Marc Alexander <admin@m-a-styles.de> | 2012-12-09 21:02:31 +0100 |
| commit | 1aae72961a3205a8487218b6d69361c43a1297d6 (patch) | |
| tree | 3096a599c14c88084f782022f002ed84224ccf8b /phpBB/includes/di | |
| parent | 26bde05a30c7111b57621a37d86425aa69d74263 (diff) | |
| parent | 3fe381eed561e724700b21789e28ea3efb1f7ef9 (diff) | |
| download | forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.gz forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.bz2 forums-1aae72961a3205a8487218b6d69361c43a1297d6.tar.xz forums-1aae72961a3205a8487218b6d69361c43a1297d6.zip | |
Merge branch 'develop' into feature/avatars
Conflicts:
phpBB/install/database_update.php
Diffstat (limited to 'phpBB/includes/di')
| -rw-r--r-- | phpBB/includes/di/extension/ext.php | 2 | ||||
| -rw-r--r-- | phpBB/includes/di/pass/kernel_pass.php | 68 | ||||
| -rw-r--r-- | phpBB/includes/di/service_collection.php | 2 |
3 files changed, 70 insertions, 2 deletions
diff --git a/phpBB/includes/di/extension/ext.php b/phpBB/includes/di/extension/ext.php index e76c543ee1..7d9b433751 100644 --- a/phpBB/includes/di/extension/ext.php +++ b/phpBB/includes/di/extension/ext.php @@ -49,7 +49,7 @@ class phpbb_di_extension_ext extends Extension { if (file_exists($path . '/config/services.yml')) { - $loader = new YamlFileLoader($container, new FileLocator(phpbb_real_path($path . '/config'))); + $loader = new YamlFileLoader($container, new FileLocator(phpbb_realpath($path . '/config'))); $loader->load('services.yml'); } } 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)); + } + } +} diff --git a/phpBB/includes/di/service_collection.php b/phpBB/includes/di/service_collection.php index 60323c8dba..880cb46d4d 100644 --- a/phpBB/includes/di/service_collection.php +++ b/phpBB/includes/di/service_collection.php @@ -43,7 +43,7 @@ class phpbb_di_service_collection extends ArrayObject public function add($name) { $task = $this->container->get($name); - $task->set_name($name); + $this->offsetSet($name, $task); } } |
