aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/includes/event/extension_subscriber_loader.php
diff options
context:
space:
mode:
Diffstat (limited to 'phpBB/includes/event/extension_subscriber_loader.php')
-rw-r--r--phpBB/includes/event/extension_subscriber_loader.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/phpBB/includes/event/extension_subscriber_loader.php b/phpBB/includes/event/extension_subscriber_loader.php
new file mode 100644
index 0000000000..d933b943d7
--- /dev/null
+++ b/phpBB/includes/event/extension_subscriber_loader.php
@@ -0,0 +1,46 @@
+<?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\EventDispatcherInterface;
+
+class phpbb_event_extension_subscriber_loader
+{
+ private $dispatcher;
+ private $extension_manager;
+
+ public function __construct(EventDispatcherInterface $dispatcher, phpbb_extension_manager $extension_manager)
+ {
+ $this->dispatcher = $dispatcher;
+ $this->extension_manager = $extension_manager;
+ }
+
+ public function load()
+ {
+ $finder = $this->extension_manager->get_finder();
+ $subscriber_classes = $finder
+ ->extension_directory('/event')
+ ->suffix('listener')
+ ->core_path('event/')
+ ->get_classes();
+
+ foreach ($subscriber_classes as $class)
+ {
+ $subscriber = new $class();
+ $this->dispatcher->addSubscriber($subscriber);
+ }
+ }
+}