• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Mapping\ClassMetadataFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中Doctrine\ORM\Mapping\ClassMetadataFactory的典型用法代码示例。如果您正苦于以下问题:PHP ClassMetadataFactory类的具体用法?PHP ClassMetadataFactory怎么用?PHP ClassMetadataFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了ClassMetadataFactory类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: testGetMetadataForSingleClass

 public function testGetMetadataForSingleClass()
 {
     $mockDriver = new MetadataDriverMock();
     $entityManager = $this->_createEntityManager($mockDriver);
     $conn = $entityManager->getConnection();
     $mockPlatform = $conn->getDatabasePlatform();
     $mockPlatform->setPrefersSequences(true);
     $mockPlatform->setPrefersIdentityColumns(false);
     $cm1 = $this->_createValidClassMetadata();
     // SUT
     $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
     $cmf->setEntityManager($entityManager);
     $cmf->setMetadataFor($cm1->name, $cm1);
     // Prechecks
     $this->assertEquals(array(), $cm1->parentClasses);
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType);
     $this->assertTrue($cm1->hasField('name'));
     $this->assertEquals(2, count($cm1->associationMappings));
     $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType);
     $this->assertEquals('group', $cm1->table['name']);
     // Go
     $cmMap1 = $cmf->getMetadataFor($cm1->name);
     $this->assertSame($cm1, $cmMap1);
     $this->assertEquals('group', $cmMap1->table['name']);
     $this->assertTrue($cmMap1->table['quoted']);
     $this->assertEquals(array(), $cmMap1->parentClasses);
     $this->assertTrue($cmMap1->hasField('name'));
 }
开发者ID:naumangcu,项目名称:doctrine2,代码行数:28,代码来源:ClassMetadataFactoryTest.php


示例2: testEmbeddedMappingsWithFalseUseColumnPrefix

 /**
  * @group DDC-3293
  * @group DDC-3477
  * @group 1238
  */
 public function testEmbeddedMappingsWithFalseUseColumnPrefix()
 {
     $factory = new ClassMetadataFactory();
     $em = $this->_getTestEntityManager();
     $em->getConfiguration()->setMetadataDriverImpl($this->_loadDriver());
     $factory->setEntityManager($em);
     $this->assertFalse($factory->getMetadataFor('Doctrine\\Tests\\Models\\DDC3293\\DDC3293User')->embeddedClasses['address']['columnPrefix']);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:13,代码来源:XmlMappingDriverTest.php


示例3: setUp

 public function setUp()
 {
     $this->metadataFactory = $this->getMock(ClassMetadataFactory::class);
     $this->metadataFactory->method('hasMetadataFor')->will($this->returnValueMap([[DummyEntity::class, true], [DummyEmbeddable::class, true]]));
     $this->metadataFactory->method('getMetadataFor')->will($this->returnValueMap([[DummyEntity::class, DummyEntity::getMetadata()], [DummyEmbeddable::class, DummyEmbeddable::getMetadata()]]));
     $em = $this->getMock(EntityManagerInterface::class);
     $em->method('getMetadataFactory')->willReturn($this->metadataFactory);
     $this->entity = new DummyEntity();
     $this->entity->setId(1);
     $this->entity->setA('1a');
     $this->entity->setB('1b');
     $this->entity->setC('1c');
     $d = new DummyEmbeddable();
     $d->setX(1);
     $d->setY(2);
     $d->setZ(3);
     $this->entity->setD($d);
     $child = new DummyEntity();
     $child->setId(2);
     $child->setA('2a');
     $child->setB('2b');
     $child->setC('2c');
     $d = new DummyEmbeddable();
     $d->setX(21);
     $d->setY(22);
     $d->setZ(23);
     $child->setD($d);
     $this->entity->addChild($child);
     $child = new DummyEntity();
     $child->setId(3);
     $child->setA('3a');
     $child->setB('3b');
     $child->setC('3c');
     $d = new DummyEmbeddable();
     $d->setX(31);
     $d->setY(32);
     $d->setZ(33);
     $child->setD($d);
     $this->entity->addChild($child);
     $subchild = new DummyEntity();
     $subchild->setId(4);
     $subchild->setA('4a');
     $subchild->setB('4b');
     $subchild->setC('4c');
     $d = new DummyEmbeddable();
     $d->setX(41);
     $d->setY(42);
     $d->setZ(43);
     $subchild->setD($d);
     $child->addChild($subchild);
     $this->normalizer = new DoctrineNormalizer(null, null, null, $em);
     $propertyNormalizer = new PropertyNormalizer();
     $serializer = new Serializer([$this->normalizer, $propertyNormalizer]);
     $this->normalizer->setSerializer($serializer);
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:55,代码来源:DoctrineNormalizerTest.php


示例4: setUp

 /**
  * @param mixed $classes
  * @return void
  */
 public function setUp()
 {
     $this->doctrine = Zend_Registry::get('container')->getService('doctrine');
     $this->em = $this->doctrine->getEntityManager();
     $this->em->clear();
     $tool = new SchemaTool($this->em);
     $tool->dropDatabase();
     $classes = func_get_args();
     if (!empty($classes)) {
         $metadataFactory = new ClassMetadataFactory();
         $metadataFactory->setEntityManager($this->em);
         $metadataFactory->setCacheDriver(new ArrayCache());
         $metadata = array();
         foreach ((array) $classes as $class) {
             $metadata[] = $metadataFactory->getMetadataFor($class);
         }
         $tool->createSchema($metadata);
     }
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:23,代码来源:RepositoryTestCase.php


示例5: testGetMetadataForSingleClass

 public function testGetMetadataForSingleClass()
 {
     $mockDriver = new MetadataDriverMock();
     $entityManager = $this->_createEntityManager($mockDriver);
     $conn = $entityManager->getConnection();
     $mockPlatform = $conn->getDatabasePlatform();
     $mockPlatform->setPrefersSequences(true);
     $mockPlatform->setPrefersIdentityColumns(false);
     // Self-made metadata
     $cm1 = new ClassMetadata('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $cm1->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
     $cm1->setPrimaryTable(array('name' => '`group`'));
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'name', 'type' => 'varchar'));
     // Add a mapped field
     $cm1->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true));
     // and a mapped association
     $cm1->mapOneToOne(array('fieldName' => 'other', 'targetEntity' => 'TestEntity1', 'mappedBy' => 'this'));
     // and an association on the owning side
     $joinColumns = array(array('name' => 'other_id', 'referencedColumnName' => 'id'));
     $cm1->mapOneToOne(array('fieldName' => 'association', 'targetEntity' => 'TestEntity1', 'joinColumns' => $joinColumns));
     // and an id generator type
     $cm1->setIdGeneratorType(ClassMetadata::GENERATOR_TYPE_AUTO);
     // SUT
     $cmf = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
     $cmf->setEntityManager($entityManager);
     $cmf->setMetadataFor('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1', $cm1);
     // Prechecks
     $this->assertEquals(array(), $cm1->parentClasses);
     $this->assertEquals(ClassMetadata::INHERITANCE_TYPE_NONE, $cm1->inheritanceType);
     $this->assertTrue($cm1->hasField('name'));
     $this->assertEquals(2, count($cm1->associationMappings));
     $this->assertEquals(ClassMetadata::GENERATOR_TYPE_AUTO, $cm1->generatorType);
     $this->assertEquals('group', $cm1->table['name']);
     // Go
     $cmMap1 = $cmf->getMetadataFor('Doctrine\\Tests\\ORM\\Mapping\\TestEntity1');
     $this->assertSame($cm1, $cmMap1);
     $this->assertEquals('group', $cmMap1->table['name']);
     $this->assertTrue($cmMap1->table['quoted']);
     $this->assertEquals(array(), $cmMap1->parentClasses);
     $this->assertTrue($cmMap1->hasField('name'));
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:42,代码来源:ClassMetadataFactoryTest.php


示例6: setUpOrm

 /**
  * Set up entity manager
  *
  * @return Doctrine\ORM\EntityManager
  */
 protected function setUpOrm()
 {
     global $application;
     $doctrine = $application->getBootstrap()->getResource('container')->getService('doctrine');
     $orm = $doctrine->getEntityManager();
     $orm->clear();
     $tool = new SchemaTool($orm);
     $tool->dropDatabase();
     $classes = func_get_args();
     if (!empty($classes)) {
         $metadataFactory = new ClassMetadataFactory();
         $metadataFactory->setEntityManager($orm);
         $metadataFactory->setCacheDriver(new Cache());
         $metadata = array();
         foreach ((array) $classes as $class) {
             $metadata[] = $metadataFactory->getMetadataFor($class);
         }
         $tool->createSchema($metadata);
     }
     return $orm;
 }
开发者ID:nidzix,项目名称:Newscoop,代码行数:26,代码来源:TestCase.php


示例7: remapActions

 private function remapActions(ClassMetadata $metadata, ClassMetadataFactory $metadataFactory)
 {
     $fieldName = 'actions';
     unset($metadata->fieldMappings[$fieldName]);
     unset($metadata->embeddedClasses[$fieldName]);
     // Re-map the embeddable
     $mapping = ['fieldName' => $fieldName, 'class' => $this->actionsClass, 'columnPrefix' => null];
     $metadata->mapEmbedded($mapping);
     // Remove the existing inlined fields
     foreach ($metadata->fieldMappings as $name => $fieldMapping) {
         if (isset($fieldMapping['declaredField']) && $fieldMapping['declaredField'] === $fieldName) {
             unset($metadata->fieldMappings[$name]);
             unset($metadata->fieldNames[$fieldMapping['columnName']]);
         }
     }
     // Re-inline the embeddable
     $embeddableMetadata = $metadataFactory->getMetadataFor($this->actionsClass);
     $metadata->inlineEmbeddable($fieldName, $embeddableMetadata);
 }
开发者ID:gbelmm,项目名称:ACL,代码行数:19,代码来源:ACLMetadataLoader.php


示例8: mapAttributeOnAttributeValue

 /**
  * @param string $attributeClass
  * @param ClassMetadataInfo $metadata
  * @param ClassMetadataFactory $metadataFactory
  */
 private function mapAttributeOnAttributeValue($attributeClass, ClassMetadataInfo $metadata, ClassMetadataFactory $metadataFactory)
 {
     $attributeMetadata = $metadataFactory->getMetadataFor($attributeClass);
     $attributeMapping = ['fieldName' => 'attribute', 'targetEntity' => $attributeClass, 'inversedBy' => 'values', 'joinColumns' => [['name' => 'attribute_id', 'referencedColumnName' => $attributeMetadata->fieldMappings['id']['columnName'], 'nullable' => false, 'onDelete' => 'CASCADE']]];
     $this->mapManyToOne($metadata, $attributeMapping);
 }
开发者ID:loic425,项目名称:Sylius,代码行数:11,代码来源:LoadMetadataSubscriber.php


示例9: getMetadataForSupportedEntities

 /**
  * Returns the metadata for each managed entity.
  *
  * @param ClassMetadataFactory $metadataFactory
  * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata[]
  */
 protected function getMetadataForSupportedEntities(ClassMetadataFactory $metadataFactory)
 {
     $metadata = array();
     foreach ($this->entityClasses as $class) {
         $metadata[] = $metadataFactory->getMetadataFor($class);
     }
     return $metadata;
 }
开发者ID:webfactory,项目名称:doctrine-orm-test-infrastructure,代码行数:14,代码来源:ORMInfrastructure.php


示例10: testQuoteMetadata

 /**
  * @group DDC-1845
  */
 public function testQuoteMetadata()
 {
     $cmf = new ClassMetadataFactory();
     $driver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/Quote/'));
     $em = $this->_createEntityManager($driver);
     $cmf->setEntityManager($em);
     $userMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\Quote\\User');
     $phoneMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\Quote\\Phone');
     $groupMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\Quote\\Group');
     $addressMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\Quote\\Address');
     // Phone Class Metadata
     $this->assertTrue($phoneMetadata->fieldMappings['number']['quoted']);
     $this->assertEquals('phone-number', $phoneMetadata->fieldMappings['number']['columnName']);
     $user = $phoneMetadata->associationMappings['user'];
     $this->assertTrue($user['joinColumns'][0]['quoted']);
     $this->assertEquals('user-id', $user['joinColumns'][0]['name']);
     $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']);
     // User Group Metadata
     $this->assertTrue($groupMetadata->fieldMappings['id']['quoted']);
     $this->assertTrue($groupMetadata->fieldMappings['name']['quoted']);
     $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']);
     $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']);
     $user = $groupMetadata->associationMappings['parent'];
     $this->assertTrue($user['joinColumns'][0]['quoted']);
     $this->assertEquals('parent-id', $user['joinColumns'][0]['name']);
     $this->assertEquals('group-id', $user['joinColumns'][0]['referencedColumnName']);
     // Address Class Metadata
     $this->assertTrue($addressMetadata->fieldMappings['id']['quoted']);
     $this->assertTrue($addressMetadata->fieldMappings['zip']['quoted']);
     $this->assertEquals('address-id', $addressMetadata->fieldMappings['id']['columnName']);
     $this->assertEquals('address-zip', $addressMetadata->fieldMappings['zip']['columnName']);
     $user = $addressMetadata->associationMappings['user'];
     $this->assertTrue($user['joinColumns'][0]['quoted']);
     $this->assertEquals('user-id', $user['joinColumns'][0]['name']);
     $this->assertEquals('user-id', $user['joinColumns'][0]['referencedColumnName']);
     // User Class Metadata
     $this->assertTrue($userMetadata->fieldMappings['id']['quoted']);
     $this->assertTrue($userMetadata->fieldMappings['name']['quoted']);
     $this->assertEquals('user-id', $userMetadata->fieldMappings['id']['columnName']);
     $this->assertEquals('user-name', $userMetadata->fieldMappings['name']['columnName']);
     $address = $userMetadata->associationMappings['address'];
     $this->assertTrue($address['joinColumns'][0]['quoted']);
     $this->assertEquals('address-id', $address['joinColumns'][0]['name']);
     $this->assertEquals('address-id', $address['joinColumns'][0]['referencedColumnName']);
     $groups = $userMetadata->associationMappings['groups'];
     $this->assertTrue($groups['joinTable']['quoted']);
     $this->assertTrue($groups['joinTable']['joinColumns'][0]['quoted']);
     $this->assertEquals('quote-users-groups', $groups['joinTable']['name']);
     $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['name']);
     $this->assertEquals('user-id', $groups['joinTable']['joinColumns'][0]['referencedColumnName']);
     $this->assertTrue($groups['joinTable']['inverseJoinColumns'][0]['quoted']);
     $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['name']);
     $this->assertEquals('group-id', $groups['joinTable']['inverseJoinColumns'][0]['referencedColumnName']);
 }
开发者ID:pnaq57,项目名称:zf2demo,代码行数:57,代码来源:ClassMetadataFactoryTest.php


示例11: testMethodsAndPropertiesAreNotDuplicatedInChildClasses

 /**
  * @group DDC-1590
  */
 public function testMethodsAndPropertiesAreNotDuplicatedInChildClasses()
 {
     $cmf = new ClassMetadataFactory();
     $em = $this->_getTestEntityManager();
     $cmf->setEntityManager($em);
     $ns = $this->_namespace;
     $nsdir = $this->_tmpDir . '/' . $ns;
     $content = str_replace('namespace Doctrine\\Tests\\Models\\DDC1590', 'namespace ' . $ns, file_get_contents(__DIR__ . '/../../Models/DDC1590/DDC1590User.php'));
     $fname = $nsdir . "/DDC1590User.php";
     file_put_contents($fname, $content);
     require $fname;
     $metadata = $cmf->getMetadataFor($ns . '\\DDC1590User');
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     // class DDC1590User extends DDC1590Entity { ... }
     $source = file_get_contents($fname);
     // class _DDC1590User extends DDC1590Entity { ... }
     $source2 = str_replace('class DDC1590User', 'class _DDC1590User', $source);
     $fname2 = $nsdir . "/_DDC1590User.php";
     file_put_contents($fname2, $source2);
     require $fname2;
     // class __DDC1590User { ... }
     $source3 = str_replace('class DDC1590User extends DDC1590Entity', 'class __DDC1590User', $source);
     $fname3 = $nsdir . "/__DDC1590User.php";
     file_put_contents($fname3, $source3);
     require $fname3;
     // class _DDC1590User extends DDC1590Entity { ... }
     $rc2 = new \ReflectionClass($ns . '\\_DDC1590User');
     $this->assertTrue($rc2->hasProperty('name'));
     $this->assertTrue($rc2->hasProperty('id'));
     $this->assertTrue($rc2->hasProperty('created_at'));
     $this->assertTrue($rc2->hasMethod('getName'));
     $this->assertTrue($rc2->hasMethod('setName'));
     $this->assertTrue($rc2->hasMethod('getId'));
     $this->assertFalse($rc2->hasMethod('setId'));
     $this->assertTrue($rc2->hasMethod('getCreatedAt'));
     $this->assertTrue($rc2->hasMethod('setCreatedAt'));
     // class __DDC1590User { ... }
     $rc3 = new \ReflectionClass($ns . '\\__DDC1590User');
     $this->assertTrue($rc3->hasProperty('name'));
     $this->assertFalse($rc3->hasProperty('id'));
     $this->assertFalse($rc3->hasProperty('created_at'));
     $this->assertTrue($rc3->hasMethod('getName'));
     $this->assertTrue($rc3->hasMethod('setName'));
     $this->assertFalse($rc3->hasMethod('getId'));
     $this->assertFalse($rc3->hasMethod('setId'));
     $this->assertFalse($rc3->hasMethod('getCreatedAt'));
     $this->assertFalse($rc3->hasMethod('setCreatedAt'));
 }
开发者ID:selimcr,项目名称:servigases,代码行数:51,代码来源:EntityGeneratorTest.php


示例12: testAddDefaultDiscriminatorMap

 public function testAddDefaultDiscriminatorMap()
 {
     $cmf = new ClassMetadataFactory();
     $driver = $this->createAnnotationDriver(array(__DIR__ . '/../../Models/JoinedInheritanceType/'));
     $em = $this->_createEntityManager($driver);
     $cmf->setEntityManager($em);
     $rootMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\JoinedInheritanceType\\RootClass');
     $childMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\JoinedInheritanceType\\ChildClass');
     $anotherChildMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\JoinedInheritanceType\\AnotherChildClass');
     $rootDiscriminatorMap = $rootMetadata->discriminatorMap;
     $childDiscriminatorMap = $childMetadata->discriminatorMap;
     $anotherChildDiscriminatorMap = $anotherChildMetadata->discriminatorMap;
     $rootClass = 'Doctrine\\Tests\\Models\\JoinedInheritanceType\\RootClass';
     $childClass = 'Doctrine\\Tests\\Models\\JoinedInheritanceType\\ChildClass';
     $anotherChildClass = 'Doctrine\\Tests\\Models\\JoinedInheritanceType\\AnotherChildClass';
     $rootClassKey = array_search($rootClass, $rootDiscriminatorMap);
     $childClassKey = array_search($childClass, $rootDiscriminatorMap);
     $anotherChildClassKey = array_search($anotherChildClass, $rootDiscriminatorMap);
     $this->assertEquals('rootclass', $rootClassKey);
     $this->assertEquals('childclass', $childClassKey);
     $this->assertEquals('anotherchildclass', $anotherChildClassKey);
     $this->assertEquals($childDiscriminatorMap, $rootDiscriminatorMap);
     $this->assertEquals($anotherChildDiscriminatorMap, $rootDiscriminatorMap);
     // ClassMetadataFactory::addDefaultDiscriminatorMap shouldn't be called again, because the
     // discriminator map is already cached
     $cmf = $this->getMock('Doctrine\\ORM\\Mapping\\ClassMetadataFactory', array('addDefaultDiscriminatorMap'));
     $cmf->setEntityManager($em);
     $cmf->expects($this->never())->method('addDefaultDiscriminatorMap');
     $rootMetadata = $cmf->getMetadataFor('Doctrine\\Tests\\Models\\JoinedInheritanceType\\RootClass');
 }
开发者ID:naumangcu,项目名称:doctrine2,代码行数:30,代码来源:ClassMetadataFactoryTest.php


示例13: testAssertTableColumnsAreNotAddedInManyToMany

 /**
  * @group DDC-2109
  */
 public function testAssertTableColumnsAreNotAddedInManyToMany()
 {
     $evm = $this->em->getEventManager();
     $this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', array());
     $this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\TargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\TargetEntity', array());
     $evm->addEventListener(Events::loadClassMetadata, $this->listener);
     $cm = $this->factory->getMetadataFor('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity');
     $meta = $cm->associationMappings['manyToMany'];
     $this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['targetEntity']);
     $this->assertEquals(array('resolvetargetentity_id', 'targetinterface_id'), $meta['joinTableColumns']);
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:14,代码来源:ResolveTargetEntityListenerTest.php


示例14: testResolveTargetEntityListenerCanResolveTargetEntity

 /**
  * @group DDC-1544
  */
 public function testResolveTargetEntityListenerCanResolveTargetEntity()
 {
     $evm = $this->em->getEventManager();
     $this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', array());
     $this->listener->addResolveTargetEntity('Doctrine\\Tests\\ORM\\Tools\\TargetInterface', 'Doctrine\\Tests\\ORM\\Tools\\TargetEntity', array());
     $evm->addEventListener(Events::loadClassMetadata, $this->listener);
     $cm = $this->factory->getMetadataFor('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity');
     $meta = $cm->associationMappings;
     $this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['manyToMany']['targetEntity']);
     $this->assertSame('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', $meta['manyToOne']['targetEntity']);
     $this->assertSame('Doctrine\\Tests\\ORM\\Tools\\ResolveTargetEntity', $meta['oneToMany']['targetEntity']);
     $this->assertSame('Doctrine\\Tests\\ORM\\Tools\\TargetEntity', $meta['oneToOne']['targetEntity']);
 }
开发者ID:dracony,项目名称:forked-php-orm-benchmark,代码行数:16,代码来源:ResolveTargetEntityListenerTest.php


示例15: clear

 /**
  * Clears the EntityManager. All entities that are currently managed
  * by this EntityManager become detached.
  *
  * @param string|null $entityName if given, only entities of this type will get detached
  *
  * @return void
  *
  * @throws ORMInvalidArgumentException                           if a non-null non-string value is given
  * @throws \Doctrine\Common\Persistence\Mapping\MappingException if a $entityName is given, but that entity is not
  *                                                               found in the mappings
  */
 public function clear($entityName = null)
 {
     if (null !== $entityName && !is_string($entityName)) {
         throw ORMInvalidArgumentException::invalidEntityName($entityName);
     }
     $this->unitOfWork->clear(null === $entityName ? null : $this->metadataFactory->getMetadataFor($entityName)->getName());
 }
开发者ID:AdactiveSAS,项目名称:doctrine2,代码行数:19,代码来源:EntityManager.php


示例16: storeCollectionCache

 /**
  * {@inheritdoc}
  */
 public function storeCollectionCache(CollectionCacheKey $key, $elements)
 {
     /* @var $targetPersister CachedEntityPersister */
     $associationMapping = $this->sourceEntity->associationMappings[$key->association];
     $targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName);
     $targetRegion = $targetPersister->getCacheRegion();
     $targetHydrator = $targetPersister->getEntityHydrator();
     // Only preserve ordering if association configured it
     if (!(isset($associationMapping['indexBy']) && $associationMapping['indexBy'])) {
         // Elements may be an array or a Collection
         $elements = array_values(is_array($elements) ? $elements : $elements->getValues());
     }
     $entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements);
     foreach ($entry->identifiers as $index => $entityKey) {
         if ($targetRegion->contains($entityKey)) {
             continue;
         }
         $class = $this->targetEntity;
         $className = ClassUtils::getClass($elements[$index]);
         if ($className !== $this->targetEntity->name) {
             $class = $this->metadataFactory->getMetadataFor($className);
         }
         $entity = $elements[$index];
         $entityEntry = $targetHydrator->buildCacheEntry($class, $entityKey, $entity);
         $targetRegion->put($entityKey, $entityEntry);
     }
     $cached = $this->region->put($key, $entry);
     if ($this->cacheLogger && $cached) {
         $this->cacheLogger->collectionCachePut($this->regionName, $key);
     }
 }
开发者ID:StoshSeb,项目名称:doctrine2,代码行数:34,代码来源:AbstractCollectionPersister.php


示例17: getIdentifierFromArray

 /**
  * @param string $class
  * @param array  $array
  *
  * @return array
  */
 protected function getIdentifierFromArray($class, $array)
 {
     $meta = $this->entityMetadataFactory->getMetadataFor($class);
     $fields = $meta->getIdentifierFieldNames();
     $ids = array();
     foreach ($fields as $field) {
         if (isset($array[$field])) {
             $ids[$field] = $array[$field];
         } else {
             $tmp = $array;
             $parts = explode('.', $field);
             foreach ($parts as $part) {
                 if (isset($tmp[$part])) {
                     if (is_array($tmp[$part])) {
                         $tmp = $tmp[$part];
                     } else {
                         $ids[$field] = $tmp[$part];
                         break;
                     }
                 }
             }
         }
     }
     return $ids;
 }
开发者ID:mihai-stancu,项目名称:serializer,代码行数:31,代码来源:DoctrineNormalizer.php


示例18: storeCollectionCache

 /**
  * {@inheritdoc}
  */
 public function storeCollectionCache(CollectionCacheKey $key, $elements)
 {
     /* @var $targetPersister CachedEntityPersister */
     $targetPersister = $this->uow->getEntityPersister($this->targetEntity->rootEntityName);
     $targetRegion = $targetPersister->getCacheRegion();
     $targetHydrator = $targetPersister->getEntityHydrator();
     $entry = $this->hydrator->buildCacheEntry($this->targetEntity, $key, $elements);
     foreach ($entry->identifiers as $index => $entityKey) {
         if ($targetRegion->contains($entityKey)) {
             continue;
         }
         $class = $this->targetEntity;
         $className = ClassUtils::getClass($elements[$index]);
         if ($className !== $this->targetEntity->name) {
             $class = $this->metadataFactory->getMetadataFor($className);
         }
         $entity = $elements[$index];
         $entityEntry = $targetHydrator->buildCacheEntry($class, $entityKey, $entity);
         $targetRegion->put($entityKey, $entityEntry);
     }
     $cached = $this->region->put($key, $entry);
     if ($this->cacheLogger && $cached) {
         $this->cacheLogger->collectionCachePut($this->regionName, $key);
     }
 }
开发者ID:BozzaCoon,项目名称:SPHERE-Framework,代码行数:28,代码来源:AbstractCollectionPersister.php


示例19: setMetadataFor

 /**
  * {@inheritdoc}
  */
 public function setMetadataFor($className, $class)
 {
     $cacheDriver = $this->getCacheDriver();
     if (null !== $cacheDriver) {
         $cacheDriver->save($className . $this->cacheSalt, $class, null);
     }
     parent::setMetadataFor($className, $class);
 }
开发者ID:northdakota,项目名称:platform,代码行数:11,代码来源:ExtendClassMetadataFactory.php


示例20: testMappedSuperclassIndex

 /**
  * Ensure indexes are inherited from the mapped superclass.
  *
  * @group DDC-3418
  */
 public function testMappedSuperclassIndex()
 {
     $class = $this->cmf->getMetadataFor(__NAMESPACE__ . '\\EntityIndexSubClass');
     /* @var $class ClassMetadataInfo */
     $this->assertArrayHasKey('mapped1', $class->fieldMappings);
     $this->assertArrayHasKey('IDX_NAME_INDEX', $class->table['uniqueConstraints']);
     $this->assertArrayHasKey('IDX_MAPPED1_INDEX', $class->table['uniqueConstraints']);
     $this->assertArrayHasKey('IDX_MAPPED2_INDEX', $class->table['indexes']);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:14,代码来源:BasicInheritanceMappingTest.php



注:本文中的Doctrine\ORM\Mapping\ClassMetadataFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Mapping\ClassMetadataInfo类代码示例发布时间:2022-05-23
下一篇:
PHP Mapping\ClassMetadata类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap