aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/event/extension_subscriber_loader.php
blob: df8e093f4a7befb086dca317ead0374d72c27a76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
*
* @package phpBB3
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/

namespace phpbb\event;

use Symfony\Component\EventDispatcher\EventDispatcherInterface;

class 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')
			->core_path('event/')
			->get_classes();

		foreach ($subscriber_classes as $class)
		{
			$subscriber = new $class();
			$this->dispatcher->addSubscriber($subscriber);
		}
	}
}