83 return $rootNode->process($entity);
100 $parsedTemplate = preg_split(
'/({=|})/', $template, -1, PREG_SPLIT_DELIM_CAPTURE);
101 while (($token = array_shift($parsedTemplate)) !==
null)
109 elseif ($token !==
"")
132 if (($token = array_shift($parsedTemplate)) !==
null)
134 if (preg_match(
"/^([a-zA-Z0-9_]+\\.[a-zA-Z0-9_.]+)\\s*\$/", $token, $match))
138 elseif (preg_match(
"/^([a-zA-Z0-9_]+)(.*)\$/", $token, $match))
145 while (($token = array_shift($parsedTemplate)) !==
null)
167 $token = ltrim($token,
" \t\n\r");
172 while (($token = array_shift($parsedTemplate)) !==
null)
176 array_unshift($parsedTemplate, $token);
179 elseif ($token ===
"{=")
185 elseif ($token !==
"")
203 if (preg_match_all(
"/
205 [a-zA-Z0-9_]+\\.[a-zA-Z0-9_.]+
209 /x", $token, $wordList)
212 foreach ($wordList[0] as $word)
216 if (preg_match(
"/^([a-zA-Z0-9_]+\\.[a-zA-Z0-9_.]+)\\s*\$/", $word, $match))
222 $node =
new NodeText(trim($word,
'"'));
270 $this->children[] = $child;
282 $this->modifiers = array();
286 $modifierFunction = Functions\Fabric::createInstance(
"lower");
288 $modifierFunction = Functions\Fabric::createInstance(
"translit", array(
289 "replace_space" => mb_substr($mod, 1),
291 $this->modifiers[] = $modifierFunction;
307 foreach ($this->children as $child)
309 $childContent = $child->process($entity);
310 if (is_array($childContent))
311 $content .= implode(
" ", $childContent);
313 $content .= $childContent;
316 foreach ($this->modifiers as $modifier)
318 $node =
new NodeText($content);
319 $arguments = $modifier->onPrepareParameters($entity, array($node));
320 $content = $modifier->calculate($arguments);
392 $entityObject = $entity;
393 $pathToField = explode(
".", $this->entityField);
394 for ($i = 0, $c = count($pathToField)-1; $i < $c; $i++)
396 $entityObject = $entityObject->resolve($pathToField[$i]);
399 return $entityObject->getField($pathToField[$c]);
435 $this->parameters[] = $parameter;
449 $functionObject = Functions\Fabric::createInstance($this->functionName);
450 if ($functionObject instanceof Functions\FunctionBase)
452 $arguments = $functionObject->onPrepareParameters($entity, $this->parameters);
453 return $functionObject->calculate($arguments);
static explodeFunctionArgument($token, NodeFunction $function)
static parseFormula(array &$parsedTemplate)
static parseFunctionArguments($token, array &$parsedTemplate, NodeFunction $function)
static process(Entity\Base $entity, $template)
static parseTemplateTree($template, NodeRoot $parent)
static splitModifiers($modifiers)
static splitTemplate($template)
process(Entity\Base $entity)
process(Entity\Base $entity)
__construct($entityField="")
addParameter(NodeBase $parameter)
process(Entity\Base $entity)
__construct($functionName="")
addChild(NodeBase $child)
process(Entity\Base $entity)