/** * @param DOMDocument $document */ public function transpile(DOMDocument $document) { $root = $document->documentElement; if ($root === null) { return; } $transformers = $this->context->getTransformers(); foreach ($transformers as $transformer) { $transformer->transform($document); } if ($root && $root->getAttribute('version') === '2.0') { $root->setAttribute('version', '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; }