|
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; |
|
11
|
|
|
|
|
12
|
|
|
class types |
|
13
|
|
|
{ |
|
14
|
|
|
/** @var \phpbb\cache\driver\driver_interface */ |
|
15
|
|
|
protected $cache; |
|
16
|
|
|
|
|
17
|
|
|
/** @var \blitze\content\model\mapper_factory */ |
|
18
|
|
|
protected $mapper_factory; |
|
19
|
|
|
|
|
20
|
|
|
/* @var array */ |
|
21
|
|
|
protected $content_forums; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Construct |
|
25
|
|
|
* |
|
26
|
|
|
* @param \phpbb\cache\driver\driver_interface $cache Cache object |
|
27
|
|
|
* @param \blitze\content\model\mapper_factory $mapper_factory Mapper factory object |
|
28
|
|
|
*/ |
|
29
|
20 |
|
public function __construct(\phpbb\cache\driver\driver_interface $cache, \blitze\content\model\mapper_factory $mapper_factory) |
|
30
|
|
|
{ |
|
31
|
20 |
|
$this->cache = $cache; |
|
32
|
20 |
|
$this->mapper_factory = $mapper_factory; |
|
33
|
20 |
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Get all content types |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $mode data|forums |
|
39
|
|
|
* @return array |
|
40
|
|
|
*/ |
|
41
|
19 |
|
public function get_all_types($mode = 'data') |
|
42
|
|
|
{ |
|
43
|
19 |
|
if (($types_data = $this->cache->get('_content_types')) === false) |
|
44
|
19 |
|
{ |
|
45
|
19 |
|
$types_mapper = $this->mapper_factory->create('types'); |
|
46
|
19 |
|
$collection = $types_mapper->find(); |
|
47
|
|
|
|
|
48
|
|
|
$types_data = array( |
|
49
|
19 |
|
'forums' => array(), |
|
50
|
19 |
|
'data' => array(), |
|
51
|
19 |
|
); |
|
52
|
|
|
|
|
53
|
19 |
|
foreach ($collection as $entity) |
|
54
|
|
|
{ |
|
55
|
|
|
/** @var \blitze\content\model\entity\type $entity */ |
|
56
|
19 |
|
$forum_id = $entity->get_forum_id(); |
|
57
|
19 |
|
$content_name = $entity->get_content_name(); |
|
58
|
|
|
|
|
59
|
19 |
|
$types_data['forums'][$forum_id] = $content_name; |
|
60
|
19 |
|
$types_data['data'][$content_name] = $entity; |
|
61
|
19 |
|
} |
|
62
|
|
|
|
|
63
|
|
|
// we do not cache while in acp to avoid bad relative paths |
|
64
|
19 |
|
if (!defined('ADMIN_START')) |
|
65
|
19 |
|
{ |
|
66
|
19 |
|
$this->cache->put('_content_types', $types_data); |
|
67
|
19 |
|
} |
|
68
|
19 |
|
} |
|
69
|
19 |
|
return $types_data[$mode]; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get content type |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $type |
|
76
|
|
|
* @param bool $trigger_error |
|
77
|
|
|
* @return false|\blitze\content\model\entity\type |
|
78
|
|
|
* @throws \blitze\sitemaker\exception\out_of_bounds |
|
79
|
|
|
*/ |
|
80
|
10 |
|
public function get_type($type, $trigger_error = true) |
|
81
|
|
|
{ |
|
82
|
10 |
|
$content_data = $this->get_all_types(); |
|
83
|
|
|
|
|
84
|
10 |
|
if (!isset($content_data[$type])) |
|
85
|
10 |
|
{ |
|
86
|
|
|
if ($trigger_error) |
|
87
|
3 |
|
{ |
|
88
|
2 |
|
throw new \blitze\sitemaker\exception\out_of_bounds($type); |
|
|
|
|
|
|
89
|
|
|
} |
|
90
|
|
|
else |
|
91
|
|
|
{ |
|
92
|
1 |
|
return false; |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
7 |
|
return $content_data[$type]; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Content type exists |
|
101
|
|
|
* |
|
102
|
|
|
* @param string $type |
|
103
|
|
|
* @return bool |
|
104
|
|
|
*/ |
|
105
|
6 |
|
public function exists($type) |
|
106
|
|
|
{ |
|
107
|
6 |
|
$content_data = $this->get_all_types(); |
|
108
|
6 |
|
return (isset($content_data[$type])); |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
/** |
|
112
|
|
|
* Get content type from forum_id |
|
113
|
|
|
* @param int $forum_id |
|
114
|
|
|
* @return string|false |
|
115
|
|
|
*/ |
|
116
|
1 |
|
public function get_forum_type($forum_id) |
|
117
|
|
|
{ |
|
118
|
1 |
|
$content_data = $this->get_all_types('forums'); |
|
119
|
1 |
|
return isset($content_data[$forum_id]) ? $content_data[$forum_id] : false; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* Get all content types by forum_id |
|
124
|
|
|
* @return array |
|
125
|
|
|
*/ |
|
126
|
1 |
|
public function get_forum_types() |
|
127
|
|
|
{ |
|
128
|
1 |
|
return $this->get_all_types('forums'); |
|
129
|
|
|
} |
|
130
|
|
|
} |
|
131
|
|
|
|
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