Doctrine\ODM\PHPCR\Mapping\ClassMetadata::newInstance PHP Method

newInstance() public method

Creates a new instance of the mapped class, without invoking the constructor.
public newInstance ( ) : object
return object
    public function newInstance()
    {
        if (!$this->instantiator instanceof InstantiatorInterface) {
            $this->instantiator = new Instantiator();
        }
        return $this->instantiator->instantiate($this->name);
    }

Usage Example

Ejemplo n.º 1
0
 /**
  * @depends testMapField
  */
 public function testNewInstance(ClassMetadata $cm)
 {
     $instance1 = $cm->newInstance();
     $instance2 = $cm->newInstance();
     $this->assertInstanceOf('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person', $instance1);
     $this->assertNotSame($instance1, $instance2);
 }
ClassMetadata