예제 #1
0
 public function testXmlSerializationRoundtrip()
 {
     $config = new ymcPipeBasicNodeConfigurationMock();
     $config->setPropertiesTestHelper(array('eins' => 'zwei', 3 => 4, 'fuenf' => 6, 7 => 'acht', 'neun' => false, 'zehn' => true, 'float' => 6.78, 'sub' => array('hi' => 'du', 'subi' => array())));
     $document = new DOMDocument();
     $document->formatOutput = true;
     $elem = $document->createElement('config');
     $config->serializeToXml($elem);
     $document->appendChild($elem);
     $newConfig = ymcPipeNodeConfiguration::unserializeFromXml($elem);
     $this->assertEquals($config, $newConfig);
 }
예제 #2
0
파일: node.php 프로젝트: jou/ymc-components
 /**
  * Unserializes and returns a node from the given DOMElement.
  * 
  * @param DOMElement $element Where to fetch the node from.
  * @param ymcPipe    $pipe    The pipe is forwarded to the node's ctor.
  * @return ymcPipeNode
  */
 public static function unserializeFromXml(DOMElement $element, ymcPipe $pipe)
 {
     $className = $element->getAttribute('node-class');
     if (!class_exists($className)) {
         throw new ymcPipeNodeException("Class {$className} not found.");
     }
     $name = $element->getAttribute('name');
     $configurationNode = $element->getElementsByTagName('configuration');
     if ($configurationNode->length === 0) {
         return new $className($pipe, $name);
     } else {
         $configurationNode = $configurationNode->item(0);
         $configuration = ymcPipeNodeConfiguration::unserializeFromXml($configurationNode);
         return new $className($pipe, $name, $configuration);
     }
 }
 public function __construct($properties = array(), $definition = array())
 {
     $this->_definition = $definition;
     parent::__construct($properties);
 }