Example #1
0
 /**
  * @param \SimpleXMLElement $node
  * @param $extensionId
  * @return static
  */
 public static function fromSimpleXMLElement(\SimpleXMLElement $node, $extensionId)
 {
     $data = array('id' => (string) $node['id'], 'group' => $node['group'] ? (string) $node['group'] : ($node['visible'] == 'true' ? self::GROUP_DEFAULT : self::GROUP_INVISIBLE), 'name' => (string) $node['name'], 'binding' => isset($node['binding']) ? (string) $node['binding'] : null, 'description' => (string) $node->description, 'extension' => $extensionId, 'level' => (string) $node['level'], 'icon' => isset($node->icon) ? Icon::fromSimpleXMLElement($node->icon, $extensionId) : null);
     $sections = array();
     foreach ($node->xpath("sections/section") as $sectionNode) {
         $sections[] = Section::fromSimpleXMLElement($sectionNode);
     }
     return new static($data, $sections);
 }
 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('name' => (string) $node['name'], 'id' => (string) $node['id'], 'url' => $url, 'binding' => isset($node['binding']) ? (string) $node['binding'] : (isset($node['js']) ? (string) $node['js'] : 'load'), 'context' => (string) $node['context'], 'reload' => isset($node['reload']) ? true : false, 'disabled' => isset($node['disabled']) ? true : false, 'group' => isset($node['group']) ? (string) $node['group'] : self::GROUP_DEFAULT, 'extension' => $extension, 'controller' => $controller, 'action' => $action);
     if (isset($node->icon)) {
         $data['icon'] = Icon::fromSimpleXMLElement($node->icon);
     }
     return new static($data);
 }