17 class Block implements Layout\ReaderInterface
81 private $conditionReader;
87 private $deprecatedAttributeAcl =
'acl';
112 $this->conditionReader = $conditionReader;
136 switch ($currentElement->getName()) {
170 $data[
'attributes'] = array_merge(
172 [
'visibilityConditions' => $this->conditionReader->parseConditions($currentElement)]
186 $currentElement = $this->replaceDeprecatedAclKey($currentElement);
187 if (isset($elementData[
'attributes'])) {
188 $elementData[
'attributes'] = $this->replaceDeprecatedAclKey($elementData[
'attributes']);
189 $keys = array_keys($elementData[
'attributes']);
190 foreach ($keys as $key) {
191 if (isset($currentElement[$key])) {
192 $elementData[
'attributes'][$key] = (string)$currentElement[$key];
196 $elementData[
'attributes'] = [
197 self::ATTRIBUTE_CLASS => (string)$currentElement[self::ATTRIBUTE_CLASS],
199 self::ATTRIBUTE_TEMPLATE => (string)$currentElement[self::ATTRIBUTE_TEMPLATE],
201 self::ATTRIBUTE_DISPLAY => (string)$currentElement[self::ATTRIBUTE_DISPLAY],
205 return $elementData[
'attributes'];
215 private function replaceDeprecatedAclKey(
$data)
217 if (isset(
$data[$this->deprecatedAttributeAcl])) {
236 $elementRemove = filter_var($currentElement->
getAttribute(
'remove'), FILTER_VALIDATE_BOOLEAN);
237 if ($elementRemove) {
259 $actions = $this->getActions($currentElement);
262 ? array_merge(
$data[
'actions'], $actions)
264 $data[
'arguments'] = isset(
$data[
'arguments'])
279 foreach ($this->attributes as $attributeName) {
291 protected function getActions(
Element $blockElement)
295 foreach ($this->getElementsByType($blockElement, self::TYPE_ACTION) as $actionElement) {
296 $configPath = $actionElement->getAttribute(
'ifconfig');
297 $methodName = $actionElement->getAttribute(
'method');
299 $actions[] = [$methodName, $actionArguments, $configPath,
$this->scopeType];
312 $arguments = $this->getElementsByType($blockElement, self::TYPE_ARGUMENTS);
315 return $argumentElement ? $this->
parseArguments($argumentElement) : [];
329 foreach (
$element as $childElement) {
330 if ($childElement->getName() ===
$type) {
331 $elements[] = $childElement;
345 $nodeDom = dom_import_simplexml($node);
347 foreach ($nodeDom->childNodes as $argumentNode) {
348 if ($argumentNode instanceof \DOMElement && $argumentNode->nodeName ==
'argument') {
349 $argumentName = $argumentNode->getAttribute(
'name');
350 $result[$argumentName] = $this->argumentParser->parse($argumentNode);
366 foreach (
$arguments as $argumentName => $argumentData) {
367 if (isset($argumentData[
'updater'])) {
370 $result = $this->argumentInterpreter->evaluate($argumentData);
372 $data[
'arguments'][$argumentName] = isset(
$data[
'arguments'][$argumentName])
373 ? array_replace_recursive(
$data[
'arguments'][$argumentName],
$result)
getArguments(Element $blockElement)
scheduleBlock(ScheduledStructure $scheduledStructure, Element $currentElement)
elseif(isset( $params[ 'redirect_parent']))
setStructureElementData($elementName, array $data)
parseArguments(Element $node)
evaluateArguments(Element $blockElement, array &$data)
unsetElementFromListToRemove($elementName)
getStructureElementData($elementName, $default=null)
setElementToRemoveList($elementName)
const TYPE_REFERENCE_BLOCK
scheduleReference(ScheduledStructure $scheduledStructure, Element $currentElement)
updateScheduledData($currentElement, array &$data)
interpret(Context $readerContext, Element $currentElement)
mergeBlockAttributes(array $elementData, Element $currentElement)
__construct(Layout\ScheduledStructure\Helper $helper, Layout\Argument\Parser $argumentParser, Layout\ReaderPool $readerPool, InterpreterInterface $argumentInterpreter, Condition $conditionReader, $scopeType=null)
getAttributes(Element $blockElement)