/** * 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']); } }
/** * Compiles the call to a function plugin. * * @param string $pluginClassName Name of the function plugin class * @param \Ableron\Core\Template\TemplateTag $templateTag The template tag to compile * @return string */ private function compileFunctionPluginCall($pluginClassName, TemplateTag $templateTag) { return sprintf('<?php echo $this->getTemplateHandler()->getTemplateFunctionPlugin(\'%s\')->execute($this, %s); ?>', $pluginClassName, $templateTag->getArgumentsAsPhpString()); }
/** * Extracts the path of the parent template file of the given template. * * Returns NULL in case the given template does not has a parent template. * * @param string $template The template to extract the parent template path from * @return string|null */ private function extractParentTemplatePath($template) { // extract template tags from given template $templateTags = $this->templateCompiler->extractTemplateTags($template); // check whether at least one tag has been found if (isset($templateTags[0])) { // get first tag $firstTemplateTag = new TemplateTag($templateTags[0]); // return parent template path in case first tag is an extends-tag if ($firstTemplateTag->getTagName() === 'extends') { return $firstTemplateTag->getArgument(0); } } // given template does not has a parent template return null; }