PHP Класс Neos\Flow\Persistence\Doctrine\Service

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$output array

Защищенные свойства (Protected)

Свойство Тип Описание
$entityManager Doctrine\Common\Persistence\ObjectManager
$environment Neos\Flow\Utility\Environment
$packageManager Neos\Flow\Package\PackageManagerInterface
$settings array

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
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

Приватные методы

Метод Описание
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.

Описание методов

buildCodeFromSql() защищенный Метод

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
Результат string

compileProxies() публичный Метод

Compiles the Doctrine proxy class code using the Doctrine ProxyFactory.
public compileProxies ( ) : void
Результат void

createSchema() публичный Метод

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
Результат string

executeMigration() публичный Метод

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
Результат string

executeMigrations() публичный Метод

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
Результат string

generateMigration() публичный Метод

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
Результат string Path to the new file

getDatabasePlatformName() публичный Метод

Get name of current database platform
public getDatabasePlatformName ( ) : string
Результат string

getEntityStatus() публичный Метод

Returns information about which entities exist and possibly if their mapping information contains errors or not.
public getEntityStatus ( ) : array
Результат array

getForeignKeyHandlingSql() публичный статический Метод

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
Результат array

getFormattedVersionAlias() защищенный Метод

Returns a formatted version string for the alias.
protected getFormattedVersionAlias ( string $alias, Configuration $configuration ) : string
$alias string
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
Результат string

getMigrationConfiguration() защищенный Метод

Return the configuration needed for Migrations.
protected getMigrationConfiguration ( ) : Configuration
Результат Doctrine\DBAL\Migrations\Configuration\Configuration

getMigrationDescription() защищенный Метод

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
Результат string

getMigrationStatus() публичный Метод

Returns the current migration status formatted as plain text.
public getMigrationStatus ( boolean $showMigrations = false, boolean $showDescriptions = false ) : string
$showMigrations boolean
$showDescriptions boolean
Результат string

getPackageKeyFromMigrationVersion() защищенный Метод

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
Результат string

markAsMigrated() публичный Метод

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
Результат void

runDql() публичный Метод

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
Результат mixed

updateSchema() публичный Метод

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
Результат string

validateMapping() публичный Метод

Validates the metadata mapping for Doctrine, using the SchemaValidator of Doctrine.
public validateMapping ( ) : array
Результат array

writeMigrationClassToFile() защищенный Метод

protected writeMigrationClassToFile ( Configuration $configuration, string $up, string $down ) : string
$configuration Doctrine\DBAL\Migrations\Configuration\Configuration
$up string
$down string
Результат string

Описание свойств

$entityManager защищенное свойство

protected ObjectManager,Doctrine\Common\Persistence $entityManager
Результат Doctrine\Common\Persistence\ObjectManager

$environment защищенное свойство

protected Environment,Neos\Flow\Utility $environment
Результат Neos\Flow\Utility\Environment

$output публичное свойство

public array $output
Результат array

$packageManager защищенное свойство

protected PackageManagerInterface,Neos\Flow\Package $packageManager
Результат Neos\Flow\Package\PackageManagerInterface

$settings защищенное свойство

protected array $settings
Результат array