Exemple #1
0
 /**
  * @param $arguments
  * @param TransformationContext $context
  * @return true
  */
 public function call($arguments, TransformationContext $context)
 {
     /** @var string $groupId */
     $groupId = $arguments[0];
     /** @var DOMElement[] $elements */
     $elements = $arguments[1];
     /** @var string $elementId */
     $elementId = $arguments[2];
     /** @var string $groupBy */
     $groupBy = base64_decode($arguments[3]);
     $collection = $this->groups->get($groupId);
     foreach ($elements as $key => $element) {
         $xpath = new DOMXPath($element->ownerDocument);
         $xpath->registerPhpFunctions($context->getPhpFunctions());
         $groupingKey = $xpath->evaluate($this->compiler->compile('string(' . $groupBy . ')', $element), $element);
         $collection->get($groupingKey)->addId($elementId);
     }
     return true;
 }