public function import($fileName) { $this->handleSession($this->session, $fileName); $this->handleSession($this->liveSession, $fileName); $doc = XmlUtils::loadFile($fileName); $xpath = new \DOMXPath($doc); $xpath->registerNamespace('sv', 'http://www.jcp.org/jcr/sv/1.0'); $data = []; /** @var \DOMNode $node */ foreach ($xpath->query('//sv:value[text()="sulu:page"]/../..') as $node) { $parent = $node; $path = ''; do { $path = '/' . XmlUtil::getValueFromXPath('@sv:name', $xpath, $parent) . $path; $parent = $parent->parentNode; } while (XmlUtil::getValueFromXPath('@sv:name', $xpath, $parent) !== 'contents'); $data[] = ['id' => XmlUtil::getValueFromXPath('sv:property[@sv:name="jcr:uuid"]/sv:value', $xpath, $node), 'path' => $path, 'title' => XmlUtil::getValueFromXPath('sv:property[@sv:name="i18n:en-title"]/sv:value', $xpath, $node), 'template' => XmlUtil::getValueFromXPath('sv:property[@sv:name="i18n:en-template"]/sv:value', $xpath, $node), 'url' => XmlUtil::getValueFromXPath('sv:property[@sv:name="i18n:en-url"]/sv:value', $xpath, $node), 'article' => XmlUtil::getValueFromXPath('sv:property[@sv:name="i18n:en-article"]/sv:value', $xpath, $node)]; } return $data; }
/** * Extracts filter type parameters from dom-node. * * @param \DOMXPath $xpath * @param \DOMNode $propertyNode * * @return array */ protected function getFilterTypeParameters(\DOMXPath $xpath, \DOMNode $propertyNode) { $parameters = []; foreach ($xpath->query('x:filter-type-parameters/x:parameter', $propertyNode) as $parameterNode) { $key = XmlUtil::getValueFromXPath('@key', $xpath, $parameterNode); $parameters[$key] = $this->parameterBag->resolveValue(trim($parameterNode->nodeValue)); } return $parameters; }
/** * Extracts data from dom-node to create a new join-metadata object. * * @param \DOMXPath $xpath * @param \DOMElement $joinNode * * @return JoinMetadata */ protected function getJoinMetadata(\DOMXPath $xpath, \DOMElement $joinNode) { $joinMetadata = new JoinMetadata(); if (null !== ($fieldName = XmlUtil::getValueFromXPath('orm:field-name', $xpath, $joinNode))) { $joinMetadata->setEntityField($this->resolveParameter($fieldName)); } if (null !== ($entityName = XmlUtil::getValueFromXPath('orm:entity-name', $xpath, $joinNode))) { $joinMetadata->setEntityName($this->resolveParameter($entityName)); } if (null !== ($condition = XmlUtil::getValueFromXPath('orm:condition', $xpath, $joinNode))) { $joinMetadata->setCondition($this->resolveParameter($condition)); } if (null !== ($conditionMethod = XmlUtil::getValueFromXPath('orm:condition-method', $xpath, $joinNode))) { $joinMetadata->setConditionMethod($this->resolveParameter($conditionMethod)); } if (null !== ($method = XmlUtil::getValueFromXPath('orm:method', $xpath, $joinNode))) { $joinMetadata->setMethod($method); } return $joinMetadata; }