Example #1
0
 /**
  * Creates a procedure from a definition.
  *
  * Procedure definition must be an array consisting of following elements:
  *   * name : string
  *   * sources : array of source adapters
  *   * workers : array of workers
  *   * targets : array of target adapters
  *
  * @param array     $definition Procedure definition (how a procedure should be built)
  * @param Procedure $parent     Parent procedure
  *
  * @return Procedure
  */
 public static function createFromDefinition(array $definition, Procedure $parent = null)
 {
     $procedure = new self($definition['name'], $definition['sources'], $definition['workers'], $definition['targets'], $parent);
     foreach ($definition['children'] as $child) {
         $procedure->addChild(self::createFromDefinition($child, $procedure));
     }
     return $procedure;
 }
Example #2
0
 public static function fromXML($type, $xml)
 {
     $obj = new self($type);
     foreach ($xml->attributes() as $k => $v) {
         $obj->addAttr($k, $v);
     }
     foreach ($xml as $k => $v) {
         $obj->addChild($k, ResponseObj::fromXML($k, $v));
     }
     return $obj;
 }
Example #3
0
 /**
  * Create a node from an array
  *
  * Usage example:
  * <code>
  *   $n= Node::fromArray($array, 'elements');
  * </code>
  *
  * @param   array arr
  * @param   string name default 'array'
  * @return  xml.Node
  */
 public static function fromArray($a, $name = 'array')
 {
     $n = new self($name);
     $sname = rtrim($name, 's');
     foreach (array_keys($a) as $field) {
         $nname = is_numeric($field) || '' == $field ? $sname : $field;
         if (is_array($a[$field])) {
             $n->addChild(self::fromArray($a[$field], $nname));
         } else {
             if ($a[$field] instanceof String) {
                 $n->addChild(new self($nname, $a[$field]));
             } else {
                 if (is_object($a[$field])) {
                     $n->addChild(self::fromObject($a[$field], $nname));
                 } else {
                     $n->addChild(new self($nname, $a[$field]));
                 }
             }
         }
     }
     return $n;
 }
Example #4
0
 /**
  * @param string $name
  * @param string $text
  * @return PPNode_Hash_Tree
  */
 public static function newWithText($name, $text)
 {
     $obj = new self($name);
     $obj->addChild(new PPNode_Hash_Text($text));
     return $obj;
 }