class DatabaseStructureManager (View source)

Properties

protected EntityManager $entityManager The entity manager instance.
protected ClassMetadata[] $metadatas The entity classes and their metadata.

Methods

__construct(EntityManager $em)

Create a new structure manager.

EntityManager
getEntityManager()

Get the entity manager object for this structure manager.

string
getProxyDir()

Returns the proxies path.

bool
generateProxyClasses()

Generates the proxy classes for all the entities managed by this class.

bool
generateProxyClassesFor(array $metadatas)

Generates the proxy classes for all given classes contained in the $metadatas array. Returns true on successful generation and false if there were no proxy classes to be generated.

bool
destroyProxyClasses(string $prefix = null)

Destroys all the proxy classes that have the defined prefix. No need to define the generic doctrine proxy marker prefix, i.e. "CG" but the part after that, e.g. "ConcreteCore".

bool
installDatabase()

Installs the database tables according to the entity schema definitions.

bool
installDatabaseFor(array $metadatas)

Installs the database tables for all entity classes contained within the $metadatas array. Returns true if new tables were created or existing ones altered. Otherwise this will return false if there were no database migrations needed.

bool
uninstallDatabase()

This drops all the tables related to the entities managed by this class.

bool
uninstallDatabaseFor(array $metadatas)

Uninstalls the database tables for all given entity classes contained within the $metadatas array. Returns true if there were tables that were dropped and false otherwise.

int
dropObsoleteDatabaseTables(string $prefix, array $excludeTables = array())

Drops all the database tables that a) are prefixed with the given prefix string b) are not linked to any existing entity managed by this class c) are not contained within the $excludeTables array.

bool
hasEntities()

Determines whether the entity manager instance for this class has any entity classes defined in its entity class path.

ClassMetadata[]
getMetadatas()

Returns the entity classes and their metadata. Loads this data if it has not been already loaded by this instancfe.

loadMetadatas()

Loads the entity class metadata into the $metadatas variable.

clearCacheAndProxies()

No description

refreshEntities()

Clears cache, regenerates all proxy classes, and updates metadatas in all entity managers

Details

__construct(EntityManager $em)

Create a new structure manager.

Parameters

EntityManager $em

EntityManager getEntityManager()

Get the entity manager object for this structure manager.

Return Value

EntityManager

string getProxyDir()

Returns the proxies path.

Return Value

string

bool generateProxyClasses()

Generates the proxy classes for all the entities managed by this class.

Returns true on successful generation and false if there were no proxy classes to be generated.

Return Value

bool

bool generateProxyClassesFor(array $metadatas)

Generates the proxy classes for all given classes contained in the $metadatas array. Returns true on successful generation and false if there were no proxy classes to be generated.

Parameters

array $metadatas

Return Value

bool

Exceptions

Exception Throws an exception in case there are issues with the proxy dir.

bool destroyProxyClasses(string $prefix = null)

Destroys all the proxy classes that have the defined prefix. No need to define the generic doctrine proxy marker prefix, i.e. "CG" but the part after that, e.g. "ConcreteCore".

Returns a boolean indicating whether any files were deleted or not.

Parameters

string $prefix

Return Value

bool

Exceptions

Exception Throws an exception if the given prefix is invalid or if one of the proxy files cannot be deleted.

bool installDatabase()

Installs the database tables according to the entity schema definitions.

This will not install any existing tables but it will migrate those tables to match the current schema definitions for the classes.

Return Value

bool

bool installDatabaseFor(array $metadatas)

Installs the database tables for all entity classes contained within the $metadatas array. Returns true if new tables were created or existing ones altered. Otherwise this will return false if there were no database migrations needed.

Parameters

array $metadatas

Return Value

bool

bool uninstallDatabase()

This drops all the tables related to the entities managed by this class.

Do not normally call this for anything. Save this ONLY for special occasions.

Return Value

bool

bool uninstallDatabaseFor(array $metadatas)

Uninstalls the database tables for all given entity classes contained within the $metadatas array. Returns true if there were tables that were dropped and false otherwise.

Parameters

array $metadatas

Return Value

bool

int dropObsoleteDatabaseTables(string $prefix, array $excludeTables = array())

Drops all the database tables that a) are prefixed with the given prefix string b) are not linked to any existing entity managed by this class c) are not contained within the $excludeTables array.

Can be used e.g. for packages by giving the package's handle in camelcased format. This would drop all the prefixed database tables for that package that no longer have a corresponding entity defined for them. Give the tables defined in the package's DB XML in the $excludeTables array in order not to drop them.

Parameters

string $prefix
array $excludeTables

Return Value

int

bool hasEntities()

Determines whether the entity manager instance for this class has any entity classes defined in its entity class path.

Return Value

bool

ClassMetadata[] getMetadatas()

Returns the entity classes and their metadata. Loads this data if it has not been already loaded by this instancfe.

Return Value

ClassMetadata[]

protected loadMetadatas()

Loads the entity class metadata into the $metadatas variable.

clearCacheAndProxies()

refreshEntities()

Clears cache, regenerates all proxy classes, and updates metadatas in all entity managers