PHP Class Platformsh\Cli\Command\CommandBase

Inheritance: extends Symfony\Component\Console\Command\Command, implements Platformsh\Cli\Command\CanHideInListInterface, use trait Platformsh\Cli\Command\HasExamplesTrait
显示文件 Open project: commerceguys/platform-cli Class Usage Examples

Protected Properties

Property Type Description
$canBeRunMultipleTimes
$config Platformsh\Cli\CliConfig
$envArgName
$hiddenInList
$interactive boolean
$local
$localProject Platformsh\Cli\Local\LocalProject | null
$output Symfony\Component\Console\Output\OutputInterface | null
$runningViaMulti
$stdErr Symfony\Component\Console\Output\OutputInterface | null

Public Methods

Method Description
__construct ( $name = null )
canBeRunMultipleTimes ( )
getCurrentEnvironment ( Platformsh\Client\Model\Project $expectedProject = null, boolean | null $refresh = null ) : Platformsh\Client\Model\Environment | false Get the current environment if the user is in a project directory.
getCurrentProject ( ) : Platformsh\Client\Model\Project | false Get the current project if the user is in a project directory.
getHelper ( $name )
getProcessedHelp ( )
getProjectRoot ( ) : string | false
getSynopsis ( $short = false )
getVisibleAliases ( ) : array Get aliases that should be visible in help.
isHiddenInList ( )
isLocal ( ) : boolean Is this a local command? (if it does not make API requests)
login ( ) Log in the user.
setRunningViaMulti ( $runningViaMulti = true )
updateDrushAliases ( EnvironmentsChangedEvent $event ) Update the user's local Drush aliases.

Protected Methods

Method Description
addAppOption ( ) : CommandBase Add the --app option.
addEnvironmentOption ( ) : CommandBase Add the --environment option.
addNoWaitOption ( string $description = 'Do not wait for the operation to complete' ) : CommandBase Add the --no-wait option.
addProjectOption ( ) : CommandBase Add the --project and --host options.
api ( ) : Api Set up the API object.
checkUpdates ( boolean $reset = false ) Check for updates.
debug ( string $message ) Print a message if debug output is enabled.
getHomeDir ( ) : string
getSelectedEnvironment ( ) : Platformsh\Client\Model\Environment Get the environment selected by the user.
getSelectedProject ( ) : Platformsh\Client\Model\Project Get the project selected by the user.
getSessionsDir ( ) : string
hasSelectedEnvironment ( ) : boolean Check whether a single environment is selected.
hasSelectedProject ( ) : boolean Check whether a project is selected.
initialize ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
interact ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
isTerminal ( Symfony\Component\Console\Output\OutputInterface $output ) : boolean Detect automatically whether the output is a TTY terminal.
parseProjectId ( string $url ) : array Parse the project ID and possibly other details from a provided URL.
promptLegacyMigrate ( ) Prompt the user to migrate from the legacy project file structure.
rebuildWarning ( ) Warn the user that the remote environment needs rebuilding.
runOtherCommand ( string $name, array $arguments = [], Symfony\Component\Console\Output\OutputInterface $output = null ) : integer Run another CLI command.
selectApp ( Symfony\Component\Console\Input\InputInterface $input, callable $filter = null ) : string | null Find the name of the app the user wants to use for an SSH command.
selectEnvironment ( string | null $environmentId = null ) : Platformsh\Client\Model\Environment Select the current environment for the user.
selectProject ( string $projectId = null, string $host = null ) : Platformsh\Client\Model\Project Select the project for the user, based on input or the environment.
selectedProjectIsCurrent ( ) : boolean
setHiddenAliases ( array $hiddenAliases ) : CommandBase Add aliases that should be hidden from help.
setProjectRoot ( string $root )
validateInput ( Symfony\Component\Console\Input\InputInterface $input, boolean $envNotRequired = false )

Method Details

__construct() public method

public __construct ( $name = null )

addAppOption() protected method

Add the --app option.
protected addAppOption ( ) : CommandBase
return CommandBase

addEnvironmentOption() protected method

Add the --environment option.
protected addEnvironmentOption ( ) : CommandBase
return CommandBase

addNoWaitOption() protected method

Add the --no-wait option.
protected addNoWaitOption ( string $description = 'Do not wait for the operation to complete' ) : CommandBase
$description string
return CommandBase

addProjectOption() protected method

Add the --project and --host options.
protected addProjectOption ( ) : CommandBase
return CommandBase

api() protected method

Set up the API object.
protected api ( ) : Api
return Platformsh\Cli\Api

canBeRunMultipleTimes() public method

checkUpdates() protected method

Check for updates.
protected checkUpdates ( boolean $reset = false )
$reset boolean

debug() protected method

Print a message if debug output is enabled.
protected debug ( string $message )
$message string

getCurrentEnvironment() public method

Get the current environment if the user is in a project directory.
public getCurrentEnvironment ( Platformsh\Client\Model\Project $expectedProject = null, boolean | null $refresh = null ) : Platformsh\Client\Model\Environment | false
$expectedProject Platformsh\Client\Model\Project The expected project.
$refresh boolean | null Whether to refresh the environments or projects cache.
return Platformsh\Client\Model\Environment | false The current environment.

getCurrentProject() public method

Get the current project if the user is in a project directory.
public getCurrentProject ( ) : Platformsh\Client\Model\Project | false
return Platformsh\Client\Model\Project | false The current project

getHelper() public method

public getHelper ( $name )

getHomeDir() protected method

protected getHomeDir ( ) : string
return string

getProcessedHelp() public method

Overrides the default method so that the description is not repeated twice.
public getProcessedHelp ( )

getProjectRoot() public method

public getProjectRoot ( ) : string | false
return string | false

getSelectedEnvironment() protected method

The project is selected via validateInput(), if there is an --environment option in the command.
protected getSelectedEnvironment ( ) : Platformsh\Client\Model\Environment
return Platformsh\Client\Model\Environment

getSelectedProject() protected method

The project is selected via validateInput(), if there is a --project option in the command.
protected getSelectedProject ( ) : Platformsh\Client\Model\Project
return Platformsh\Client\Model\Project

getSessionsDir() protected method

protected getSessionsDir ( ) : string
return string

getSynopsis() public method

public getSynopsis ( $short = false )

getVisibleAliases() public method

Get aliases that should be visible in help.
public getVisibleAliases ( ) : array
return array

hasSelectedEnvironment() protected method

Check whether a single environment is selected.
protected hasSelectedEnvironment ( ) : boolean
return boolean

hasSelectedProject() protected method

Check whether a project is selected.
protected hasSelectedProject ( ) : boolean
return boolean

initialize() protected method

protected initialize ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface

interact() protected method

protected interact ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface

isHiddenInList() public method

public isHiddenInList ( )

isLocal() public method

Is this a local command? (if it does not make API requests)
public isLocal ( ) : boolean
return boolean

isTerminal() protected method

Detect automatically whether the output is a TTY terminal.
protected isTerminal ( Symfony\Component\Console\Output\OutputInterface $output ) : boolean
$output Symfony\Component\Console\Output\OutputInterface
return boolean

login() public method

This is called via the 'login_required' event.
See also: Api::getClient()
public login ( )

parseProjectId() protected method

Parse the project ID and possibly other details from a provided URL.
protected parseProjectId ( string $url ) : array
$url string A web UI, API, or public URL of the project.
return array An array of containing at least a 'projectId'. Keys 'host', 'environmentId', and 'appId' will be either null or strings.

promptLegacyMigrate() protected method

If the input is interactive, the user will be asked to migrate up to once per hour. The time they were last asked will be stored in the project configuration. If the input is not interactive, the user will be warned (on every command run) that they should run the 'legacy-migrate' command.
protected promptLegacyMigrate ( )

rebuildWarning() protected method

Warn the user that the remote environment needs rebuilding.
protected rebuildWarning ( )

runOtherCommand() protected method

Run another CLI command.
protected runOtherCommand ( string $name, array $arguments = [], Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$name string The name of the other command.
$arguments array Arguments for the other command.
$output Symfony\Component\Console\Output\OutputInterface The output for the other command. Defaults to the current output.
return integer

selectApp() protected method

Find the name of the app the user wants to use for an SSH command.
protected selectApp ( Symfony\Component\Console\Input\InputInterface $input, callable $filter = null ) : string | null
$input Symfony\Component\Console\Input\InputInterface The user input object.
$filter callable A filter callback that takes one argument: a LocalApplication object.
return string | null The application name, or null if it could not be found.

selectEnvironment() protected method

Select the current environment for the user.
protected selectEnvironment ( string | null $environmentId = null ) : Platformsh\Client\Model\Environment
$environmentId string | null The environment ID specified by the user, or null to auto-detect the environment.
return Platformsh\Client\Model\Environment

selectProject() protected method

Select the project for the user, based on input or the environment.
protected selectProject ( string $projectId = null, string $host = null ) : Platformsh\Client\Model\Project
$projectId string
$host string
return Platformsh\Client\Model\Project

selectedProjectIsCurrent() protected method

protected selectedProjectIsCurrent ( ) : boolean
return boolean

setHiddenAliases() protected method

Add aliases that should be hidden from help.
See also: parent::setAliases()
protected setHiddenAliases ( array $hiddenAliases ) : CommandBase
$hiddenAliases array
return CommandBase

setProjectRoot() protected method

protected setProjectRoot ( string $root )
$root string

setRunningViaMulti() public method

public setRunningViaMulti ( $runningViaMulti = true )

updateDrushAliases() public method

This is called via the 'environments_changed' event.
See also: Api::getEnvironments()
public updateDrushAliases ( EnvironmentsChangedEvent $event )
$event Platformsh\Cli\Event\EnvironmentsChangedEvent

validateInput() protected method

protected validateInput ( Symfony\Component\Console\Input\InputInterface $input, boolean $envNotRequired = false )
$input Symfony\Component\Console\Input\InputInterface
$envNotRequired boolean

Property Details

$canBeRunMultipleTimes protected_oe property

protected $canBeRunMultipleTimes

$config protected_oe static_oe property

protected static CliConfig,Platformsh\Cli $config
return Platformsh\Cli\CliConfig

$envArgName protected_oe property

protected $envArgName

$hiddenInList protected_oe property

protected $hiddenInList

$interactive protected_oe static_oe property

protected static bool $interactive
return boolean

$local protected_oe property

protected $local

$localProject protected_oe property

protected LocalProject,Platformsh\Cli\Local|null $localProject
return Platformsh\Cli\Local\LocalProject | null

$output protected_oe property

protected OutputInterface,Symfony\Component\Console\Output|null $output
return Symfony\Component\Console\Output\OutputInterface | null

$runningViaMulti protected_oe property

protected $runningViaMulti

$stdErr protected_oe property

protected OutputInterface,Symfony\Component\Console\Output|null $stdErr
return Symfony\Component\Console\Output\OutputInterface | null