mirror of
https://github.com/phpbb/phpbb.git
synced 2025-03-14 04:30:29 +01:00
[feature/event-dispatcher] Allow subscribers to be loaded from extensions
PHPBB3-9550
This commit is contained in:
parent
80840a5f08
commit
581b5624f7
@ -98,6 +98,7 @@ $phpbb_class_loader_ext->set_cache($cache->get_driver());
|
||||
$phpbb_class_loader->set_cache($cache->get_driver());
|
||||
|
||||
// Instantiate some basic classes
|
||||
$phpbb_dispatcher = new phpbb_event_dispatcher();
|
||||
$request = new phpbb_request();
|
||||
$user = new user();
|
||||
$auth = new auth();
|
||||
@ -124,6 +125,9 @@ $phpbb_template_locator = new phpbb_template_locator();
|
||||
$phpbb_template_path_provider = new phpbb_template_extension_path_provider($phpbb_extension_manager, new phpbb_template_path_provider());
|
||||
$template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $phpbb_template_locator, $phpbb_template_path_provider);
|
||||
|
||||
$phpbb_subscriber_loader = new phpbb_event_extension_subscriber_loader($phpbb_dispatcher, $phpbb_extension_manager);
|
||||
$phpbb_subscriber_loader->load();
|
||||
|
||||
// Add own hook handler
|
||||
require($phpbb_root_path . 'includes/hooks/index.' . $phpEx);
|
||||
$phpbb_hook = new phpbb_hook(array('exit_handler', 'phpbb_user_session_handler', 'append_sid', array('template', 'display')));
|
||||
|
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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user