PHP Class Neos\Flow\Persistence\Doctrine\Service

Afficher le fichier Open project: neos/flow-development-collection Class Usage Examples

Méthodes publiques

Свойство Type Description
$output array

Protected Properties

Свойство Type Description
$entityManager Doctrine\Common\Persistence\ObjectManager
$environment Neos\Flow\Utility\Environment
$packageManager Neos\Flow\Package\PackageManagerInterface
$settings array

Méthodes publiques

Méthode Description
compileProxies ( ) : void Compiles the Doctrine proxy class code using the Doctrine ProxyFactory.
createSchema ( string $outputPathAndFilename = null ) : string Creates the needed DB schema using Doctrine's SchemaTool. If tables already exist, this will throw an exception.
executeMigration ( string $version, string $direction = 'up', string $outputPathAndFilename = null, boolean $dryRun = false ) : string Execute a single migration in up or down direction. If $path is given, the SQL statements will be written to the file in $path instead of executed.
executeMigrations ( string $version = null, string $outputPathAndFilename = null, boolean $dryRun = false, boolean $quiet = false ) : string Execute all new migrations, up to $version if given.
generateMigration ( boolean $diffAgainstCurrent = true, string $filterExpression = null ) : string Generates a new migration file and returns the path to it.
getDatabasePlatformName ( ) : string Get name of current database platform
getEntityStatus ( ) : array Returns information about which entities exist and possibly if their mapping information contains errors or not.
getForeignKeyHandlingSql ( Doctrine\DBAL\Schema\Schema $schema, Doctrine\DBAL\Platforms\AbstractPlatform $platform, array $tableNames, string $search, string $replace ) : array This serves a rather strange use case: renaming columns used in FK constraints.
getMigrationStatus ( boolean $showMigrations = false, boolean $showDescriptions = false ) : string Returns the current migration status formatted as plain text.
markAsMigrated ( string $version, boolean $markAsMigrated ) : void Add a migration version to the migrations table or remove it.
runDql ( string $dql, integer $hydrationMode = Doctrine\ORM\Query::HYDRATE_OBJECT, integer $firstResult = null, integer $maxResult = null ) : mixed Run DQL and return the result as-is.
updateSchema ( boolean $safeMode = true, string $outputPathAndFilename = null ) : string Updates the DB schema using Doctrine's SchemaTool. The $safeMode flag is passed to SchemaTool unchanged.
validateMapping ( ) : array Validates the metadata mapping for Doctrine, using the SchemaValidator of Doctrine.

Méthodes protégées

Méthode Description
buildCodeFromSql ( Configuration $configuration, array $sql ) : string Returns PHP code for a migration file that "executes" the given array of SQL statements.
getFormattedVersionAlias ( string $alias, Configuration $configuration ) : string Returns a formatted version string for the alias.
getMigrationConfiguration ( ) : Configuration Return the configuration needed for Migrations.
getMigrationDescription ( Version $version, DocCommentParser $parser ) : string Returns the description of a migration.
getPackageKeyFromMigrationVersion ( Version $version ) : string Tries to find out a package key which the Version belongs to. If no package could be found, an empty string is returned.
writeMigrationClassToFile ( Configuration $configuration, string $up, string $down ) : string

Private Methods

Méthode Description
resolveTableName ( string $name ) : string Resolve a table name from its fully qualified name. The $name argument comes from Doctrine\DBAL\Schema\Table#getName which can sometimes return a namespaced name with the form {namespace}.{tableName}. This extracts the table name from that.

Method Details

buildCodeFromSql() protected méthode

Returns PHP code for a migration file that "executes" the given array of SQL statements.
protected buildCodeFromSql ( Configuration $configuration, array $sql ) : string
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
$sql array
Résultat string

compileProxies() public méthode

Compiles the Doctrine proxy class code using the Doctrine ProxyFactory.
public compileProxies ( ) : void
Résultat void

createSchema() public méthode

Creates the needed DB schema using Doctrine's SchemaTool. If tables already exist, this will throw an exception.
public createSchema ( string $outputPathAndFilename = null ) : string
$outputPathAndFilename string A file to write SQL to, instead of executing it
Résultat string

executeMigration() public méthode

Execute a single migration in up or down direction. If $path is given, the SQL statements will be written to the file in $path instead of executed.
public executeMigration ( string $version, string $direction = 'up', string $outputPathAndFilename = null, boolean $dryRun = false ) : string
$version string The version to migrate to
$direction string
$outputPathAndFilename string A file to write SQL to, instead of executing it
$dryRun boolean Whether to do a dry run or not
Résultat string

executeMigrations() public méthode

If $outputPathAndFilename is given, the SQL statements will be written to the given file instead of executed.
public executeMigrations ( string $version = null, string $outputPathAndFilename = null, boolean $dryRun = false, boolean $quiet = false ) : string
$version string The version to migrate to
$outputPathAndFilename string A file to write SQL to, instead of executing it
$dryRun boolean Whether to do a dry run or not
$quiet boolean Whether to do a quiet run or not
Résultat string

generateMigration() public méthode

If $diffAgainstCurrent is TRUE, it generates a migration file with the diff between current DB structure and the found mapping metadata. Only include tables/sequences matching the $filterExpression regexp when diffing models and existing schema. Otherwise an empty migration skeleton is generated.
public generateMigration ( boolean $diffAgainstCurrent = true, string $filterExpression = null ) : string
$diffAgainstCurrent boolean
$filterExpression string
Résultat string Path to the new file

getDatabasePlatformName() public méthode

Get name of current database platform
public getDatabasePlatformName ( ) : string
Résultat string

getEntityStatus() public méthode

Returns information about which entities exist and possibly if their mapping information contains errors or not.
public getEntityStatus ( ) : array
Résultat array

getForeignKeyHandlingSql() public static méthode

For a column that is used in a FK constraint to be renamed, the FK constraint has to be dropped first, then the column can be renamed and last the FK constraint needs to be added back (using the new name, of course). This method helps with the task of handling the FK constraints during this. Given a list of tables that contain columns to be renamed and a search/replace pair for the column name, it will return an array with arrays with drop and add SQL statements. Use them like this before and after renaming the affected fields: collect foreign keys pointing to "our" tables $tableNames = array(...); $foreignKeyHandlingSql = $this->getForeignKeyHandlingSql($schema, $tableNames, 'old_name', 'new_name'); drop FK constraints foreach ($foreignKeyHandlingSql['drop'] as $sql) { $this->addSql($sql); } rename columns now add back FK constraints foreach ($foreignKeyHandlingSql['add'] as $sql) { $this->addSql($sql); }
public static getForeignKeyHandlingSql ( Doctrine\DBAL\Schema\Schema $schema, Doctrine\DBAL\Platforms\AbstractPlatform $platform, array $tableNames, string $search, string $replace ) : array
$schema Doctrine\DBAL\Schema\Schema
$platform Doctrine\DBAL\Platforms\AbstractPlatform
$tableNames array
$search string
$replace string
Résultat array

getFormattedVersionAlias() protected méthode

Returns a formatted version string for the alias.
protected getFormattedVersionAlias ( string $alias, Configuration $configuration ) : string
$alias string
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
Résultat string

getMigrationConfiguration() protected méthode

Return the configuration needed for Migrations.
protected getMigrationConfiguration ( ) : Configuration
Résultat Doctrine\DBAL\Migrations\Configuration\Configuration

getMigrationDescription() protected méthode

If available it is fetched from the getDescription() method, if that returns an empty value the class docblock is used instead.
protected getMigrationDescription ( Version $version, DocCommentParser $parser ) : string
$version Doctrine\DBAL\Migrations\Version
$parser Neos\Flow\Reflection\DocCommentParser
Résultat string

getMigrationStatus() public méthode

Returns the current migration status formatted as plain text.
public getMigrationStatus ( boolean $showMigrations = false, boolean $showDescriptions = false ) : string
$showMigrations boolean
$showDescriptions boolean
Résultat string

getPackageKeyFromMigrationVersion() protected méthode

Tries to find out a package key which the Version belongs to. If no package could be found, an empty string is returned.
protected getPackageKeyFromMigrationVersion ( Version $version ) : string
$version Doctrine\DBAL\Migrations\Version
Résultat string

markAsMigrated() public méthode

This does not execute any migration code but simply records a version as migrated or not.
public markAsMigrated ( string $version, boolean $markAsMigrated ) : void
$version string The version to add or remove
$markAsMigrated boolean
Résultat void

runDql() public méthode

Run DQL and return the result as-is.
public runDql ( string $dql, integer $hydrationMode = Doctrine\ORM\Query::HYDRATE_OBJECT, integer $firstResult = null, integer $maxResult = null ) : mixed
$dql string
$hydrationMode integer
$firstResult integer
$maxResult integer
Résultat mixed

updateSchema() public méthode

Updates the DB schema using Doctrine's SchemaTool. The $safeMode flag is passed to SchemaTool unchanged.
public updateSchema ( boolean $safeMode = true, string $outputPathAndFilename = null ) : string
$safeMode boolean
$outputPathAndFilename string A file to write SQL to, instead of executing it
Résultat string

validateMapping() public méthode

Validates the metadata mapping for Doctrine, using the SchemaValidator of Doctrine.
public validateMapping ( ) : array
Résultat array

writeMigrationClassToFile() protected méthode

protected writeMigrationClassToFile ( Configuration $configuration, string $up, string $down ) : string
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
$up string
$down string
Résultat string

Property Details

$entityManager protected_oe property

protected ObjectManager,Doctrine\Common\Persistence $entityManager
Résultat Doctrine\Common\Persistence\ObjectManager

$environment protected_oe property

protected Environment,Neos\Flow\Utility $environment
Résultat Neos\Flow\Utility\Environment

$output public_oe property

public array $output
Résultat array

$packageManager protected_oe property

protected PackageManagerInterface,Neos\Flow\Package $packageManager
Résultat Neos\Flow\Package\PackageManagerInterface

$settings protected_oe property

protected array $settings
Résultat array