98 public function listAction($iblock, $select = [
'*'], $filter = [], $order = [],
PageNavigation $pageNavigation =
null)
214 $propertyEntityAllowedList = static::getPropertyEntityAllowedList();
215 $elementEntityAllowedList = static::getElementEntityAllowedList();
216 $allowedList = array_merge($elementEntityAllowedList, static::getAllowedList());
219 $chainReplacement = [];
222 foreach ($fields as $definition)
225 if (in_array($definition, $allowedList,
true))
231 $chain = Chain::getChainByDefinition($entity, $definition);
232 $currentDefinition =
'';
234 $elements = $chain->getAllElements();
235 $lastElement = $chain->getLastElement();
237 foreach ($elements as $element)
239 $isLastElement = ($element === $lastElement);
242 if ($element->getValue() instanceof
ElementEntity && !$isLastElement)
251 if ($currentDefinition ===
'*' && $isLastElement)
253 $chainReplacement[$definition] = [];
255 foreach ($elementEntityAllowedList as $allowedFieldName)
257 if ($entity->
hasField($allowedFieldName))
259 $chainReplacement[$definition][] = $allowedFieldName;
267 if (!($element->getValue() instanceof
Field))
270 sprintf(
'Restricted field `%s`', $currentDefinition)
274 $currentField = $element->getValue();
275 $currentEntity = $currentField->getEntity();
281 if (in_array($currentField->getName(), $elementEntityAllowedList,
true))
287 if (!empty(class_uses($currentField)[PropertyRelation::class]))
292 $propEntity = $currentField->getRefEntity();
293 $chainReplacement[$definition] = [];
295 foreach ($propertyEntityAllowedList as $allowedFieldName)
297 if ($propEntity->hasField($allowedFieldName))
312 if (in_array($currentField->getName(), $propertyEntityAllowedList,
true))
320 $refEntity = $currentField->getRefEntity();
328 $chainReplacement[$definition] = [];
330 foreach ($elementEntityAllowedList as $allowedFieldName)
332 if ($refEntity->hasField($allowedFieldName))
346 sprintf(
'Restricted field `%s`', $currentDefinition)
352 foreach ($chainReplacement as $definition => $replacement)
355 $key = array_search($definition, $fields);
356 unset($fields[$key]);
359 $fields = array_merge($fields, $replacement);