示例#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);
 }
示例#2
0
 /**
  * Test the section can be loaded from either legacy or new XML format 
  * 
  * @dataProvider legacyAndNewSectionProvider
  * 
  * @param string $xml new format xml
  * @param string $xml legacy format xml
  */
 public function testActions($newXml, $legacyXml)
 {
     $sectionFromNew = Section::fromSimpleXMLElement(new SimpleXMLElement($newXml));
     $this->assertTrue($sectionFromNew instanceof Section);
     $this->assertEquals(count($sectionFromNew->getActions()), 4);
     $sectionFromLegacy = Section::fromSimpleXMLElement(new SimpleXMLElement($legacyXml));
     $this->assertTrue($sectionFromLegacy instanceof Section);
     $this->assertEquals(count($sectionFromLegacy->getActions()), 4);
     $this->assertEquals(count($sectionFromLegacy->getTrees()), 1);
     $trees = $sectionFromLegacy->getTrees();
     $tree = $trees[0];
     $this->assertTrue($tree instanceof Tree);
     $this->assertFalse(is_null($tree->get('selectClass')));
     $this->assertEquals('edit_class', $tree->get('selectClass'));
 }