class DatabaseStructureManager (View source)

Properties

protected EntityManagerInterface $entityManager

The entity manager instance.

protected ClassMetadata[]|null $metadatas

The entity classes and their metadata.

Methods

__construct(EntityManagerInterface $em)

Create a new structure manager.

EntityManagerInterface
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, Closure $queryFilter = null)

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(EntityManagerInterface $em)

Create a new structure manager.

Parameters

EntityManagerInterface $em

EntityManagerInterface getEntityManager()

Get the entity manager object for this structure manager.

Return Value

EntityManagerInterface

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

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

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, Closure $queryFilter = null)

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
Closure $queryFilter

a callback that receives a query being executed and may return FALSE to skip its execution

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()

No description

refreshEntities()

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