private function loadTemplateAttributes($resource, \DOMXPath $xpath, $type)
{
if ($type === 'page' || $type === 'home') {
$result = ['key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'internal' => $this->getValueFromXPath('/x:template/x:internal', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath)];
$result = array_filter($result, function ($value) {
return $value !== null;
});
foreach (['key', 'view', 'controller', 'cacheLifetime'] as $requiredProperty) {
if (!isset($result[$requiredProperty])) {
throw new InvalidXmlException($type, sprintf('Property "%s" is required in XML template file "%s"', $requiredProperty, $resource));
}
}
} else {
$result = ['key' => $this->getValueFromXPath('/x:template/x:key', $xpath), 'view' => $this->getValueFromXPath('/x:template/x:view', $xpath), 'controller' => $this->getValueFromXPath('/x:template/x:controller', $xpath), 'cacheLifetime' => $this->loadCacheLifetime('/x:template/x:cacheLifetime', $xpath), 'tags' => $this->loadStructureTags('/x:template/x:tag', $xpath), 'meta' => $this->loadMeta('/x:template/x:meta/x:*', $xpath)];
$result = array_filter($result);
if (count($result) < 1) {
throw new InvalidXmlException($result['key']);
}
}
return $result;
}