當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DisconnectedClassMetadataFactory::getMetadataFor方法代碼示例

本文整理匯總了PHP中Doctrine\ORM\Tools\DisconnectedClassMetadataFactory::getMetadataFor方法的典型用法代碼示例。如果您正苦於以下問題:PHP DisconnectedClassMetadataFactory::getMetadataFor方法的具體用法?PHP DisconnectedClassMetadataFactory::getMetadataFor怎麽用?PHP DisconnectedClassMetadataFactory::getMetadataFor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ORM\Tools\DisconnectedClassMetadataFactory的用法示例。


在下文中一共展示了DisconnectedClassMetadataFactory::getMetadataFor方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testTest

 public function testTest()
 {
     if (!class_exists('Symfony\\Component\\Yaml\\Yaml', true)) {
         $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
     }
     $cme = new ClassMetadataExporter();
     $converter = new ConvertDoctrine1Schema(__DIR__ . '/doctrine1schema');
     $exporter = $cme->getExporter('yml', __DIR__ . '/convert');
     $exporter->setOverwriteExistingFiles(true);
     $exporter->setMetadata($converter->getMetadata());
     $exporter->export();
     $this->assertTrue(file_exists(__DIR__ . '/convert/User.dcm.yml'));
     $this->assertTrue(file_exists(__DIR__ . '/convert/Profile.dcm.yml'));
     $metadataDriver = new \Doctrine\ORM\Mapping\Driver\YamlDriver(__DIR__ . '/convert');
     $em = $this->_createEntityManager($metadataDriver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($em);
     $metadata = $cmf->getAllMetadata();
     $profileClass = $cmf->getMetadataFor('Profile');
     $userClass = $cmf->getMetadataFor('User');
     $this->assertEquals(2, count($metadata));
     $this->assertEquals('Profile', $profileClass->name);
     $this->assertEquals('User', $userClass->name);
     $this->assertEquals(4, count($profileClass->fieldMappings));
     $this->assertEquals(5, count($userClass->fieldMappings));
     $this->assertEquals('text', $userClass->fieldMappings['clob']['type']);
     $this->assertEquals('test_alias', $userClass->fieldMappings['theAlias']['columnName']);
     $this->assertEquals('theAlias', $userClass->fieldMappings['theAlias']['fieldName']);
     $this->assertEquals('Profile', $profileClass->associationMappings['User']['sourceEntity']);
     $this->assertEquals('User', $profileClass->associationMappings['User']['targetEntity']);
     $this->assertEquals('username', $userClass->table['uniqueConstraints']['username']['columns'][0]);
 }
開發者ID:Herriniaina,項目名稱:iVarotra,代碼行數:32,代碼來源:ConvertDoctrine1SchemaTest.php

示例2: getAllMetadata

 protected function getAllMetadata(array $entity)
 {
     $metadata = array();
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($this->_em);
     foreach ($entity as $e) {
         $metadata[] = $cmf->getMetadataFor($e);
     }
     return $metadata;
 }
開發者ID:controleonline,項目名稱:core,代碼行數:10,代碼來源:InstallModel.php

示例3: getMetadataForClass

 /**
  * @param string $entity
  *
  * @return ClassMetadataCollection
  */
 private function getMetadataForClass($entity)
 {
     foreach ($this->registry->getManagers() as $em) {
         $cmf = new DisconnectedClassMetadataFactory();
         $cmf->setEntityManager($em);
         if (!$cmf->isTransient($entity)) {
             return new ClassMetadataCollection(array($cmf->getMetadataFor($entity)));
         }
     }
     return new ClassMetadataCollection(array());
 }
開發者ID:RuntyCybin,項目名稱:csymfony,代碼行數:16,代碼來源:DisconnectedMetadataFactory.php

示例4: entityManager

 /**
  * Entidades::entityManager()
  * 
  * Prepara el proceso de la creacion de las entidades
  * @param object $configuracion
  * @return object
  */
 private function entityManager($configuracion = false)
 {
     $entidad = EntityManager::create($this->confg, $configuracion);
     $entidad->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
     $entidad->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
     // fetch metadata
     $driver = new DatabaseDriver($entidad->getConnection()->getSchemaManager());
     $driver->setNamespace('Entidades\\' . $this->conexion . '\\');
     //Agrega el namespace Entidad\Nombre de la tabla
     $entidad->getConfiguration()->setMetadataDriverImpl($driver);
     $cmf = new DisconnectedClassMetadataFactory();
     $cmf->setEntityManager($entidad);
     // we must set the EntityManager
     $classes = $driver->getAllClassNames();
     $metadata = array();
     foreach ($classes as $class) {
         //any unsupported table/schema could be handled here to exclude some classes
         if (true) {
             $metadata[] = $cmf->getMetadataFor($class);
         }
     }
     $this->generador($metadata);
 }
開發者ID:NeuralFramework,項目名稱:NeuralPHPv4,代碼行數:30,代碼來源:Entidades.php


注:本文中的Doctrine\ORM\Tools\DisconnectedClassMetadataFactory::getMetadataFor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。