Example #1
0
 public static function parse(\DOMNode $node)
 {
     if ($node->nodeName == self::getNodeName()) {
         $actions = new ActionList();
         foreach (XMLUtils::getChildrenByName($node, AbstractAction::getNodeName()) as $action) {
             $actions->add(AbstractAction::parse($action));
         }
         return new Target(XMLUtils::getAttributeByName($node, "name")->nodeValue, Uri::fromString(XMLUtils::getChildByName($node, "uri")->nodeValue), $actions, AbstractView::parse(XMLUtils::getChildByName($node, AbstractView::getNodeName())));
     }
     throw new \Exception("Unexpected node '" . $node->nodeName . "', expected '" . self::getNodeName() . "'");
 }
Example #2
0
 public static function parse(\DOMNode $node)
 {
     if ($node->nodeName == self::getNodeName()) {
         $path = XMLUtils::getChildByName($node, "path");
         $requirements = array();
         if (($require = XMLUtils::getAttributeByName($node, "require")) != null) {
             foreach (explode(",", $require->nodeValue) as $requirement) {
                 $requirements[] = trim($requirement);
             }
         }
         try {
             $reflection = new \ReflectionClass($path->nodeValue);
             $instance = $reflection->newInstance(XMLUtils::getAttributeByName($node, "name")->nodeValue, $requirements);
             if ($instance instanceof AbstractAction) {
                 return $instance;
             }
             throw new \Exception("The class '" . $path->nodeValue . "' must be a subclass of AbstractAction");
         } catch (\ReflectionException $re) {
             throw new \Exception("No class found for '" . $path->nodeValue . "'");
         }
     }
     throw new \Exception("Unexpected node '" . $node->nodeName . "', expected '" . self::getNodeName() . "'");
 }