当前位置: 首页>>代码示例>>PHP>>正文


PHP ClassMetadataFactory::setEntityManager方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     $annotationDriver = $this->createAnnotationDriver();
     $this->em = $this->_getTestEntityManager();
     $this->em->getConfiguration()->setMetadataDriverImpl($annotationDriver);
     $this->factory = new ClassMetadataFactory();
     $this->factory->setEntityManager($this->em);
     $this->listener = new ResolveTargetEntityListener();
 }
开发者ID:Herriniaina,项目名称:iVarotra,代码行数:9,代码来源:ResolveTargetEntityListenerTest.php

示例2: setUp

 public function setUp()
 {
     $this->listener = new AttachEntityListenersListener();
     $driver = $this->createAnnotationDriver();
     $this->em = $this->_getTestEntityManager();
     $evm = $this->em->getEventManager();
     $this->factory = new ClassMetadataFactory();
     $evm->addEventListener(Events::loadClassMetadata, $this->listener);
     $this->em->getConfiguration()->setMetadataDriverImpl($driver);
     $this->factory->setEntityManager($this->em);
 }
开发者ID:selimcr,项目名称:servigases,代码行数:11,代码来源:AttachEntityListenersListenerTest.php

示例3: 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

示例4: 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

示例5: __construct

 /**
  * Creates a new EntityManager that operates on the given database connection
  * and uses the given Configuration and EventManager implementations.
  *
  * @param \Doctrine\DBAL\Connection $conn
  * @param \Doctrine\ORM\Configuration $config
  * @param \Doctrine\Common\EventManager $eventManager
  */
 protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager)
 {
     $this->conn = $conn;
     $this->config = $config;
     $this->eventManager = $eventManager;
     $metadataFactoryClassName = $config->getClassMetadataFactoryName();
     $this->metadataFactory = new $metadataFactoryClassName();
     $this->metadataFactory->setEntityManager($this);
     $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
     $this->unitOfWork = new UnitOfWork($this);
     $this->proxyFactory = new ProxyFactory($this, $config->getProxyDir(), $config->getProxyNamespace(), $config->getAutoGenerateProxyClasses());
 }
开发者ID:pollux1er,项目名称:dlawebdev2,代码行数:20,代码来源:EntityManager.php

示例6: __construct

 /**
  * Creates a new EntityManager that operates on the given database connection
  * and uses the given Configuration and EventManager implementations.
  *
  * @param \Doctrine\DBAL\Connection     $conn
  * @param \Doctrine\ORM\Configuration   $config
  * @param \Doctrine\Common\EventManager $eventManager
  */
 protected function __construct(Connection $conn, Configuration $config, EventManager $eventManager)
 {
     $this->conn = $conn;
     $this->config = $config;
     $this->eventManager = $eventManager;
     $metadataFactoryClassName = $config->getClassMetadataFactoryName();
     $this->metadataFactory = new $metadataFactoryClassName();
     $this->metadataFactory->setEntityManager($this);
     $this->metadataFactory->setCacheDriver($this->config->getMetadataCacheImpl());
     $this->repositoryFactory = $config->getRepositoryFactory();
     $this->unitOfWork = new UnitOfWork($this);
     $this->proxyFactory = new ProxyFactory($this, $config->getProxyDir(), $config->getProxyNamespace(), $config->getAutoGenerateProxyClasses());
     if ($config->isSecondLevelCacheEnabled()) {
         $cacheClass = $config->getSecondLevelCacheConfiguration()->getCacheClassName();
         $this->cache = new $cacheClass($this);
     }
 }
开发者ID:svobodni,项目名称:web,代码行数:25,代码来源:EntityManager.php

示例7: 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

示例8: 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

示例9: 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

示例10: setEntityManager

 /**
  * @param EntityManager $em
  */
 public function setEntityManager(EntityManager $em)
 {
     $this->em = $em;
     $this->config = $em->getConfiguration();
     parent::setEntityManager($em);
 }
开发者ID:peterkrejci,项目名称:music-collection,代码行数:9,代码来源:ClassMetadataFactory.php

示例11: setUp

 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->cmf = new ClassMetadataFactory();
     $this->cmf->setEntityManager($this->_getTestEntityManager());
 }
开发者ID:selimcr,项目名称:servigases,代码行数:8,代码来源:BasicInheritanceMappingTest.php

示例12: setEntityManager

 /**
  * {@inheritdoc}
  */
 public function setEntityManager(EntityManagerInterface $em)
 {
     parent::setEntityManager($em);
     $this->entityManager = $em;
 }
开发者ID:sagikazarmark,项目名称:platform,代码行数:8,代码来源:OroClassMetadataFactory.php

示例13: 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

示例14: 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

示例15: writeEntityClass

 /**
  * @param string $className
  * @param string $newClassName
  * @return string
  */
 private function writeEntityClass($className, $newClassName)
 {
     $cmf = new ClassMetadataFactory();
     $em = $this->_getTestEntityManager();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getMetadataFor($className);
     $metadata->namespace = $this->_namespace;
     $metadata->name = $newClassName;
     $metadata->customRepositoryClassName = $newClassName . "Repository";
     $this->_generator->writeEntityClass($metadata, $this->_tmpDir);
     require $this->_tmpDir . DIRECTORY_SEPARATOR . str_replace('\\', DIRECTORY_SEPARATOR, $newClassName) . ".php";
 }
开发者ID:selimcr,项目名称:servigases,代码行数:17,代码来源:EntityRepositoryGeneratorTest.php


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