1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, https://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Metaways Infosystems GmbH, 2011 |
6
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2023 |
7
|
|
|
* @package MW |
8
|
|
|
* @subpackage Tree |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
namespace Aimeos\MW\Tree\Manager; |
13
|
|
|
|
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Abstract tree manager class with basic methods. |
17
|
|
|
* |
18
|
|
|
* @package MW |
19
|
|
|
* @subpackage Tree |
20
|
|
|
*/ |
21
|
|
|
abstract class Base implements \Aimeos\MW\Tree\Manager\Iface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Returns only the requested node |
25
|
|
|
*/ |
26
|
|
|
const LEVEL_ONE = 1; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Returns the requested node and its children |
30
|
|
|
*/ |
31
|
|
|
const LEVEL_LIST = 2; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Returns all subnodes including the requested one |
35
|
|
|
*/ |
36
|
|
|
const LEVEL_TREE = 3; |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
private $readOnly = false; |
40
|
|
|
/** |
41
|
|
|
* Returns the attribute helper functions for searching defined by the manager. |
42
|
|
|
* |
43
|
|
|
* @param \Aimeos\Base\Criteria\Attribute\Iface[] $attributes List of search attribute items |
44
|
|
|
* @return array Associative array of attribute code and helper function |
45
|
|
|
*/ |
46
|
|
|
protected function getSearchFunctions( array $attributes ) : array |
47
|
|
|
{ |
48
|
|
|
$list = []; |
49
|
|
|
$iface = \Aimeos\Base\Criteria\Attribute\Iface::class; |
50
|
|
|
|
51
|
|
|
foreach( $attributes as $key => $item ) |
52
|
|
|
{ |
53
|
|
|
if( $item instanceof $iface ) { |
54
|
|
|
$list[$item->getCode()] = $item->getFunction(); |
55
|
|
|
} else if( isset( $item['code'] ) ) { |
56
|
|
|
$list[$item['code']] = $item['function'] ?? null; |
57
|
|
|
} else { |
58
|
|
|
throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
return $list; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Returns the attribute translations for searching defined by the manager. |
68
|
|
|
* |
69
|
|
|
* @param \Aimeos\Base\Criteria\Attribute\Iface[] $attributes List of search attribute items |
70
|
|
|
* @return array Associative array of attribute code and internal attribute code |
71
|
|
|
*/ |
72
|
|
|
protected function getSearchTranslations( array $attributes ) : array |
73
|
|
|
{ |
74
|
|
|
$translations = []; |
75
|
|
|
$iface = \Aimeos\Base\Criteria\Attribute\Iface::class; |
76
|
|
|
|
77
|
|
|
foreach( $attributes as $key => $item ) |
78
|
|
|
{ |
79
|
|
|
if( $item instanceof $iface ) { |
80
|
|
|
$translations[$item->getCode()] = $item->getInternalCode(); |
81
|
|
|
} else if( isset( $item['code'] ) ) { |
82
|
|
|
$translations[$item['code']] = $item['internalcode']; |
83
|
|
|
} else { |
84
|
|
|
throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
return $translations; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Returns the attribute types for searching defined by the manager. |
94
|
|
|
* |
95
|
|
|
* @param \Aimeos\Base\Criteria\Attribute\Iface[] $attributes List of search attribute items |
96
|
|
|
* @return array Associative array of attribute code and internal attribute type |
97
|
|
|
*/ |
98
|
|
|
protected function getSearchTypes( array $attributes ) : array |
99
|
|
|
{ |
100
|
|
|
$types = []; |
101
|
|
|
$iface = \Aimeos\Base\Criteria\Attribute\Iface::class; |
102
|
|
|
|
103
|
|
|
foreach( $attributes as $key => $item ) |
104
|
|
|
{ |
105
|
|
|
if( $item instanceof $iface ) { |
106
|
|
|
$types[$item->getCode()] = $item->getInternalType(); |
107
|
|
|
} else if( isset( $item['code'] ) ) { |
108
|
|
|
$types[$item['code']] = $item['internaltype']; |
109
|
|
|
} else { |
110
|
|
|
throw new \Aimeos\MW\Common\Exception( sprintf( 'Invalid attribute at position "%1$d"', $key ) ); |
111
|
|
|
} |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
return $types; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Checks, whether a tree is read only. |
120
|
|
|
* |
121
|
|
|
* @return bool True if tree is read-only, false if not |
122
|
|
|
*/ |
123
|
|
|
public function isReadOnly() : bool |
124
|
|
|
{ |
125
|
|
|
return $this->readOnly; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* Sets this manager to read only. |
131
|
|
|
* |
132
|
|
|
* @param bool $flag True if tree is read-only, false if not |
133
|
|
|
*/ |
134
|
|
|
protected function setReadOnly( bool $flag = true ) : Iface |
135
|
|
|
{ |
136
|
|
|
$this->readOnly = (bool) $flag; |
137
|
|
|
return $this; |
138
|
|
|
} |
139
|
|
|
} |
140
|
|
|
|
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