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

setChildClasses() public method

Set the class names or interfaces that children of this document must be instance of.
public setChildClasses ( array $childClasses )
$childClasses array
    public function setChildClasses(array $childClasses)
    {
        $this->childClasses = $childClasses;
    }

Usage Example

 /**
  * It should throw an exception if the given class is not allowed.
  *
  * @expectedException \Doctrine\ODM\PHPCR\Exception\OutOfBoundsException
  * @expectedExceptionMessage does not allow children of type "stdClass"
  */
 public function testAssertValidChildClassesNotAllowed()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person');
     $cm->initializeReflection(new RuntimeReflectionService());
     $childCm = new ClassMetadata('stdClass');
     $childCm->initializeReflection(new RuntimeReflectionService());
     $cm->setChildClasses(array('Doctrine\\Tests\\ODM\\PHPCR\\Mapping\\Person'));
     $cm->assertValidChildClass($childCm);
 }
All Usage Examples Of Doctrine\ODM\PHPCR\Mapping\ClassMetadata::setChildClasses
ClassMetadata