class Preflight (View source)

The Drush preflight determines what needs to be done for this request.

The preflight happens after Drush has loaded its autoload file, but prior to loading Drupal's autoload file and setting up the DI container.

  • Pre-parse commandline arguments
  • Read configuration .yml files
  • Determine the site to use

Properties

protected Environment $environment
protected PreflightVerify $verify
protected ConfigLocator $configLocator
protected DrupalFinder $drupalFinder
protected PreflightArgs $preflightArgs
protected SiteAliasManager $aliasManager
protected PreflightLog $logger

Methods

__construct(Environment $environment, $verify = null, $configLocator = null, $preflightLog = null)

Preflight constructor

logger()

No description

setLogger(PreflightLog $logger)

No description

init()

Perform preliminary initialization. This mostly involves setting up legacy systems.

remapOptions()

Remapping table for arguments. Anything found in a key here will be converted to the corresponding value entry.

remapCommandAliases()

Symfony Console dislikes certain command aliases, because they are too similar to other Drush commands that contain the same characters. To avoid the "I don't know which command you mean"-type errors, we will replace problematic aliases with their longhand equivalents.

preflightArgs($argv)

Preprocess the args, removing any @sitealias that may be present.

prepareConfig(Environment $environment)

Create the initial config locator object, and inject any needed settings, paths and so on into it.

createInput()

No description

getCommandFilePaths()

No description

loadSiteAutoloader()

No description

config()

No description

bool
preflight($argv)

No description

findSelectedSite()

Find the site the user selected based on --root or cwd. If neither of those result in a site, then we will fall back to the vendor path.

setSelectedSite($selectedRoot, $fallbackPath = false, $originalSelection = null)

Use the DrupalFinder to locate the Drupal Root + Composer Root at the selected root, or, if nothing is found there, at a fallback path.

DrupalFinder
drupalFinder()

Return the Drupal Finder

SiteAliasManager
aliasManager()

Return the alias manager

environment()

Return the environment

Details

__construct(Environment $environment, $verify = null, $configLocator = null, $preflightLog = null)

Preflight constructor

Parameters

Environment $environment
$verify
$configLocator
$preflightLog

PreflightLog logger()

Return Value

PreflightLog

setLogger(PreflightLog $logger)

Parameters

PreflightLog $logger

init()

Perform preliminary initialization. This mostly involves setting up legacy systems.

protected remapOptions()

Remapping table for arguments. Anything found in a key here will be converted to the corresponding value entry.

For example: --ssh-options='-i mysite_dsa' will become: -Dssh.options='-i mysite_dsa'

TODO: We could consider loading this from a file or some other source. However, this table is needed very early -- even earlier than config is loaded (since this is needed for preflighting the arguments, which can select config files to load). Hardcoding is probably best; we might want to move to another class, perhaps. We also need this prior to Dependency Injection, though.

Eventually, we might want to expose this table to some form of 'help' output, so folks can see the available conversions.

protected remapCommandAliases()

Symfony Console dislikes certain command aliases, because they are too similar to other Drush commands that contain the same characters. To avoid the "I don't know which command you mean"-type errors, we will replace problematic aliases with their longhand equivalents.

This should be fixed in Symfony Console.

preflightArgs($argv)

Preprocess the args, removing any @sitealias that may be present.

Arguments and options not used during preflight will be processed with an ArgvInput.

Parameters

$argv

prepareConfig(Environment $environment)

Create the initial config locator object, and inject any needed settings, paths and so on into it.

Parameters

Environment $environment

createInput()

getCommandFilePaths()

loadSiteAutoloader()

config()

bool preflight($argv)

Parameters

$argv

Return Value

bool True if the request was successfully redispatched remotely. False if the request should proceed.

protected findSelectedSite()

Find the site the user selected based on --root or cwd. If neither of those result in a site, then we will fall back to the vendor path.

protected setSelectedSite($selectedRoot, $fallbackPath = false, $originalSelection = null)

Use the DrupalFinder to locate the Drupal Root + Composer Root at the selected root, or, if nothing is found there, at a fallback path.

Parameters

$selectedRoot
$fallbackPath
$originalSelection

DrupalFinder drupalFinder()

Return the Drupal Finder

Return Value

DrupalFinder

SiteAliasManager aliasManager()

Return the alias manager

Return Value

SiteAliasManager

Environment environment()

Return the environment

Return Value

Environment