Processes a single command

Override this method if you need a different approach.

@param NodeTemplate $nodeTemplate
@param array $data
@return void
@throws \Exception
@api
170750
public function processRecord(NodeTemplate $nodeTemplate, array $data)
    {
        $this->unsetAllNodeTemplateProperties($nodeTemplate);

        $externalIdentifier = $this->getExternalIdentifierFromRecordData($data);
        if (!isset($data['uriPathSegment'])) {
            $data['uriPathSegment'] = Slug::create($this->getLabelFromRecordData($data))->getValue();
        }

        $this->nodeTemplate->setNodeType($this->nodeType);
        $this->nodeTemplate->setName($this->renderNodeName($externalIdentifier));

        if (!isset($data['mode'])) {
            throw new \Exception(sprintf('Could not determine command mode from data record with external identifier %s. Please make sure that "mode" exists in that record.', $externalIdentifier), 1462985246103);
        }

        $commandMethodName = $data['mode'] . 'Command';
        if (!method_exists($this, $commandMethodName)) {
            throw new \Exception(sprintf('Could not find a command method "%s" in %s for processing record with external identifier %s.', $commandMethodName, get_class($this), $externalIdentifier), 1462985425892);
        }

        $this->$commandMethodName($externalIdentifier, $data);
    }
867228
protected function buildTemplateResponseProcessing(DOMElement $data){
        $returnValue = null;

        if($data->hasAttribute('template') && $data->childNodes->length === 0){
            $templateUri = (string) $data->getAttribute('template');
            $returnValue = new Template($templateUri);
        }elseif($data->childNodes->length === 1){

            //check response declaration identifier, which must be RESPONSE in standard rp
            $responses = $this->item->getResponses();
            if(count($responses) == 1){
                $response = reset($responses);
                if($response->getIdentifier() !== 'RESPONSE'){
                    throw new UnexpectedResponseProcessing('the response declaration identifier must be RESPONSE');
                }
            }else{
                //invalid number of response declaration
                throw new UnexpectedResponseProcessing('the item must have exactly one response declaration');
            }

            $patternCorrectIMS = 'responseCondition [count(./*) = 2 ] [name(./*[1]) = "responseIf" ] [count(./responseIf/*) = 2 ] [name(./responseIf/*[1]) = "match" ] [name(./responseIf/match/*[1]) = "variable" ] [name(./responseIf/match/*[2]) = "correct" ] [name(./responseIf/*[2]) = "setOutcomeValue" ] [name(./responseIf/setOutcomeValue/*[1]) = "baseValue" ] [name(./*[2]) = "responseElse" ] [count(./responseElse/*) = 1 ] [name(./responseElse/*[1]) = "setOutcomeValue" ] [name(./responseElse/setOutcomeValue/*[1]) = "baseValue"]';
            $patternMappingIMS = 'responseCondition [count(./*) = 2] [name(./*[1]) = "responseIf"] [count(./responseIf/*) = 2] [name(./responseIf/*[1]) = "isNull"] [name(./responseIf/isNull/*[1]) = "variable"] [name(./responseIf/*[2]) = "setOutcomeValue"] [name(./responseIf/setOutcomeValue/*[1]) = "variable"] [name(./*[2]) = "responseElse"] [count(./responseElse/*) = 1] [name(./responseElse/*[1]) = "setOutcomeValue"] [name(./responseElse/setOutcomeValue/*[1]) = "mapResponse"]';
            $patternMappingPointIMS = 'responseCondition [count(./*) = 2] [name(./*[1]) = "responseIf"] [count(./responseIf/*) = 2] [name(./responseIf/*[1]) = "isNull"] [name(./responseIf/isNull/*[1]) = "variable"] [name(./responseIf/*[2]) = "setOutcomeValue"] [name(./responseIf/setOutcomeValue/*[1]) = "variable"] [name(./*[2]) = "responseElse"] [count(./responseElse/*) = 1] [name(./responseElse/*[1]) = "setOutcomeValue"] [name(./responseElse/setOutcomeValue/*[1]) = "mapResponsePoint"]';
            if(count($this->queryXPath($patternCorrectIMS)) == 1){
                $returnValue = new Template(Template::MATCH_CORRECT);
            }elseif(count($this->queryXPath($patternMappingIMS)) == 1){
                $returnValue = new Template(Template::MAP_RESPONSE);
            }elseif(count($this->queryXPath($patternMappingPointIMS)) == 1){
                $returnValue = new Template(Template::MAP_RESPONSE_POINT);
            }else{
                throw new UnexpectedResponseProcessing('not Template, wrong rule');
            }
            $returnValue->setRelatedItem($this->item);
        }else{
            throw new UnexpectedResponseProcessing('not Template');
        }

        return $returnValue;
    }
13385
static function processNodeTransformationNodes( $tpl, &$node, &$nodes, &$privateData )
    {
        $useComments = $privateData['use-comments'];
        $php =& $privateData['php-creator'];
        $resourceData =& $privateData['resource-data'];
        return eZTemplateCompiler::processNodeTransformationChildren( $useComments, $php, $tpl, $node, $nodes, $resourceData );
    }
166312
protected function processBatch(NodeTemplate $nodeTemplate = null)
    {
        $records = $this->dataProvider->fetch();
        if (!\is_iterable($records)) {
            throw new Exception(sprintf('Expected records as an array while calling %s->fetch(), but returned %s instead.', get_class($this->dataProvider), gettype($records)), 1462960769826);
        }
        $records = $this->preProcessing($records);

        foreach ($records as $data) {
            if (!\is_array($data)) {
                $data = $this->propertyMapper->convert($data, 'array');
            }
            $this->processRecord($nodeTemplate, $data);
            ++$this->processedRecords;
        }

        $this->postProcessing($records);
    }
108247
function executeCompiledTemplate( $tpl, &$textElements,
                                      $keyData, $uri, $resourceData, $templatePath,
                                      &$extraParameters, $timestamp,
                                      $rootNamespace, $currentNamespace )
    {
        $key = $this->cacheKey( $keyData, $resourceData, $templatePath, $extraParameters );
        return eZTemplateCompiler::executeCompilation( $tpl, $textElements, $key, $resourceData,
                                                       $rootNamespace, $currentNamespace );
    }
515510
public function execute(NodeData $node)
    {
        $dimensionValuesToBeAdded = $node->getDimensionValues();

        foreach ($this->dimensionValues as $dimensionName => $dimensionValues) {
            if (!isset($dimensionValuesToBeAdded[$dimensionName])) {
                if (is_array($dimensionValues)) {
                    $dimensionValuesToBeAdded[$dimensionName] = $dimensionValues;
                } else {
                    $dimensionValuesToBeAdded[$dimensionName] = [$dimensionValues];
                }
            }
        }

        if ($this->addDefaultDimensionValues === true) {
            $configuredDimensions = $this->contentDimensionRepository->findAll();
            foreach ($configuredDimensions as $configuredDimension) {
                if (!isset($dimensionValuesToBeAdded[$configuredDimension->getIdentifier()])) {
                    $dimensionValuesToBeAdded[$configuredDimension->getIdentifier()] = [$configuredDimension->getDefault()];
                }
            }
        }

        $dimensionsToBeSet = [];
        foreach ($dimensionValuesToBeAdded as $dimensionName => $dimensionValues) {
            foreach ($dimensionValues as $dimensionValue) {
                $dimensionsToBeSet[] = new NodeDimension($node, $dimensionName, $dimensionValue);
            }
        }

        $node->setDimensions($dimensionsToBeSet);
    }
1081385
protected function render($template, $data = array())
    {
        $view        = null;
        $data        = array_merge_recursive($this->all(), $data);
        $data['app'] = $this->app;
        $template    = $this->resolve($template);


        if (! $template) {
            return;
        }

        if (! $this->layout) {
            $view = $this->make($template, $data);
        } else {
            $view = $this->layout->nest('content', $template, $data);
        }

        return $view;
    }
661535
public function process()
    {
        $this->initializeStorageNode($this->storageNodeNodePath, $this->storageNodeTitle);
        $this->initializeNodeTemplates();

        $nodeTemplate = new NodeTemplate();
        $this->processBatch($nodeTemplate);
    }
182903
public function useTwigTemplate($template, array $data = array())
	{
		$html = $this->renderer->render($template, $data);
		$this->setHtml($html);
		return $this;
	}
1333398
public function deleteEmailTemplate(array $templateData)
    {
        if (!($template = $this->findEmailTemplate($templateData))) {
            throw new Exception("Email template for event {$templateData['EVENT_NAME']} not found");
        }

        $et = new CEventMessage;
        $res = $et->delete($template['ID']);

        if (!$res) {
            throw new Exception("Can't delete template({$template['ID']}) for type {$templateData['EVENT_NAME']}");
        }

        return ["Email template({$template['ID']}) for type {$templateData['EVENT_NAME']} deleted"];
    }
837253
protected function responseTemplate($template, $data = array()){
        
        if(!isset(hubert()->template)){
            throw new \Exception("no template engine installed");
        }
        $html = hubert()->template->render($template, $data);
        $this->_response->getBody()->write($html);
        
        return $this->_response;
        
    }
1308622
public function invoke($node, NodeInterface $parent): void
    {
        if (! $node instanceof Node\Stmt\ClassMethod || ! $parent instanceof InterfaceModelInterface) {
            throw new Exception('MethodNodeParser is made to parse a method node');
        }

        // Retrieve visibility
        $function = new FunctionModel();
        $function->setVisibility(MethodVisibilityHelper::getVisibility($node));

        // If no private / protected methods parsing is required
        if (! $function->isPublic() && ! $this->config->hasPrivateParsing()) {
            return;
        }

        $function->setParentNode($parent);
        $function->setName($node->name);
        $function->setIsFinal($node->isFinal());
        $function->setIsStatic($node->isStatic());
        $function->setIsAbstract($node->isAbstract());

        $this->parseFunction($node, $function);

        $parent->addFunction($function);

        if ($this->autoGetterOrSetter($function, $parent)) {
            return;
        }
        if (($documentation = $node->getDocComment()) !== null) {
            $this->documentationNodeParser->invoke($documentation, $function);
        }
    }
933682
protected function templateToString($template, array $data)
    {

        $templateFullName = $this->getTemplateFullName($template);

        if (!is_file($templateFullName)) {
            throw new RuntimeException("View cannot render `$template` because the template does not exist");
        }

        $fullData = array_merge($this->attributes, $data);
        $this->levelStartObcache = ob_get_level();
        $this->startSection($this->courentSection);
        $this->protectedIncludeScope($templateFullName, $fullData);
        $output = $this->endSection(true);
        $this->sectionContent[self::CONTENT] = $this->sectionContent[self::C_CONTENT];
        unset($this->sectionContent[self::C_CONTENT]);
        while (ob_get_level() > $this->levelStartObcache) {
            ob_end_clean();
        }

        if (!empty($this->layout)) {
            $layout = $this->layout;
            $this->layout = '';
            return $this->templateToString($layout, $fullData);
        }

        return $output;
    }
18643
final public function render($template=null, $data=null)
    {
        $renderType = $this->getRenderType();
        switch ($renderType) {
            case 'json':
                $this->renderJson($data);
                break;
            case 'xml':
                $this->renderXml($data);
                break;
            case 'html':
                $this->renderHtml($template, $data);
                break;
            default:
                $string = print_r($data, true);
                $this->renderText($string);
                break;
        }
        
        return $this->response;
    }
172912
public function apply(NodeInterface $node, array $context)
    {
        $context['node'] = $node;

        // Check if this template should be applied at all
        if (!$this->isApplicable($context)) {
            return;
        }
        $this->setProperties($node, $context);

        // Create child nodes if applicable
        /** @var Template $childNodeTemplate */
        foreach ($this->childNodes as $childNodeTemplate) {
            $childNodeTemplate->createOrFetchAndApply($node, $context);
        }

        $this->emitNodeTemplateApplied($node, $context, $this->options);
    }
1365658
public function setTemplate($templateName, $data = [])
    {
        if (!empty($templateName)) {
            $this->_templateName = $templateName.$this->_suffix;
        }

        if (!empty($data)) {
            if (is_array($data)) {
                $this->_data = array_merge($this->_data, $data);
            } else {
                $this->_data['__data__'] = $data;
            }
        }

        return $this;
    }
356909
public function renderString(string $template, array $data = [])
    {
        try {
            return $this->loadFromString($template)->render($data);
        } catch (SyntaxError $e) {
            if ($this->exceptionHandler) {
                $e->setTemplateContent($template);

                return $this->renderSyntaxError($e);
            } else {
                throw $e;
            }
        }
    }