diff options
author | Matt Friedman <maf675@gmail.com> | 2013-12-12 10:28:10 -0800 |
---|---|---|
committer | Matt Friedman <maf675@gmail.com> | 2013-12-12 10:28:10 -0800 |
commit | a59bbeed2dd82b316f1e2f9ad484b978ef2a541c (patch) | |
tree | f3d667b7711b44fa56f6d575b8ae2bc072682d23 /phpBB/phpbb/event | |
parent | 2ae6f216f66466a1851f52cbc9839e3405525981 (diff) | |
parent | da6ced59d9632fec5103ce4bea86eb6bcceb5d1e (diff) | |
download | forums-a59bbeed2dd82b316f1e2f9ad484b978ef2a541c.tar forums-a59bbeed2dd82b316f1e2f9ad484b978ef2a541c.tar.gz forums-a59bbeed2dd82b316f1e2f9ad484b978ef2a541c.tar.bz2 forums-a59bbeed2dd82b316f1e2f9ad484b978ef2a541c.tar.xz forums-a59bbeed2dd82b316f1e2f9ad484b978ef2a541c.zip |
[ticket/11966] Merge branch 'develop' into ticket/11966
PHPBB3-11966
Diffstat (limited to 'phpBB/phpbb/event')
-rw-r--r-- | phpBB/phpbb/event/data.php | 100 | ||||
-rw-r--r-- | phpBB/phpbb/event/dispatcher.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/event/extension_subscriber_loader.php | 28 | ||||
-rw-r--r-- | phpBB/phpbb/event/kernel_exception_subscriber.php | 9 | ||||
-rw-r--r-- | phpBB/phpbb/event/kernel_request_subscriber.php | 8 | ||||
-rw-r--r-- | phpBB/phpbb/event/kernel_terminate_subscriber.php | 8 |
6 files changed, 54 insertions, 107 deletions
diff --git a/phpBB/phpbb/event/data.php b/phpBB/phpbb/event/data.php index 3481023b74..fbb16574ed 100644 --- a/phpBB/phpbb/event/data.php +++ b/phpBB/phpbb/event/data.php @@ -9,62 +9,54 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\Event; class data extends Event implements \ArrayAccess { - private $data; - - public function __construct(array $data = array()) - { - $this->set_data($data); - } - - public function set_data(array $data = array()) - { - $this->data = $data; - } - - public function get_data() - { - return $this->data; - } - - /** - * Returns data filtered to only include specified keys. - * - * This effectively discards any keys added to data by hooks. - */ - public function get_data_filtered($keys) - { - return array_intersect_key($this->data, array_flip($keys)); - } - - public function offsetExists($offset) - { - return isset($this->data[$offset]); - } - - public function offsetGet($offset) - { - return isset($this->data[$offset]) ? $this->data[$offset] : null; - } - - public function offsetSet($offset, $value) - { - $this->data[$offset] = $value; - } - - public function offsetUnset($offset) - { - unset($this->data[$offset]); - } + private $data; + + public function __construct(array $data = array()) + { + $this->set_data($data); + } + + public function set_data(array $data = array()) + { + $this->data = $data; + } + + public function get_data() + { + return $this->data; + } + + /** + * Returns data filtered to only include specified keys. + * + * This effectively discards any keys added to data by hooks. + */ + public function get_data_filtered($keys) + { + return array_intersect_key($this->data, array_flip($keys)); + } + + public function offsetExists($offset) + { + return isset($this->data[$offset]); + } + + public function offsetGet($offset) + { + return isset($this->data[$offset]) ? $this->data[$offset] : null; + } + + public function offsetSet($offset, $value) + { + $this->data[$offset] = $value; + } + + public function offsetUnset($offset) + { + unset($this->data[$offset]); + } } diff --git a/phpBB/phpbb/event/dispatcher.php b/phpBB/phpbb/event/dispatcher.php index cc3733692e..74b35eb78d 100644 --- a/phpBB/phpbb/event/dispatcher.php +++ b/phpBB/phpbb/event/dispatcher.php @@ -9,14 +9,6 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; /** diff --git a/phpBB/phpbb/event/extension_subscriber_loader.php b/phpBB/phpbb/event/extension_subscriber_loader.php index ab50a589fe..6408f93e2a 100644 --- a/phpBB/phpbb/event/extension_subscriber_loader.php +++ b/phpBB/phpbb/event/extension_subscriber_loader.php @@ -9,39 +9,27 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\EventDispatcherInterface; class extension_subscriber_loader { private $dispatcher; - private $extension_manager; + private $listener_collection; - public function __construct(EventDispatcherInterface $dispatcher, \phpbb\extension\manager $extension_manager) + public function __construct(EventDispatcherInterface $dispatcher, \phpbb\di\service_collection $listener_collection) { $this->dispatcher = $dispatcher; - $this->extension_manager = $extension_manager; + $this->listener_collection = $listener_collection; } public function load() { - $finder = $this->extension_manager->get_finder(); - $subscriber_classes = $finder - ->extension_directory('/event') - ->core_path('event/') - ->get_classes(); - - foreach ($subscriber_classes as $class) + if (!empty($this->listener_collection)) { - $subscriber = new $class(); - $this->dispatcher->addSubscriber($subscriber); + foreach ($this->listener_collection as $listener) + { + $this->dispatcher->addSubscriber($listener); + } } } } diff --git a/phpBB/phpbb/event/kernel_exception_subscriber.php b/phpBB/phpbb/event/kernel_exception_subscriber.php index 09103680e8..8a4de1fbad 100644 --- a/phpBB/phpbb/event/kernel_exception_subscriber.php +++ b/phpBB/phpbb/event/kernel_exception_subscriber.php @@ -9,14 +9,6 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; @@ -72,7 +64,6 @@ class kernel_exception_subscriber implements EventSubscriberInterface page_footer(true, false, false); - $status_code = $exception instanceof HttpException ? $exception->getStatusCode() : 500; $response = new Response($this->template->assign_display('body'), $status_code); $event->setResponse($response); diff --git a/phpBB/phpbb/event/kernel_request_subscriber.php b/phpBB/phpbb/event/kernel_request_subscriber.php index a629dd8440..7d5418498b 100644 --- a/phpBB/phpbb/event/kernel_request_subscriber.php +++ b/phpBB/phpbb/event/kernel_request_subscriber.php @@ -9,14 +9,6 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; diff --git a/phpBB/phpbb/event/kernel_terminate_subscriber.php b/phpBB/phpbb/event/kernel_terminate_subscriber.php index de441da102..32dba322d1 100644 --- a/phpBB/phpbb/event/kernel_terminate_subscriber.php +++ b/phpBB/phpbb/event/kernel_terminate_subscriber.php @@ -9,14 +9,6 @@ namespace phpbb\event; -/** -* @ignore -*/ -if (!defined('IN_PHPBB')) -{ - exit; -} - use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\PostResponseEvent; |