DatabaseDriver
in package
implements
MappingDriver
The DatabaseDriver reverse engineers the mapping metadata from a database.
Tags
Table of Contents
Interfaces
- MappingDriver
- Contract for metadata drivers.
Constants
- ARRAY = 'array'
- Replacement for {@see Types::ARRAY}.
- JSON_ARRAY = 'json_array'
- Replacement for {@see Types::JSON_ARRAY}.
- OBJECT = 'object'
- Replacement for {@see Types::OBJECT}.
Properties
- $classNamesForTables : array<string|int, mixed>
- $classToTableNames : array<class-string, string>
- $fieldNamesForColumns : array<string|int, mixed>
- $inflector : Inflector
- $manyToManyTables : mixed
- $namespace : string|null
- The namespace for the generated entities.
- $sm : AbstractSchemaManager
- $tables : array<string, Table>|null
Methods
- __construct() : mixed
- getAllClassNames() : array<int, string>
- Gets the names of all mapped classes known to this driver.
- isTransient() : bool
- Returns whether the class with the specified name should have its metadata loaded.
- loadMetadataForClass() : void
- Loads the metadata for the specified class into the provided container.
- setClassNameForTable() : void
- Sets class name for a table.
- setFieldNameForColumn() : void
- Sets field name for a column on a specific table.
- setInflector() : void
- setNamespace() : void
- Set the namespace for the generated entities.
- setTables() : void
- Sets tables manually instead of relying on the reverse engineering capabilities of SchemaManager.
- buildFieldMapping() : array<string|int, mixed>
- Build field mapping from a schema column definition
- buildFieldMappings() : void
- Build field mapping from class metadata.
- buildIndexes() : void
- Build indexes from a class metadata.
- buildToOneAssociationMappings() : void
- Build to one (one to one, many to one) association mapping from class metadata.
- getClassNameForTable() : string
- Returns the mapped class name for a table if it exists. Otherwise return "classified" version.
- getFieldNameForColumn() : string
- Return the mapped field name for a column, if it exists. Otherwise return camelized version.
- getTablePrimaryKeys() : array<string|int, string>
- Retrieve schema table definition primary keys.
- reverseEngineerMappingFromDatabase() : void
Constants
ARRAY
Replacement for {@see Types::ARRAY}.
private
mixed
ARRAY
= 'array'
To be removed as soon as support for DBAL 3 is dropped.
JSON_ARRAY
Replacement for {@see Types::JSON_ARRAY}.
private
mixed
JSON_ARRAY
= 'json_array'
To be removed as soon as support for DBAL 2 is dropped.
OBJECT
Replacement for {@see Types::OBJECT}.
private
mixed
OBJECT
= 'object'
To be removed as soon as support for DBAL 3 is dropped.
Properties
$classNamesForTables
private
array<string|int, mixed>
$classNamesForTables
= []
$classToTableNames
private
array<class-string, string>
$classToTableNames
= []
$fieldNamesForColumns
private
array<string|int, mixed>
$fieldNamesForColumns
= []
$inflector
private
Inflector
$inflector
$manyToManyTables
private
mixed
$manyToManyTables
= []
Tags
$namespace
The namespace for the generated entities.
private
string|null
$namespace
$sm
private
AbstractSchemaManager
$sm
$tables
private
array<string, Table>|null
$tables
= null
Methods
__construct()
public
__construct(AbstractSchemaManager $schemaManager) : mixed
Parameters
- $schemaManager : AbstractSchemaManager
getAllClassNames()
Gets the names of all mapped classes known to this driver.
public
getAllClassNames() : array<int, string>
Return values
array<int, string> —The names of all mapped classes known to this driver.
isTransient()
Returns whether the class with the specified name should have its metadata loaded.
public
isTransient(mixed $className) : bool
Parameters
- $className : mixed
Return values
boolloadMetadataForClass()
Loads the metadata for the specified class into the provided container.
public
loadMetadataForClass(mixed $className, ClassMetadata $metadata) : void
Parameters
- $className : mixed
- $metadata : ClassMetadata
Tags
setClassNameForTable()
Sets class name for a table.
public
setClassNameForTable(string $tableName, string $className) : void
Parameters
- $tableName : string
- $className : string
setFieldNameForColumn()
Sets field name for a column on a specific table.
public
setFieldNameForColumn(string $tableName, string $columnName, string $fieldName) : void
Parameters
- $tableName : string
- $columnName : string
- $fieldName : string
setInflector()
public
setInflector(Inflector $inflector) : void
Parameters
- $inflector : Inflector
setNamespace()
Set the namespace for the generated entities.
public
setNamespace(string $namespace) : void
Parameters
- $namespace : string
setTables()
Sets tables manually instead of relying on the reverse engineering capabilities of SchemaManager.
public
setTables(array<string|int, Table> $entityTables, array<string|int, Table> $manyToManyTables) : void
Parameters
Tags
buildFieldMapping()
Build field mapping from a schema column definition
private
buildFieldMapping(string $tableName, Column $column) : array<string|int, mixed>
Parameters
- $tableName : string
- $column : Column
Tags
Return values
array<string|int, mixed>buildFieldMappings()
Build field mapping from class metadata.
private
buildFieldMappings(ClassMetadataInfo $metadata) : void
Parameters
- $metadata : ClassMetadataInfo
buildIndexes()
Build indexes from a class metadata.
private
buildIndexes(ClassMetadataInfo $metadata) : void
Parameters
- $metadata : ClassMetadataInfo
buildToOneAssociationMappings()
Build to one (one to one, many to one) association mapping from class metadata.
private
buildToOneAssociationMappings(ClassMetadataInfo $metadata) : void
Parameters
- $metadata : ClassMetadataInfo
getClassNameForTable()
Returns the mapped class name for a table if it exists. Otherwise return "classified" version.
private
getClassNameForTable(string $tableName) : string
Parameters
- $tableName : string
Tags
Return values
stringgetFieldNameForColumn()
Return the mapped field name for a column, if it exists. Otherwise return camelized version.
private
getFieldNameForColumn(string $tableName, string $columnName[, bool $fk = false ]) : string
Parameters
- $tableName : string
- $columnName : string
- $fk : bool = false
-
Whether the column is a foreignkey or not.
Return values
stringgetTablePrimaryKeys()
Retrieve schema table definition primary keys.
private
getTablePrimaryKeys(Table $table) : array<string|int, string>
Parameters
- $table : Table
Return values
array<string|int, string>reverseEngineerMappingFromDatabase()
private
reverseEngineerMappingFromDatabase() : void