/** * Reads the tag arguments based on $this->argumentDefinition. * * @throws \Ableron\Core\Exception\SystemException * @return void */ private function readArguments() { // init arguments map $this->tagArguments = new OrderedMap(); // read arguments foreach ($this->argumentDefinition as $argument) { // determine whether argument value shall be dequoted $dequote = isset($argument['dequoteValue']) ? $argument['dequoteValue'] : true; // check whether argument is set in the template tag if ($this->templateTag->getArguments()->containsKey($argument['name'])) { $this->tagArguments->set($argument['name'], $this->templateTag->getArgument($argument['name'], $dequote)); continue; } // handle shorthand argument if (isset($argument['isShorthandArgument']) && $argument['isShorthandArgument'] && $this->templateTag->getArguments()->containsKey(0)) { $this->tagArguments->set($argument['name'], $this->templateTag->getArgument(0, $dequote)); continue; } // throw exception in case the argument is mandatory but missing if (isset($argument['isMandatory']) && $argument['isMandatory']) { throw new SystemException(sprintf('Missing argument "%s" in tag {%s}', $argument['name'], $this->getTag()->getTagName()), 0, E_USER_ERROR, __FILE__, __LINE__); } // check whether default value is set (use array_key_exists() to make sure default value is recognized even if set to NULL) if (!array_key_exists('defaultValue', $argument)) { throw new SystemException(sprintf('Missing default value for argument "%s" in tag {%s}', $argument['name'], $this->getTag()->getTagName()), 0, E_USER_ERROR, __FILE__, __LINE__); } // use default value as argument value $this->tagArguments->set($argument['name'], $argument['defaultValue']); } }
/** * Returns the block name of the given block tag. * * @param \Ableron\Core\Template\TemplateTag $blockTag The block tag to return the name of * @return string */ private function getBlockName(TemplateTag $blockTag) { return $blockTag->getArguments()->containsKey('name') ? $blockTag->getArgument('name') : $blockTag->getArgument(0); }