setNodeType() публичный Метод

public setNodeType ( string $nodeType )
$nodeType string
 /**
  * Verify that no exception results from a correctly-mapped set
  * of documents.
  */
 public function testCheckNodeTypeMappingsWithoutDuplicate()
 {
     $metadataA = new ClassMetadata('Doctrine\\PHPCR\\Models\\ClassA');
     $metadataA->setNodeType('nt:unstructured');
     $metadataB = new ClassMetadata('Doctrine\\PHPCR\\Models\\ClassB');
     $metadataB->setNodeType('custom:type');
     $metadataB->setUniqueNodeType(true);
     $metadataC = new ClassMetadata('Doctrine\\PHPCR\\Models\\ClassC');
     $metadataA->setNodeType('nt:unstructured');
     $documentManager = $this->configureDocumentManager(array($metadataA, $metadataB, $metadataC));
     $uniqueNodeTypeHelper = new UniqueNodeTypeHelper();
     $uniqueNodeTypeHelper->checkNodeTypeMappings($documentManager);
 }
Пример #2
0
 /**
  * Adds inherited fields to the subclass mapping.
  *
  * @param ClassMetadata $subClass
  * @param ClassMetadata $parentClass
  */
 private function addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass)
 {
     foreach ($parentClass->fieldMappings as $fieldName) {
         $subClass->mapField($parentClass->mappings[$fieldName], $parentClass);
     }
     foreach ($parentClass->referenceMappings as $fieldName) {
         $mapping = $parentClass->mappings[$fieldName];
         if ($mapping['type'] == ClassMetadata::MANY_TO_ONE) {
             $subClass->mapManyToOne($mapping, $parentClass);
         } else {
             $subClass->mapManyToMany($mapping, $parentClass);
         }
     }
     foreach ($parentClass->childMappings as $fieldName) {
         $mapping = $parentClass->mappings[$fieldName];
         $subClass->mapChild($mapping, $parentClass);
     }
     foreach ($parentClass->childrenMappings as $fieldName) {
         $subClass->mapChildren($parentClass->mappings[$fieldName], $parentClass);
     }
     foreach ($parentClass->referrersMappings as $fieldName) {
         $subClass->mapReferrers($parentClass->mappings[$fieldName], $parentClass);
     }
     if ($parentClass->identifier) {
         $subClass->mapId($parentClass->mappings[$parentClass->identifier], $parentClass);
     }
     if ($parentClass->node) {
         $subClass->mapNode($parentClass->mappings[$parentClass->node], $parentClass);
     }
     if ($parentClass->nodename) {
         $subClass->mapNodename($parentClass->mappings[$parentClass->nodename], $parentClass);
     }
     if ($parentClass->parentMapping) {
         $subClass->mapParentDocument($parentClass->mappings[$parentClass->parentMapping], $parentClass);
     }
     if ($parentClass->localeMapping) {
         $subClass->mapLocale($parentClass->mappings[$parentClass->localeMapping], $parentClass);
     }
     if ($parentClass->versionNameField) {
         $subClass->mapVersionName($parentClass->mappings[$parentClass->versionNameField], $parentClass);
     }
     if ($parentClass->versionCreatedField) {
         $subClass->mapVersionCreated($parentClass->mappings[$parentClass->versionCreatedField], $parentClass);
     }
     if ($parentClass->lifecycleCallbacks) {
         $subClass->mapLifecycleCallbacks($parentClass->lifecycleCallbacks);
     }
     $subClass->setReferenceable($parentClass->referenceable);
     // Versionable defaults to false - only set on child class if it is non-false
     if ($parentClass->versionable) {
         $subClass->setVersioned($parentClass->versionable);
     }
     $subClass->setTranslator($parentClass->translator);
     $subClass->setNodeType($parentClass->nodeType);
     $subClass->setCustomRepositoryClassName($parentClass->customRepositoryClassName);
 }
Пример #3
0
 public function testClassMetadataInstanceSerialization()
 {
     $cm = new ClassMetadata('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     // Test initial state
     $this->assertTrue(count($cm->getReflectionProperties()) == 0);
     $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals(array(), $cm->parentClasses);
     $this->assertEquals(0, count($cm->referenceMappings));
     // Customize state
     $cm->setParentClasses(array("UserParent"));
     $cm->setCustomRepositoryClassName("CmsUserRepository");
     $cm->setNodeType('foo:bar');
     $cm->mapManyToOne(array('fieldName' => 'address', 'targetDocument' => 'CmsAddress', 'mappedBy' => 'foo'));
     $this->assertEquals(1, count($cm->referenceMappings));
     $serialized = serialize($cm);
     /** @var ClassMetadata $cm */
     $cm = unserialize($serialized);
     $cm->wakeupReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     // Check state
     $this->assertTrue(count($cm->getReflectionProperties()) > 0);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS', $cm->namespace);
     $this->assertInstanceOf('ReflectionClass', $cm->reflClass);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUser', $cm->name);
     $this->assertEquals(array('UserParent'), $cm->parentClasses);
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsUserRepository', $cm->customRepositoryClassName);
     $this->assertEquals('foo:bar', $cm->getNodeType());
     $this->assertEquals(ClassMetadata::MANY_TO_ONE, $cm->getTypeOfField('address'));
     $this->assertEquals(1, count($cm->referenceMappings));
     $this->assertTrue($cm->hasAssociation('address'));
     $this->assertEquals('Doctrine\\Tests\\Models\\CMS\\CmsAddress', $cm->getAssociationTargetClass('address'));
 }