Doctrine


Doctrine\ORM\Tools\EntityGenerator
/Doctrine/ORM/Tools/EntityGenerator.php at line 50

Class EntityGenerator

EntityGenerator

public class EntityGenerator

Generic class used to generate PHP5 entity classes from ClassMetadataInfo instances

[php] $classes = $em->getClassMetadataFactory()->getAllMetadata();

$generator = new \Doctrine\ORM\Tools\EntityGenerator(); $generator->setGenerateAnnotations(true); $generator->setGenerateStubMethods(true); $generator->setRegenerateEntityIfExists(false); $generator->setUpdateEntityIfExists(true); $generator->generate($classes, '/path/to/generate/entities');

License:
http://www.opensource.org/licenses/lgpl-license.php LGPL
See Also:
www.doctrine-project.org
Since:
2.0
Version:
$Revision$
Author:
Benjamin Eberlei
Guilherme Blanco
Jonathan Wage
Roman Borschel

Method Summary
void

generate(array metadatas, string outputDirectory)

Generate and write entity classes for the given array of ClassMetadataInfo instances

string

generateEntityClass(ClassMetadataInfo metadata)

Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance

string

generateUpdatedEntityClass(ClassMetadataInfo metadata, string path)

Generate the updated code for the given ClassMetadataInfo and entity at path

void

setClassToExtend(mixed classToExtend)

Set the name of the class the generated classes should extend from

void

setExtension(string extension)

Set the extension to use when writing php files to disk

void

setGenerateAnnotations(bool bool)

Set whether or not to generate annotations for the entity

void

setGenerateStubMethods(bool bool)

Set whether or not to generate stub methods for the entity

void

setNumSpaces(integer numSpaces)

Set the number of spaces the exported class should have

void

setRegenerateEntityIfExists(bool bool)

Set whether or not to regenerate the entity if it exists

void

setUpdateEntityIfExists(bool bool)

Set whether or not to try and update the entity if it already exists

void

writeEntityClass(ClassMetadataInfo metadata, string outputDirectory)

Generated and write entity class to disk for the given ClassMetadataInfo instance

Method Detail

/Doctrine/ORM/Tools/EntityGenerator.php at line 142

generate

public void generate(array metadatas, string outputDirectory)

Generate and write entity classes for the given array of ClassMetadataInfo instances


/Doctrine/ORM/Tools/EntityGenerator.php at line 188

generateEntityClass

public string generateEntityClass(ClassMetadataInfo metadata)

Generate a PHP5 Doctrine 2 entity class from the given ClassMetadataInfo instance

Returns:
$code

/Doctrine/ORM/Tools/EntityGenerator.php at line 216

generateUpdatedEntityClass

public string generateUpdatedEntityClass(ClassMetadataInfo metadata, string path)

Generate the updated code for the given ClassMetadataInfo and entity at path

Returns:
$code;

/Doctrine/ORM/Tools/EntityGenerator.php at line 254

setClassToExtend

public void setClassToExtend(mixed classToExtend)

Set the name of the class the generated classes should extend from


/Doctrine/ORM/Tools/EntityGenerator.php at line 244

setExtension

public void setExtension(string extension)

Set the extension to use when writing php files to disk


/Doctrine/ORM/Tools/EntityGenerator.php at line 265

setGenerateAnnotations

public void setGenerateAnnotations(bool bool)

Set whether or not to generate annotations for the entity


/Doctrine/ORM/Tools/EntityGenerator.php at line 298

setGenerateStubMethods

public void setGenerateStubMethods(bool bool)

Set whether or not to generate stub methods for the entity


/Doctrine/ORM/Tools/EntityGenerator.php at line 232

setNumSpaces

public void setNumSpaces(integer numSpaces)

Set the number of spaces the exported class should have


/Doctrine/ORM/Tools/EntityGenerator.php at line 287

setRegenerateEntityIfExists

public void setRegenerateEntityIfExists(bool bool)

Set whether or not to regenerate the entity if it exists


/Doctrine/ORM/Tools/EntityGenerator.php at line 276

setUpdateEntityIfExists

public void setUpdateEntityIfExists(bool bool)

Set whether or not to try and update the entity if it already exists


/Doctrine/ORM/Tools/EntityGenerator.php at line 156

writeEntityClass

public void writeEntityClass(ClassMetadataInfo metadata, string outputDirectory)

Generated and write entity class to disk for the given ClassMetadataInfo instance


Doctrine