本文整理汇总了PHP中Doctrine\ORM\Tools\EntityGenerator::setAnnotationPrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityGenerator::setAnnotationPrefix方法的具体用法?PHP EntityGenerator::setAnnotationPrefix怎么用?PHP EntityGenerator::setAnnotationPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\Tools\EntityGenerator
的用法示例。
在下文中一共展示了EntityGenerator::setAnnotationPrefix方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* @inheritdoc
*/
public function setUp()
{
$this->_namespace = uniqid('doctrine_');
$this->_tmpDir = \sys_get_temp_dir() . DIRECTORY_SEPARATOR . $this->_namespace;
\mkdir($this->_tmpDir);
$this->_generator = new EntityGenerator();
$this->_generator->setAnnotationPrefix("");
$this->_generator->setGenerateAnnotations(true);
$this->_generator->setGenerateStubMethods(true);
$this->_generator->setRegenerateEntityIfExists(false);
$this->_generator->setUpdateEntityIfExists(true);
$this->_generator->setFieldVisibility(EntityGenerator::FIELD_VISIBLE_PROTECTED);
$this->_repositoryGenerator = new EntityRepositoryGenerator();
}
示例2: getEntityGenerator
protected function getEntityGenerator()
{
$entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateAnnotations(false);
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(false);
$entityGenerator->setUpdateEntityIfExists(true);
$entityGenerator->setNumSpaces(4);
$entityGenerator->setAnnotationPrefix('ORM\\');
return $entityGenerator;
}
示例3: getEntityGenerator
protected function getEntityGenerator()
{
$entityGenerator = new EntityGenerator();
if (version_compare(DoctrineVersion::VERSION, "2.0.2-DEV") >= 0) {
$entityGenerator->setAnnotationPrefix("orm:");
}
$entityGenerator->setGenerateAnnotations(false);
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(false);
$entityGenerator->setUpdateEntityIfExists(true);
$entityGenerator->setNumSpaces(4);
return $entityGenerator;
}
示例4: testMappedSuperclassAnnotationGeneration
/**
* @group DDC-3272
*/
public function testMappedSuperclassAnnotationGeneration()
{
$metadata = new ClassMetadataInfo($this->_namespace . '\\EntityGeneratorBook');
$metadata->namespace = $this->_namespace;
$metadata->isMappedSuperclass = true;
$this->_generator->setAnnotationPrefix('ORM\\');
$this->_generator->writeEntityClass($metadata, $this->_tmpDir);
$this->newInstance($metadata);
// force instantiation (causes autoloading to kick in)
$driver = new AnnotationDriver(new AnnotationReader(), array());
$cm = new ClassMetadata($metadata->name);
$cm->initializeReflection(new RuntimeReflectionService());
$driver->loadMetadataForClass($cm->name, $cm);
$this->assertTrue($cm->isMappedSuperclass);
}
示例5: testLoadPrefixedMetadata
public function testLoadPrefixedMetadata()
{
$this->_generator->setAnnotationPrefix('ORM\\');
$metadata = $this->generateBookEntityFixture();
$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$driver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader, array());
$book = $this->newInstance($metadata);
$cm = new \Doctrine\ORM\Mapping\ClassMetadata($metadata->name);
$cm->initializeReflection(new \Doctrine\Common\Persistence\Mapping\RuntimeReflectionService());
$driver->loadMetadataForClass($cm->name, $cm);
$this->assertEquals($cm->columnNames, $metadata->columnNames);
$this->assertEquals($cm->getTableName(), $metadata->getTableName());
$this->assertEquals($cm->lifecycleCallbacks, $metadata->lifecycleCallbacks);
$this->assertEquals($cm->identifier, $metadata->identifier);
$this->assertEquals($cm->idGenerator, $metadata->idGenerator);
$this->assertEquals($cm->customRepositoryClassName, $metadata->customRepositoryClassName);
}
示例6: getEntityGenerator
/**
* Get a Doctrine EntityGenerator instance.
*
* @param string|null $classToExtend
*
* @return EntityGenerator
*/
protected function getEntityGenerator($classToExtend = null)
{
$entityGenerator = new EntityGenerator();
if (!is_null($classToExtend)) {
$entityGenerator->setClassToExtend($classToExtend);
}
$entityGenerator->setGenerateAnnotations(true);
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(false);
$entityGenerator->setUpdateEntityIfExists(true);
$entityGenerator->setNumSpaces(4);
$entityGenerator->setAnnotationPrefix('ORM\\');
return $entityGenerator;
}
示例7: testExportDirectoryAndFilesAreCreated
public function testExportDirectoryAndFilesAreCreated()
{
$this->_deleteDirectory(__DIR__ . '/export/' . $this->_getType());
$type = $this->_getType();
$metadataDriver = $this->_createMetadataDriver($type, __DIR__ . '/' . $type);
$em = $this->_createEntityManager($metadataDriver);
$cmf = $this->_createClassMetadataFactory($em, $type);
$metadata = $cmf->getAllMetadata();
$metadata[0]->name = 'Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser';
$this->assertEquals('Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser', $metadata[0]->name);
$type = $this->_getType();
$cme = new ClassMetadataExporter();
$exporter = $cme->getExporter($type, __DIR__ . '/export/' . $type);
if ($type === 'annotation') {
$entityGenerator = new EntityGenerator();
$entityGenerator->setAnnotationPrefix("");
$exporter->setEntityGenerator($entityGenerator);
}
$this->_extension = $exporter->getExtension();
$exporter->setMetadata($metadata);
$exporter->export();
if ($type == 'annotation') {
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/' . str_replace('\\', '/', 'Doctrine\\Tests\\ORM\\Tools\\Export\\ExportedUser') . $this->_extension));
} else {
$this->assertTrue(file_exists(__DIR__ . '/export/' . $type . '/Doctrine.Tests.ORM.Tools.Export.ExportedUser' . $this->_extension));
}
}
示例8: getEntityGenerator
/**
* @return \Doctrine\ORM\Tools\EntityGenerator
*/
protected function getEntityGenerator()
{
$entityGenerator = new EntityGenerator();
$entityGenerator->setClassToExtend('Kunstmaan\\AdminBundle\\Entity\\AbstractEntity');
$entityGenerator->setGenerateAnnotations(true);
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(false);
$entityGenerator->setUpdateEntityIfExists(true);
$entityGenerator->setNumSpaces(4);
$entityGenerator->setAnnotationPrefix('ORM\\');
return $entityGenerator;
}
示例9: generateClasses
/**
* Generate the model class for Raptor
* Genera las clases modelos para las clases schema especificadas
* Los modelos seran generados en el namespace especificado
* Tenga en cuenta que un SchemaClass no es lo mismo que los nombres
* de las tablas, es una representacion que brinda doctrine para tablas en la base de datos
*
* $this->getStore()->generateClasses('\example\exampleBundle','Persona');
*
* @param string $namespace el namespace del bundle donde seran creados los modelos
* @param array $schemaClass un array con todos los schemaClass que seran generados los modelos
*/
public function generateClasses($namespace, $schemaClass)
{
$clases = $schemaClass;
// custom datatypes (not mapped for reverse engineering)
$this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('set', 'string');
$this->entityManager->getConnection()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
// fetch metadata
$driver = new \Doctrine\ORM\Mapping\Driver\DatabaseDriver($this->entityManager->getConnection()->getSchemaManager());
$this->entityManager->getConfiguration()->setMetadataDriverImpl($driver);
$cmf = new \Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($this->entityManager);
// we must set the EntityManager
$classes = $driver->getAllClassNames();
$metadata = array();
$rep = new EntityRepositoryGenerator();
foreach ($clases as $class) {
//any unsupported table/schema could be handled here to exclude some classes
if (true) {
$meta = $cmf->getMetadataFor($class);
$association = new ItemList($meta->associationMappings);
$me = $this;
$association->each(function ($k, $v, $l) use(&$me) {
$v['targetEntity'] = $me->translateSchemas($v['targetEntity']);
$v['sourceEntity'] = $me->translateSchemas($v['sourceEntity']);
$l->set($k, $v);
});
$meta->associationMappings = $association->getArray();
$real = $this->translateSchemas($class);
$meta->name = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $real;
$meta->namespace = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity';
// $meta->namespace='Entities\\'.$class;
$meta->customRepositoryClassName = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository';
//TODO buscar entidades ya creadas
foreach ($meta->associationMappings as $key => $value) {
$names = $this->entityManager->getConfiguration()->getEntityNamespaces();
$target = $meta->associationMappings[$key]['targetEntity'];
$found = false;
foreach ($names as $routes) {
if ($routes[0] == '\\') {
$bundleRoute = substr($routes, 1);
} else {
$bundleRoute = $routes;
}
$fileroute = __DIR__ . "/../../../src/" . str_replace('\\', DIRECTORY_SEPARATOR, $bundleRoute);
$fileroute .= DIRECTORY_SEPARATOR . $target . ".php";
if (file_exists($fileroute)) {
$found = true;
$target = $bundleRoute . $this->namespaceSeparator . $value['targetEntity'];
}
}
if ($found) {
//$target = $namespace . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
$meta->associationMappings[$key]['targetEntity'] = $target;
} else {
$meta->associationMappings[$key]['targetEntity'] = $namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Entity' . $this->namespaceSeparator . $value['targetEntity'];
}
}
$metadata[] = $meta;
$rep->writeEntityRepositoryClass($namespace . $this->namespaceSeparator . 'Model' . $this->namespaceSeparator . 'Repository' . $this->namespaceSeparator . $real . 'Repository', \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
}
}
$generator = new EntityGenerator();
$generator->setAnnotationPrefix('');
// edit: quick fix for No Metadata Classes to process
$generator->setUpdateEntityIfExists(true);
// only update if class already exists
$generator->setRegenerateEntityIfExists(true);
// this will overwrite the existing classes
$generator->setGenerateStubMethods(true);
$generator->setGenerateAnnotations(true);
//$y=new Doctrine\ORM\Tools\Export\Driver\YamlExporter(__DIR__ . '/Entities/yml');
//$y->setMetadata($metadata);
//$y->export();
$generator->generate($metadata, \Raptor\Core\Location::get(\Raptor\Core\Location::SRC));
}
示例10: getEntityGenerator
/**
* Get entity generator.
*
* @return EntityGenerator
*/
protected static function getEntityGenerator()
{
$entityGenerator = new EntityGenerator();
$entityGenerator->setGenerateAnnotations(true);
$entityGenerator->setGenerateStubMethods(true);
$entityGenerator->setRegenerateEntityIfExists(true);
$entityGenerator->setUpdateEntityIfExists(true);
$entityGenerator->setNumSpaces(4);
$entityGenerator->setAnnotationPrefix(self::$annotationPrefix);
return $entityGenerator;
}
示例11: generador
/**
* Entidades::generador()
*
* Genera el proceso correspondiente
* @param array $metadata
* @return void
*/
private function generador($metadata = false)
{
$generator = new EntityGenerator();
$generator->setAnnotationPrefix('');
// edit: quick fix for No Metadata Classes to process
$generator->setUpdateEntityIfExists(true);
// only update if class already exists
$generator->setRegenerateEntityIfExists(true);
// this will overwrite the existing classes
$generator->setGenerateStubMethods(true);
$generator->setGenerateAnnotations(true);
$generator->generate($metadata, dirname($this->dirEntidades));
}