|
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\model\mapper; |
|
11
|
|
|
|
|
12
|
|
|
use blitze\sitemaker\model\base_mapper; |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
class types extends base_mapper |
|
15
|
|
|
{ |
|
16
|
|
|
/** @var string */ |
|
17
|
|
|
protected $entity_class = 'blitze\content\model\entity\type'; |
|
18
|
|
|
|
|
19
|
|
|
/** @var string */ |
|
20
|
|
|
protected $entity_pkey = 'content_id'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* {@inheritdoc} |
|
24
|
|
|
*/ |
|
25
|
3 |
|
public function load(array $condition = array()) |
|
26
|
|
|
{ |
|
27
|
3 |
|
$entity = parent::load($condition); |
|
28
|
|
|
|
|
29
|
|
|
if ($entity) |
|
30
|
3 |
|
{ |
|
31
|
3 |
|
$fields = $this->find_fields($entity->get_content_id()); |
|
32
|
3 |
|
$entity->set_content_fields(array_pop($fields)); |
|
33
|
3 |
|
} |
|
34
|
|
|
|
|
35
|
3 |
|
return $entity; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* {@inheritdoc} |
|
40
|
|
|
*/ |
|
41
|
20 |
|
public function find(array $condition = array()) |
|
42
|
|
|
{ |
|
43
|
20 |
|
parent::find($condition); |
|
44
|
|
|
|
|
45
|
20 |
|
if ($this->collection->count()) |
|
46
|
20 |
|
{ |
|
47
|
20 |
|
$content_fields = $this->find_fields(array_keys($this->collection->get_entities())); |
|
48
|
|
|
|
|
49
|
20 |
|
foreach ($content_fields as $content_id => $fields) |
|
50
|
|
|
{ |
|
51
|
20 |
|
/** @var \blitze\content\model\entity\type $entity */ |
|
52
|
20 |
|
$entity = &$this->collection[$content_id]; |
|
53
|
20 |
|
$entity->set_content_fields($fields); |
|
54
|
|
|
} |
|
55
|
20 |
|
} |
|
56
|
|
|
|
|
57
|
|
|
return $this->collection; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
2 |
|
* {@inheritdoc} |
|
62
|
|
|
*/ |
|
63
|
|
|
public function delete($entity) |
|
64
|
2 |
|
{ |
|
65
|
|
|
/** @var \blitze\content\model\entity\type $entity */ |
|
66
|
2 |
|
parent::delete($entity); |
|
67
|
2 |
|
|
|
68
|
2 |
|
if ($entity instanceof $this->entity_class) |
|
69
|
2 |
|
{ |
|
70
|
2 |
|
$fields_mapper = $this->mapper_factory->create('fields'); |
|
71
|
2 |
|
$fields_mapper->delete(array('content_id', '=', $entity->get_content_id())); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param int|array $content_ids |
|
77
|
22 |
|
* @return array |
|
78
|
|
|
*/ |
|
79
|
22 |
|
protected function find_fields($content_ids) |
|
80
|
22 |
|
{ |
|
81
|
|
|
$fields_mapper = $this->mapper_factory->create('fields'); |
|
82
|
22 |
|
$collection = $fields_mapper->find(array('content_id', '=', $content_ids)); |
|
83
|
22 |
|
|
|
84
|
|
|
$content_fields = array(); |
|
85
|
22 |
|
foreach ($collection as $entity) |
|
86
|
22 |
|
{ |
|
87
|
22 |
|
$content_id = $entity->get_content_id(); |
|
88
|
|
|
$content_fields[$content_id][$entity->get_field_name()] = $entity->to_array(); |
|
89
|
22 |
|
} |
|
90
|
|
|
|
|
91
|
|
|
return $content_fields; |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
|
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