/**
  *
  */
 protected function initialize()
 {
     if ($this->initialized) {
         return;
     }
     $this->initialized = true;
     if ($this->definition->isArray()) {
         $this->collection =& $this->definition->extract($this->origin);
     }
     if ($this->definition->isObject()) {
         $this->object =& $this->definition->extract($this->origin);
         if ($this->object === null) {
             $this->object = $this->definition->create($this->origin);
         }
     }
 }
Example #2
0
 /**
  * @param \XMLWriter $writer
  * @param mixed      $origin
  * @param Definition $definition
  */
 protected function writeScalar(\XMLWriter $writer, $origin, Definition $definition)
 {
     $content = $definition->extract($origin);
     if (strpbrk($content, '></&![]\\') === false) {
         $writer->writeRaw($content);
     } else {
         $writer->writeCdata($content);
     }
 }
 public function testExtractNormalize()
 {
     $object = $this->getDocument();
     $transformer = $this->getTransformerMock();
     $transformer->expects($this->once())->method('normalize')->with('baz')->will($this->returnValue('foo'));
     $accessor = $this->getAccessorMock();
     $accessor->expects($this->once())->method('getValue')->with($object, 'path')->will($this->returnValue('baz'));
     $definition = new Definition();
     $definition->setPropertyAccessor($accessor);
     $definition->setPropertyPath('path');
     $definition->setTransformer($transformer);
     $this->assertEquals('foo', $definition->extract($object));
 }