|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2013 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\sitemaker\services\blocks; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
13
|
|
|
|
|
14
|
|
|
class action_handler |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var \phpbb\config\config */ |
|
17
|
|
|
protected $config; |
|
18
|
|
|
|
|
19
|
|
|
/** @var ContainerInterface */ |
|
20
|
|
|
protected $phpbb_container; |
|
21
|
|
|
|
|
22
|
|
|
/** @var \phpbb\request\request_interface */ |
|
23
|
|
|
protected $request; |
|
24
|
|
|
|
|
25
|
|
|
/** @var \phpbb\language\language */ |
|
26
|
|
|
protected $translator; |
|
27
|
|
|
|
|
28
|
|
|
/** @var \blitze\sitemaker\services\blocks\blocks */ |
|
29
|
|
|
protected $blocks; |
|
30
|
|
|
|
|
31
|
|
|
/** @var \blitze\sitemaker\services\blocks\factory */ |
|
32
|
|
|
protected $block_factory; |
|
33
|
|
|
|
|
34
|
|
|
/** @var \blitze\sitemaker\model\mapper_factory */ |
|
35
|
|
|
protected $mapper_factory; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Constructor |
|
39
|
|
|
* |
|
40
|
|
|
* @param \phpbb\config\config $config Config object |
|
41
|
|
|
* @param ContainerInterface $phpbb_container Service container |
|
42
|
|
|
* @param \phpbb\request\request_interface $request Request object |
|
43
|
|
|
* @param \phpbb\language\language $translator Language object |
|
44
|
|
|
* @param \blitze\sitemaker\services\blocks\blocks $blocks Blocks object |
|
45
|
|
|
* @param \blitze\sitemaker\services\blocks\factory $block_factory Blocks factory object |
|
46
|
|
|
* @param \blitze\sitemaker\model\mapper_factory $mapper_factory Mapper factory object |
|
47
|
|
|
*/ |
|
48
|
15 |
|
public function __construct(\phpbb\config\config $config, ContainerInterface $phpbb_container, \phpbb\request\request_interface $request, \phpbb\language\language $translator, \blitze\sitemaker\services\blocks\blocks $blocks, \blitze\sitemaker\services\blocks\factory $block_factory, \blitze\sitemaker\model\mapper_factory $mapper_factory) |
|
49
|
|
|
{ |
|
50
|
15 |
|
$this->config = $config; |
|
51
|
15 |
|
$this->phpbb_container = $phpbb_container; |
|
52
|
15 |
|
$this->request = $request; |
|
53
|
15 |
|
$this->translator = $translator; |
|
54
|
15 |
|
$this->blocks = $blocks; |
|
55
|
15 |
|
$this->block_factory = $block_factory; |
|
56
|
15 |
|
$this->mapper_factory = $mapper_factory; |
|
57
|
15 |
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @param string $action |
|
61
|
|
|
* @return \blitze\sitemaker\services\blocks\action\action_interface |
|
62
|
|
|
* @throws \blitze\sitemaker\exception\unexpected_value |
|
63
|
|
|
*/ |
|
64
|
13 |
|
public function create($action) |
|
65
|
|
|
{ |
|
66
|
13 |
|
$action_class = 'blitze\\sitemaker\\services\\blocks\\action\\' . $action; |
|
67
|
|
|
|
|
68
|
13 |
|
if (!class_exists($action_class)) |
|
69
|
13 |
|
{ |
|
70
|
2 |
|
throw new \blitze\sitemaker\exception\unexpected_value(array($action, 'INVALID_ACTION')); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
11 |
|
return new $action_class($this->config, $this->phpbb_container, $this->request, $this->translator, $this->blocks, $this->block_factory, $this->mapper_factory); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* Clear cache after every action |
|
78
|
|
|
*/ |
|
79
|
1 |
|
public function clear_cache() |
|
80
|
|
|
{ |
|
81
|
1 |
|
$this->blocks->clear_cache(); |
|
82
|
1 |
|
} |
|
83
|
|
|
} |
|
84
|
|
|
|