diff options
author | David King <imkingdavid@gmail.com> | 2012-10-20 16:57:21 -0400 |
---|---|---|
committer | Igor Wiedler <igor@wiedler.ch> | 2012-11-10 11:40:10 +0100 |
commit | b20d852b7fc43431ade40ee97fd5ece5e3271d5d (patch) | |
tree | ecc46410675ea760d9cde2b51d3e912e7bd0da2d | |
parent | 6d40b81dda242f5f07fe1e01430d70e6879d1885 (diff) | |
download | forums-b20d852b7fc43431ade40ee97fd5ece5e3271d5d.tar forums-b20d852b7fc43431ade40ee97fd5ece5e3271d5d.tar.gz forums-b20d852b7fc43431ade40ee97fd5ece5e3271d5d.tar.bz2 forums-b20d852b7fc43431ade40ee97fd5ece5e3271d5d.tar.xz forums-b20d852b7fc43431ade40ee97fd5ece5e3271d5d.zip |
[feature/compiled-dic] Remove HttpKernel-related stuff
These things should be added in the Controller PR instead.
PHPBB3-11152
-rw-r--r-- | phpBB/common.php | 4 | ||||
-rw-r--r-- | phpBB/includes/event/kernel_compiler_pass.php | 72 | ||||
-rw-r--r-- | phpBB/includes/event/kernel_subscriber.php | 94 |
3 files changed, 1 insertions, 169 deletions
diff --git a/phpBB/common.php b/phpBB/common.php index a681561619..fce08f3834 100644 --- a/phpBB/common.php +++ b/phpBB/common.php @@ -104,9 +104,7 @@ $phpbb_container = phpbb_create_compiled_container( new phpbb_di_extension_config($phpbb_root_path . 'config.' . $phpEx), new phpbb_di_extension_core($phpbb_root_path), ), - array( - new phpbb_event_kernel_compiler_pass(), - ), + array(), $phpbb_root_path . 'config.' . $phpEx, $phpbb_root_path, $phpEx diff --git a/phpBB/includes/event/kernel_compiler_pass.php b/phpBB/includes/event/kernel_compiler_pass.php deleted file mode 100644 index 18b6661cd4..0000000000 --- a/phpBB/includes/event/kernel_compiler_pass.php +++ /dev/null @@ -1,72 +0,0 @@ -<?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_event_kernel_compiler_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'); - $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'])) - { - $event['method'] = 'on'.preg_replace(array( - '/(?<=\b)[a-z]/ie', - '/[^a-z0-9]/i' - ), array('strtoupper("\\0")', ''), $event['event']); - } - - $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_subscriber.php b/phpBB/includes/event/kernel_subscriber.php deleted file mode 100644 index 9737d9bc23..0000000000 --- a/phpBB/includes/event/kernel_subscriber.php +++ /dev/null @@ -1,94 +0,0 @@ -<?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\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\HttpKernel\Event\PostResponseEvent; -use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; -use Symfony\Component\HttpFoundation\Response; - -class phpbb_event_kernel_subscriber implements EventSubscriberInterface -{ - /** - * Template object - * @var phpbb_template - */ - protected $template; - - /** - * User object - * @var phpbb_user - */ - protected $user; - - /** - * Construct method - * - * @param phpbb_template $template Template object - * @param phpbb_user $user User object - */ - public function __construct(phpbb_template $template, phpbb_user $user) - { - $this->template = $template; - $this->user = $user; - } - - /** - * This listener is run when the KernelEvents::TERMINATE event is triggered - * This comes after a Response has been sent to the server; this is - * primarily cleanup stuff. - * - * @param PostResponseEvent $event - * @return null - */ - public function on_kernel_terminate(PostResponseEvent $event) - { - exit_handler(); - } - - /** - * This listener is run when the KernelEvents::EXCEPTION event is triggered - * - * @param GetResponseForExceptionEvent $event - * @return null - */ - public function on_kernel_exception(GetResponseForExceptionEvent $event) - { - page_header($this->user->lang('INFORMATION')); - - $this->template->assign_vars(array( - 'MESSAGE_TITLE' => $this->user->lang('INFORMATION'), - 'MESSAGE_TEXT' => $event->getException()->getMessage(), - )); - - $this->template->set_filenames(array( - 'body' => 'message_body.html', - )); - - page_footer(true, false, false); - - $event->setResponse(new Response($this->template->return_display('body'), 404)); - } - - public static function getSubscribedEvents() - { - return array( - KernelEvents::TERMINATE => 'on_kernel_terminate', - KernelEvents::EXCEPTION => 'on_kernel_exception', - ); - } -} |