44 private $excludedFields;
92 $this->sources = $sources;
94 $this->rules = $rules;
103 public function get(
$path =
'')
108 if (isset($this->data[
$path])) {
109 return $this->data[
$path];
112 $this->sortSources();
114 foreach ($this->sources as $sourceConfig) {
116 $source = $sourceConfig[
'source'];
117 $data = array_replace_recursive($data,
$source->get(
$path));
120 $this->excludedFields = [];
121 $this->filterChain(
$path, $data);
123 return $this->data[
$path] = $data;
133 private function filterChain(
$path, &$data)
135 foreach ($data as $subKey => &$subData) {
136 $newPath =
$path ?
$path .
'/' . $subKey : $subKey;
137 $filteredPath = $this->filterPath($newPath);
139 if (is_array($subData)) {
140 $this->filterChain($newPath, $subData);
141 }
elseif ($this->isExcludedPath($filteredPath)) {
142 $this->excludedFields[$newPath] = $filteredPath;
143 unset($data[$subKey]);
146 if (empty($subData) && isset($data[$subKey]) && is_array($data[$subKey])) {
147 unset($data[$subKey]);
158 private function isExcludedPath(
$path)
164 $defaultRule = isset($this->rules[
'default']) ?
168 if (
$type ===
'default') {
172 if ($this->typePool->isPresent(
$path,
$type)) {
186 private function filterPath(
$path)
188 $parts = explode(
'/',
$path);
191 if (count($parts) < 3) {
198 unset($parts[0], $parts[1]);
201 return implode(
'/', $parts);
209 private function sortSources()
211 uasort($this->sources,
function ($firstItem, $secondItem) {
212 return $firstItem[
'sortOrder'] > $secondItem[
'sortOrder'];
224 $fields = array_values($this->excludedFields);
__construct(ExcludeList $excludeList, array $sources=[], TypePool $typePool=null, array $rules=[])
elseif(isset( $params[ 'redirect_parent']))