|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* |
|
4
|
|
|
* @package sitemaker |
|
5
|
|
|
* @copyright (c) 2016 Daniel A. (blitze) |
|
6
|
|
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace blitze\content\services\actions\type; |
|
11
|
|
|
|
|
12
|
|
|
use blitze\content\services\actions\action_interface; |
|
13
|
|
|
use blitze\content\services\actions\action_utils; |
|
14
|
|
|
|
|
15
|
|
|
class delete extends action_utils implements action_interface |
|
16
|
|
|
{ |
|
17
|
|
|
/** @var \phpbb\cache\driver\driver_interface */ |
|
18
|
|
|
protected $cache; |
|
19
|
|
|
|
|
20
|
|
|
/** @var\phpbb\language\language */ |
|
21
|
|
|
protected $language; |
|
22
|
|
|
|
|
23
|
|
|
/** @var \phpbb\log\log_interface */ |
|
24
|
|
|
protected $logger; |
|
25
|
|
|
|
|
26
|
|
|
/** @var \phpbb\request\request_interface */ |
|
27
|
|
|
protected $request; |
|
28
|
|
|
|
|
29
|
|
|
/** @var \phpbb\user */ |
|
30
|
|
|
protected $user; |
|
31
|
|
|
|
|
32
|
|
|
/** @var \blitze\content\services\types */ |
|
33
|
|
|
protected $content_types; |
|
34
|
|
|
|
|
35
|
|
|
/** @var \blitze\sitemaker\services\forum\manager */ |
|
|
|
|
|
|
36
|
|
|
protected $forum_manager; |
|
37
|
|
|
|
|
38
|
|
|
/** @var \blitze\content\model\mapper_factory */ |
|
39
|
|
|
protected $content_mapper_factory; |
|
40
|
|
|
|
|
41
|
|
|
/** @var \blitze\sitemaker\model\mapper_factory */ |
|
|
|
|
|
|
42
|
|
|
protected $sitemaker_mapper_factory; |
|
43
|
|
|
|
|
44
|
|
|
/** @var bool */ |
|
45
|
|
|
protected $auto_refresh; |
|
46
|
|
|
|
|
47
|
|
|
/** @var bool */ |
|
48
|
|
|
protected $trigger_error; |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Constructor |
|
52
|
|
|
* |
|
53
|
|
|
* @param \phpbb\cache\driver\driver_interface $cache Cache object |
|
54
|
|
|
* @param \phpbb\language\language $language Language Object |
|
55
|
|
|
* @param \phpbb\log\log_interface $logger phpBB logger |
|
56
|
|
|
* @param \phpbb\request\request_interface $request Request object |
|
57
|
|
|
* @param \phpbb\user $user User object |
|
58
|
|
|
* @param \blitze\content\services\types $content_types Content types object |
|
59
|
|
|
* @param \blitze\sitemaker\services\forum\manager $forum_manager Forum manager object |
|
60
|
|
|
* @param \blitze\content\model\mapper_factory $content_mapper_factory Content Mapper factory object |
|
61
|
|
|
* @param \blitze\sitemaker\model\mapper_factory $sitemaker_mapper_factory Sitemaker Mapper factory object |
|
62
|
|
|
* @param bool $auto_refresh Used during testing |
|
63
|
|
|
* @param bool $trigger_error Used during testing |
|
64
|
|
|
*/ |
|
65
|
2 |
|
public function __construct(\phpbb\cache\driver\driver_interface $cache, \phpbb\language\language $language, \phpbb\log\log_interface $logger, \phpbb\request\request_interface $request, \phpbb\user $user, \blitze\content\services\types $content_types, \blitze\sitemaker\services\forum\manager $forum_manager, \blitze\content\model\mapper_factory $content_mapper_factory, \blitze\sitemaker\model\mapper_factory $sitemaker_mapper_factory, $auto_refresh = true, $trigger_error = true) |
|
66
|
|
|
{ |
|
67
|
2 |
|
$this->cache = $cache; |
|
68
|
2 |
|
$this->language = $language; |
|
69
|
2 |
|
$this->logger = $logger; |
|
70
|
2 |
|
$this->request = $request; |
|
71
|
2 |
|
$this->user = $user; |
|
72
|
2 |
|
$this->content_types = $content_types; |
|
73
|
2 |
|
$this->forum_manager = $forum_manager; |
|
74
|
2 |
|
$this->content_mapper_factory = $content_mapper_factory; |
|
75
|
2 |
|
$this->sitemaker_mapper_factory = $sitemaker_mapper_factory; |
|
76
|
2 |
|
$this->auto_refresh = $auto_refresh; |
|
77
|
2 |
|
$this->trigger_error = $trigger_error; |
|
78
|
2 |
|
} |
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* @inheritdoc |
|
82
|
|
|
*/ |
|
83
|
2 |
|
public function execute($u_action, $type = '') |
|
84
|
|
|
{ |
|
85
|
2 |
|
if (!check_form_key('delete_content_type')) |
|
86
|
2 |
|
{ |
|
87
|
1 |
|
$this->trigger_error($this->language->lang('FORM_INVALID'), $u_action, E_USER_ERROR); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
1 |
|
$types_mapper = $this->content_mapper_factory->create('types'); |
|
91
|
1 |
|
$entity = $this->content_types->get_type($type); |
|
92
|
|
|
|
|
93
|
1 |
|
$this->delete_content_type_forum($entity->get_forum_id()); |
|
94
|
1 |
|
$this->delete_content_type_blocks($type); |
|
95
|
|
|
|
|
96
|
|
|
// Delete the content type |
|
97
|
1 |
|
$types_mapper->delete($entity); |
|
98
|
1 |
|
$this->cache->destroy('_content_types'); |
|
99
|
|
|
|
|
100
|
1 |
|
$this->logger->add('admin', $this->user->data['user_id'], $this->user->ip, 'ACP_LOG_CONTENT_TYPE_DELETED'); |
|
101
|
|
|
|
|
102
|
1 |
|
$this->meta_refresh(3, $u_action); |
|
103
|
1 |
|
$this->trigger_error($this->language->lang('CONTENT_TYPE_DELETED'), $u_action); |
|
104
|
|
|
|
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
/** |
|
108
|
|
|
* @param int $forum_id |
|
109
|
|
|
* @return void |
|
110
|
|
|
*/ |
|
111
|
1 |
|
protected function delete_content_type_forum($forum_id) |
|
112
|
|
|
{ |
|
113
|
1 |
|
$action_posts = $this->request->variable('action_posts', 'delete'); |
|
114
|
1 |
|
$transfer_to_id = $this->request->variable('transfer_to_id', 0); |
|
115
|
|
|
|
|
116
|
1 |
|
$this->forum_manager->remove($forum_id, $action_posts, 'delete', $transfer_to_id); |
|
117
|
1 |
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @param string $type |
|
121
|
|
|
* @return void |
|
122
|
|
|
*/ |
|
123
|
1 |
|
protected function delete_content_type_blocks($type) |
|
124
|
|
|
{ |
|
125
|
1 |
|
$block_mapper = $this->sitemaker_mapper_factory->create('blocks'); |
|
126
|
1 |
|
$collection = $block_mapper->find(array('name', 'LIKE', 'blitze.content.block%')); |
|
127
|
|
|
|
|
128
|
1 |
|
foreach ($collection as $entity) |
|
129
|
|
|
{ |
|
130
|
1 |
|
$settings = $entity->get_settings(); |
|
131
|
1 |
|
if ($settings['content_type'] === $type) |
|
132
|
1 |
|
{ |
|
133
|
1 |
|
$block_mapper->delete($entity); |
|
134
|
1 |
|
} |
|
135
|
1 |
|
} |
|
136
|
1 |
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths