/** * @param \SimpleXMLElement $node * @param $structureExtensionId extension of structures.xml * @return static */ public static function fromSimpleXMLElement(\SimpleXMLElement $node, $structureExtensionId) { $url = isset($node['url']) ? (string) $node['url'] : '#'; if ($url == '#' || empty($url)) { $extension = null; $controller = null; $action = null; } else { $parts = explode('/', trim($url, '/')); $parts = array_replace(array_fill(0, 3, null), $parts); list($extension, $controller, $action) = $parts; } $data = array('id' => (string) $node['id'], 'name' => (string) $node['name'], 'url' => $url, 'extension' => $extension, 'controller' => $controller, 'action' => $action, 'binding' => isset($node['binding']) ? (string) $node['binding'] : null, 'policy' => isset($node['policy']) ? (string) $node['policy'] : self::POLICY_MERGE, 'disabled' => isset($node['disabled']) ? true : false); $trees = array(); foreach ($node->xpath("trees/tree") as $treeNode) { $trees[] = Tree::fromSimpleXMLElement($treeNode, $structureExtensionId); } $actions = array(); foreach ($node->xpath("actions/action") as $actionNode) { $actions[] = Action::fromSimpleXMLElement($actionNode, $structureExtensionId); } $includeClassActions = isset($node->actions) && isset($node->actions['allowClassActions']) && $node->actions['allowClassActions'] == 'true'; if ($includeClassActions) { foreach ($trees as $tree) { $rootNodeUri = $tree->get('rootNode'); if (!empty($rootNodeUri)) { $rootNode = new \core_kernel_classes_Class($rootNodeUri); foreach (ClassActionRegistry::getRegistry()->getClassActions($rootNode) as $action) { $actions[] = $action; } } } } return new static($data, $trees, $actions); }
public static function fromSimpleXMLElement(\SimpleXMLElement $node) { $url = isset($node['url']) ? (string) $node['url'] : '#'; if ($url == '#' || empty($url)) { $extension = null; $controller = null; $action = null; } else { list($extension, $controller, $action) = explode('/', trim($url, '/')); } $data = array('id' => (string) $node['id'], 'name' => (string) $node['name'], 'url' => $url, 'extension' => $extension, 'controller' => $controller, 'action' => $action, 'binding' => isset($node['binding']) ? (string) $node['binding'] : null, 'policy' => isset($node['policy']) ? (string) $node['policy'] : self::POLICY_MERGE, 'disabled' => isset($node['disabled']) ? true : false); $trees = array(); foreach ($node->xpath("trees/tree") as $treeNode) { $trees[] = Tree::fromSimpleXMLElement($treeNode); } $actions = array(); foreach ($node->xpath("actions/action") as $actionNode) { $actions[] = Action::fromSimpleXMLElement($actionNode); } return new static($data, $trees, $actions); }