class PreflightArgs extends Config implements PreflightArgsInterface (View source)

Storage for arguments preprocessed during preflight.

Holds @sitealias, if present, and a limited number of global options.

TODO: The methods here with >~3 lines of logic could be refactored into a couple of different classes e.g. a helper to convert preflight args to configuration, and another to prepare the input object.

Constants

DRUSH_CONFIG_PATH_NAMESPACE

DRUSH_RUNTIME_CONTEXT_NAMESPACE

ALIAS

ALIAS_PATH

COMMAND_PATH

CONFIG_PATH

COVERAGE_FILE

LOCAL

ROOT

URI

SIMULATE

BACKEND

STRICT

DEBUG

Properties

protected array $args
protected string $homeDir
protected $commandName

Methods

string
homeDir()

No description

setHomeDir(string $homeDir)

No description

__construct(array $data = [])

PreflightArgs constructor

optionsWithValues()

No description

adjustHelpOption()

If the user enters '--help' or '-h', thrown that option away and add a 'help' command to the beginning of the argument list.

optionConfigMap()

Map of option key to the corresponding config key to store the preflight option in. The values of the config items in this map must be BOOLEANS or STRINGS.

optionConfigPathMap()

Map of path option keys to the corresponding config key to store the preflight option in. The values of the items in this map must be STRINGS or ARRAYS OF STRINGS.

applyToConfig(ConfigInterface $config)

No description

args()

No description

applicationPath()

No description

commandName()

No description

setCommandName($commandName)

No description

addArg(string $arg)

No description

passArgs($args)

No description

alias()

No description

hasAlias()

No description

setAlias(string $alias)

No description

selectedSite($default = false)

Get the selected site. Here, the default will typically be the cwd.

setDebug($value)

No description

setSelectedSite($root)

Set the selected site.

uri($default = false)

Get the selected uri

hasUri()

No description

setUri($uri)

Set the uri option

configPaths()

Get the config path where drush.yml files may be found

addConfigPath(string $path)

Add another location where drush.yml files may be found

mergeConfigPaths(string[] $configPaths)

Add multiple additional locations where drush.yml files may be found.

aliasPaths()

Get the alias paths where drush site.site.yml files may be found

addAliasPath(string $path)

Set one more path where aliases may be found.

mergeAliasPaths(string $aliasPaths)

Add multiple additional locations for alias paths.

commandPaths()

Get the path where Drush commandfiles e.g. FooCommands.php may be found.

addCommandPath(string $path)

Add one more path where commandfiles might be found.

mergeCommandPaths($commandPaths)

Add multiple paths where commandfiles might be found.

isLocal()

Determine whether Drush is in "local" mode

setLocal(bool $isLocal)

Set local mode

isSimulated()

Determine whether Drush is in "simulated" mode.

setSimulate($simulate)

Set simulated mode

isBackend()

Determine whether Drush was placed in simulated mode.

setBackend(bool $backend)

Set backend mode

coverageFile()

Get the path to the coverage file.

setCoverageFile(string $coverageFile)

Set the coverage file path.

isStrict()

Determine whether Drush is in "strict" mode or not.

setStrict(bool $strict)

Set strict mode.

string[]
getOptionNameList(array $argv)

Search through the provided argv list, and return just the option name of any item that is an option.

createInput()

Create a Symfony Input object.

An
readStdinOptions()

Read options fron STDIN during POST requests.

Details

string homeDir()

Return Value

string

setHomeDir(string $homeDir)

Parameters

string $homeDir

__construct(array $data = [])

PreflightArgs constructor

Parameters

array $data Initial data (not usually used)

optionsWithValues()

adjustHelpOption()

If the user enters '--help' or '-h', thrown that option away and add a 'help' command to the beginning of the argument list.

protected optionConfigMap()

Map of option key to the corresponding config key to store the preflight option in. The values of the config items in this map must be BOOLEANS or STRINGS.

protected optionConfigPathMap()

Map of path option keys to the corresponding config key to store the preflight option in. The values of the items in this map must be STRINGS or ARRAYS OF STRINGS.

applyToConfig(ConfigInterface $config)

Parameters

ConfigInterface $config The configuration object to inject data into

See also

Environment::exportConfigData(), which also exports information to config.

args()

applicationPath()

commandName()

setCommandName($commandName)

Parameters

$commandName

addArg(string $arg)

Parameters

string $arg One argument

passArgs($args)

Parameters

$args

alias()

hasAlias()

setAlias(string $alias)

Parameters

string $alias The alias name '@site'

selectedSite($default = false)

Get the selected site. Here, the default will typically be the cwd.

Parameters

$default

setDebug($value)

Parameters

$value

setSelectedSite($root)

Set the selected site.

Parameters

$root

uri($default = false)

Get the selected uri

Parameters

$default

hasUri()

setUri($uri)

Set the uri option

Parameters

$uri

configPaths()

Get the config path where drush.yml files may be found

addConfigPath(string $path)

Add another location where drush.yml files may be found

Parameters

string $path

mergeConfigPaths(string[] $configPaths)

Add multiple additional locations where drush.yml files may be found.

Parameters

string[] $configPaths

aliasPaths()

Get the alias paths where drush site.site.yml files may be found

addAliasPath(string $path)

Set one more path where aliases may be found.

Parameters

string $path

mergeAliasPaths(string $aliasPaths)

Add multiple additional locations for alias paths.

Parameters

string $aliasPaths

commandPaths()

Get the path where Drush commandfiles e.g. FooCommands.php may be found.

addCommandPath(string $path)

Add one more path where commandfiles might be found.

Parameters

string $path

mergeCommandPaths($commandPaths)

Add multiple paths where commandfiles might be found.

Parameters

$commandPaths

isLocal()

Determine whether Drush is in "local" mode

setLocal(bool $isLocal)

Set local mode

Parameters

bool $isLocal

isSimulated()

Determine whether Drush is in "simulated" mode.

setSimulate($simulate)

Set simulated mode

Parameters

$simulate

isBackend()

Determine whether Drush was placed in simulated mode.

setBackend(bool $backend)

Set backend mode

Parameters

bool $backend

coverageFile()

Get the path to the coverage file.

setCoverageFile(string $coverageFile)

Set the coverage file path.

Parameters

string $coverageFile

isStrict()

Determine whether Drush is in "strict" mode or not.

setStrict(bool $strict)

Set strict mode.

Parameters

bool $strict

protected string[] getOptionNameList(array $argv)

Search through the provided argv list, and return just the option name of any item that is an option.

Parameters

array $argv e.g. ['foo', '--bar=baz', 'boz']

Return Value

string[] e.g. ['bar']

createInput()

Create a Symfony Input object.

protected An readStdinOptions()

Read options fron STDIN during POST requests.

This function will read any text from the STDIN pipe, and attempts to generate an associative array if valid JSON was received.

Return Value

An associative array of options, if successfull. Otherwise an empty array.