setChildClasses() public method

Set the class names or interfaces that children of this document must be instance of.
public setChildClasses ( array $childClasses )
$childClasses array
示例#1
0
 /**
  * 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);
 }
示例#2
0
 private function unrestrictChildClass(string $class, ClassMetadata $metadata)
 {
     if (!$class) {
         return;
     }
     if (!($childClasses = $metadata->getChildClasses())) {
         return;
     }
     $childClasses[] = $class;
     $metadata->setChildClasses($childClasses);
 }