class DoctrineCommandController extends CommandController (View source)

Command controller for tasks related to Doctrine

Properties

protected Request $request from  CommandController
protected Response $response from  CommandController
protected Arguments $arguments from  CommandController
protected string $commandMethodName

Name of the command method

from  CommandController
protected ObjectManagerInterface $objectManager from  CommandController
protected CommandManager $commandManager from  CommandController
protected ConsoleOutput $output from  CommandController
protected array $settings
protected Service $doctrineService
protected PackageManager $packageManager
protected ThrowableStorageInterface $throwableStorage
protected LoggerInterface $logger

Methods

__construct()

Constructs the command controller

void
injectCommandManager(CommandManager $commandManager)

No description

void
injectObjectManager(ObjectManagerInterface $objectManager)

Injects the reflection service

void
processRequest(Request $request, Response $response)

Processes a command line request.

string
resolveCommandMethodName()

Resolves and checks the current command method name

void
initializeCommandMethodArguments()

Initializes the arguments array of this controller by creating an empty argument object for each of the method arguments found in the designated command method.

void
mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

void
forward(string $commandName, string $controllerObjectName = null, array $arguments = [])

Forwards the request to another command and / or CommandController.

void
callCommandMethod()

Calls the specified command method and passes the arguments.

string
getFlowInvocationString()

Returns the CLI Flow command depending on the environment

void
output(string $text, array $arguments = [])

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

void
outputLine(string $text = '', array $arguments = [])

Outputs specified text to the console window and appends a line break

void
outputFormatted(string $text = '', array $arguments = [], int $leftPadding = 0)

Formats the given text to fit into MAXIMUM_LINE_LENGTH and outputs it to the console window

quit(int $exitCode = 0)

Exits the CLI through the dispatcher and makes sure that Flow is properly shut down.

sendAndExit(int $exitCode = 0)

Sends the response and exits the CLI without any further code execution Should be used for commands that flush code caches.

void
injectSettings(array $settings)

Injects the Flow settings, only the persistence part is kept for further use

void
injectLogger(LoggerInterface $logger)

No description

void
compileProxiesCommand()

Compile the Doctrine proxy classes

void
validateCommand()

Validate the class/table mappings

void
createCommand(string $output = null)

Create the database schema

void
updateCommand(bool $unsafeMode = false, string $output = null)

Update the database schema

void
entityStatusCommand(bool $dumpMappingData = false, string $entityClassName = null)

Show the current status of entities and mappings

void
dqlCommand(int $depth = 3, string $hydrationMode = 'array', int $offset = null, int $limit = null)

Run arbitrary DQL and display results

void
migrationStatusCommand(bool $showMigrations = false)

Show the current migration status

void
migrateCommand(string $version = 'latest', string $output = null, bool $dryRun = false, bool $quiet = false)

Migrate the database schema

void
emitAfterDatabaseMigration()

No description

void
migrationExecuteCommand(string $version, string $direction = 'up', string $output = null, bool $dryRun = false)

Execute a single migration

void
migrationVersionCommand(string $version, bool $add = false, bool $delete = false)

Mark/unmark migrations as migrated

void
migrationGenerateCommand(bool $diffAgainstCurrent = true, string $filterExpression = null, bool $force = false)

Generate a new migration

void
handleException(Exception $exception)

Output an error message and log the exception.

bool
isDatabaseConfigured()

No description

Details

__construct()

Constructs the command controller

void injectCommandManager(CommandManager $commandManager)

No description

Parameters

CommandManager $commandManager

Return Value

void

void injectObjectManager(ObjectManagerInterface $objectManager)

Injects the reflection service

Parameters

ObjectManagerInterface $objectManager

Return Value

void

void processRequest(Request $request, Response $response)

Processes a command line request.

Parameters

Request $request

The request object

Response $response

The response, modified by the controller

Return Value

void

Exceptions

InvalidArgumentTypeException
NoSuchCommandException

protected string resolveCommandMethodName()

Resolves and checks the current command method name

Note: The resulting command method name might not have the correct case, which isn't a problem because PHP is case insensitive regarding method names.

Return Value

string

Method name of the current command

Exceptions

NoSuchCommandException

protected void initializeCommandMethodArguments()

Initializes the arguments array of this controller by creating an empty argument object for each of the method arguments found in the designated command method.

Return Value

void

Exceptions

InvalidArgumentTypeException

protected void mapRequestArgumentsToControllerArguments()

Maps arguments delivered by the request object to the local controller arguments.

Return Value

void

protected void forward(string $commandName, string $controllerObjectName = null, array $arguments = [])

Forwards the request to another command and / or CommandController.

Request is directly transferred to the other command / controller without the need for a new request.

Parameters

string $commandName
string $controllerObjectName
array $arguments

Return Value

void

Exceptions

StopCommandException

protected void callCommandMethod()

Calls the specified command method and passes the arguments.

If the command returns a string, it is appended to the content in the response object. If the command doesn't return anything and a valid view exists, the view is rendered automatically.

Return Value

void

string getFlowInvocationString()

Returns the CLI Flow command depending on the environment

Return Value

string

protected void output(string $text, array $arguments = [])

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

Return Value

void

See also

http://www.php.net/sprintf

protected void outputLine(string $text = '', array $arguments = [])

Outputs specified text to the console window and appends a line break

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

Return Value

void

See also

output()
outputLines()

protected void outputFormatted(string $text = '', array $arguments = [], int $leftPadding = 0)

Formats the given text to fit into MAXIMUM_LINE_LENGTH and outputs it to the console window

Parameters

string $text

Text to output

array $arguments

Optional arguments to use for sprintf

int $leftPadding

The number of spaces to use for indentation

Return Value

void

See also

outputLine()

protected quit(int $exitCode = 0)

Exits the CLI through the dispatcher and makes sure that Flow is properly shut down.

If your command relies on functionality which is triggered through the Bootstrap shutdown (such as the persistence framework), you must use quit() instead of exit().

Parameters

int $exitCode

Exit code to return on exit (see http://www.php.net/exit)

Exceptions

StopCommandException

protected sendAndExit(int $exitCode = 0)

Sends the response and exits the CLI without any further code execution Should be used for commands that flush code caches.

Parameters

int $exitCode

Exit code to return on exit

void injectSettings(array $settings)

Injects the Flow settings, only the persistence part is kept for further use

Parameters

array $settings

Return Value

void

void injectLogger(LoggerInterface $logger)

No description

Parameters

LoggerInterface $logger

Return Value

void

void compileProxiesCommand()

Compile the Doctrine proxy classes

Return Value

void

Exceptions

Exception
FilesException

void validateCommand()

Validate the class/table mappings

Checks if the current class model schema is valid. Any inconsistencies in the relations between models (for example caused by wrong or missing annotations) will be reported.

Note that this does not check the table structure in the database in any way.

Return Value

void

Exceptions

StopCommandException

See also

neos.flow:doctrine:entitystatus

void createCommand(string $output = null)

Create the database schema

Creates a new database schema based on the current mapping information.

It expects the database to be empty, if tables that are to be created already exist, this will lead to errors.

Parameters

string $output

A file to write SQL to, instead of executing it

Return Value

void

Exceptions

ToolsException
StopCommandException

See also

neos.flow:doctrine:update
neos.flow:doctrine:migrate

void updateCommand(bool $unsafeMode = false, string $output = null)

Update the database schema

Updates the database schema without using existing migrations.

It will not drop foreign keys, sequences and tables, unless --unsafe-mode is set.

Parameters

bool $unsafeMode

If set, foreign keys, sequences and tables can potentially be dropped.

string $output

A file to write SQL to, instead of executing the update directly

Return Value

void

Exceptions

StopCommandException

See also

neos.flow:doctrine:create
neos.flow:doctrine:migrate

void entityStatusCommand(bool $dumpMappingData = false, string $entityClassName = null)

Show the current status of entities and mappings

Shows basic information about which entities exist and possibly if their mapping information contains errors or not.

To run a full validation, use the validate command.

Parameters

bool $dumpMappingData

If set, the mapping data will be output

string $entityClassName

If given, the mapping data for just this class will be output

Return Value

void

Exceptions

ORMException

See also

neos.flow:doctrine:validate

void dqlCommand(int $depth = 3, string $hydrationMode = 'array', int $offset = null, int $limit = null)

Run arbitrary DQL and display results

Any DQL queries passed after the parameters will be executed, the results will be output:

doctrine:dql --limit 10 'SELECT a FROM Neos\Flow\Security\Account a'

Parameters

int $depth

How many levels deep the result should be dumped

string $hydrationMode

One of: object, array, scalar, single-scalar, simpleobject

int $offset

Offset the result by this number

int $limit

Limit the result to this number

Return Value

void

Exceptions

StopCommandException

void migrationStatusCommand(bool $showMigrations = false)

Show the current migration status

Displays the migration configuration as well as the number of available, executed and pending migrations.

Parameters

bool $showMigrations

Output a list of all migrations and their status

Return Value

void

Exceptions

StopCommandException
DBALException

See also

neos.flow:doctrine:migrate
neos.flow:doctrine:migrationexecute
neos.flow:doctrine:migrationgenerate
neos.flow:doctrine:migrationversion

void migrateCommand(string $version = 'latest', string $output = null, bool $dryRun = false, bool $quiet = false)

Migrate the database schema

Adjusts the database structure by applying the pending migrations provided by currently active packages.

Parameters

string $version

The version to migrate to

string $output

A file to write SQL to, instead of executing it

bool $dryRun

Whether to do a dry run or not

bool $quiet

If set, only the executed migration versions will be output, one per line

Return Value

void

Exceptions

StopCommandException

See also

neos.flow:doctrine:migrationstatus
neos.flow:doctrine:migrationexecute
neos.flow:doctrine:migrationgenerate
neos.flow:doctrine:migrationversion

protected void emitAfterDatabaseMigration()

No description

Return Value

void

void migrationExecuteCommand(string $version, string $direction = 'up', string $output = null, bool $dryRun = false)

Execute a single migration

Manually runs a single migration in the given direction.

Parameters

string $version

The migration to execute

string $direction

Whether to execute the migration up (default) or down

string $output

A file to write SQL to, instead of executing it

bool $dryRun

Whether to do a dry run or not

Return Value

void

Exceptions

StopCommandException

See also

neos.flow:doctrine:migrate
neos.flow:doctrine:migrationstatus
neos.flow:doctrine:migrationgenerate
neos.flow:doctrine:migrationversion

void migrationVersionCommand(string $version, bool $add = false, bool $delete = false)

Mark/unmark migrations as migrated

If all is given as version, all available migrations are marked as requested.

Parameters

string $version

The migration to execute

bool $add

The migration to mark as migrated

bool $delete

The migration to mark as not migrated

Return Value

void

Exceptions

StopCommandException
Exception

See also

neos.flow:doctrine:migrate
neos.flow:doctrine:migrationstatus
neos.flow:doctrine:migrationexecute
neos.flow:doctrine:migrationgenerate

void migrationGenerateCommand(bool $diffAgainstCurrent = true, string $filterExpression = null, bool $force = false)

Generate a new migration

If $diffAgainstCurrent is true (the default), it generates a migration file with the diff between current DB structure and the found mapping metadata.

Otherwise an empty migration skeleton is generated.

Only includes tables/sequences matching the $filterExpression regexp when diffing models and existing schema. Include delimiters in the expression! The use of

--filter-expression '/^acme_com/'

would only create a migration touching tables starting with "acme_com".

Note: A filter-expression will overrule any filter configured through the Neos.Flow.persistence.doctrine.migrations.ignoredTables setting

Parameters

bool $diffAgainstCurrent

Whether to base the migration on the current schema structure

string $filterExpression

Only include tables/sequences matching the filter expression regexp

bool $force

Generate migrations even if there are migrations left to execute

Return Value

void

Exceptions

DBALException
StopCommandException
FilesException

See also

neos.flow:doctrine:migrate
neos.flow:doctrine:migrationstatus
neos.flow:doctrine:migrationexecute
neos.flow:doctrine:migrationversion

protected void handleException(Exception $exception)

Output an error message and log the exception.

Parameters

Exception $exception

Return Value

void

Exceptions

StopCommandException

protected bool isDatabaseConfigured()

No description

Return Value

bool