本文整理汇总了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]);
}
示例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;
}
示例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());
}
示例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);
}