mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[feature/event-dispatcher] Allow subscribers to be loaded from extensions
PHPBB3-9550
This commit is contained in:
43
phpBB/includes/event/extension_subscriber_loader.php
Normal file
43
phpBB/includes/event/extension_subscriber_loader.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package phpBB3
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
if (!defined('IN_PHPBB'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class phpbb_event_extension_subscriber_loader
|
||||
{
|
||||
private $dispatcher;
|
||||
private $extension_manager;
|
||||
|
||||
public function __construct(phpbb_event_dispatcher $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('subscriber')
|
||||
->core_path('event/')
|
||||
->get_classes();
|
||||
|
||||
foreach ($subscriber_classes as $class) {
|
||||
$subscriber = new $class();
|
||||
$this->dispatcher->add_subscriber($subscriber);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user