aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/report/handler_factory.php
blob: ec229aac5432b21dec7c70c47638e45e3b6fcdf1 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
/**
 *
 * This file is part of the phpBB Forum Software package.
 *
 * @copyright (c) phpBB Limited <https://www.phpbb.com>
 * @license GNU General Public License, version 2 (GPL-2.0)
 *
 * For full copyright and license information, please see
 * the docs/CREDITS.txt file.
 *
 */

namespace phpbb\report;

use phpbb\report\exception\factory_invalid_argument_exception;

class handler_factory
{
	/**
	 * @var \Symfony\Component\DependencyInjection\ContainerInterface
	 */
	protected $container;

	/**
	 * Constructor
	 *
	 * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
	 */
	public function __construct(\Symfony\Component\DependencyInjection\ContainerInterface $container)
	{
		$this->container = $container;
	}

	/**
	 * Return a new instance of an appropriate report handler
	 *
	 * @param string	$type
	 * @return \phpbb\report\report_handler_interface
	 * @throws \phpbb\report\exception\factory_invalid_argument_exception if $type is not valid
	 */
	public function get_instance($type)
	{
		switch ($type)
		{
			case 'pm':
				return $this->container->get('phpbb.report.handlers.report_handler_pm');
			break;
			case 'post':
				return $this->container->get('phpbb.report.handlers.report_handler_post');
			break;
		}

		throw new factory_invalid_argument_exception();
	}
}