PHP Class Platformsh\Cli\Api

Datei anzeigen Open project: commerceguys/platform-cli Class Usage Examples

Protected Properties

Property Type Description
$apiToken string | null
$apiTokenType string
$cache Doctrine\Common\Cache\CacheProvider
$client Platformsh\Client\PlatformClient
$config CliConfig
$dispatcher null | Symfony\Component\EventDispatcher\EventDispatcherInterface
$sessionId string

Public Methods

Method Description
__construct ( CliConfig $config = null, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null ) Constructor.
clearCache ( ) Clear the cache.
clearEnvironmentsCache ( string $projectId ) Clear the environments cache for a project.
clearProjectsCache ( ) Clear the projects cache.
getAccount ( Platformsh\Client\Model\ProjectAccess $user, boolean $reset = false ) : array Get a user's account info.
getCache ( ) : CacheProvider
getClient ( boolean $autoLogin = true ) : Platformsh\Client\PlatformClient Get the API client object.
getEnvironment ( string $id, Platformsh\Client\Model\Project $project, boolean | null $refresh = null, boolean $tryMachineName = false ) : Platformsh\Client\Model\Environment | false Get a single environment.
getEnvironments ( Platformsh\Client\Model\Project $project, boolean | null $refresh = null, boolean $events = true ) : Platformsh\Client\Model\Environment[] Return the user's environments.
getMyAccount ( boolean $reset = false ) : array Get the current user's account info.
getNestedProperty ( Platformsh\Client\Model\Resource $resource, string $propertyPath, boolean $lazyLoad = true ) : mixed Get a nested property of a resource, via a dot-separated string path.
getProject ( string $id, string | null $host = null, boolean | null $refresh = null ) : Platformsh\Client\Model\Project | false Return the user's project with the given ID.
getProjectLabel ( Platformsh\Client\Model\Project $project, string | false $tag = 'info' ) : string Returns a project label.
getProjects ( boolean | null $refresh = null ) : Platformsh\Client\Model\Project[] Return the user's projects.
hasApiToken ( ) : boolean Returns whether the CLI is authenticating using an API token.
isLoggedIn ( ) : boolean
loadProjectAccessByEmail ( Platformsh\Client\Model\Project $project, string $email ) : Platformsh\Client\Model\ProjectAccess | false Load a project user ("project access" record) by email address.
sortResources ( array &$resources, string $propertyPath ) : Platformsh\Client\Model\Resource[] Sort resources.

Protected Methods

Method Description
getUserAgent ( ) : string Get an HTTP User Agent string representing this application.
loadTokenFromFile ( string $filename ) : string Load an API token from a file.
setUpCache ( )

Method Details

__construct() public method

Constructor.
public __construct ( CliConfig $config = null, Symfony\Component\EventDispatcher\EventDispatcherInterface $dispatcher = null )
$config CliConfig
$dispatcher Symfony\Component\EventDispatcher\EventDispatcherInterface

clearCache() public method

Clear the cache.
public clearCache ( )

clearEnvironmentsCache() public method

Use this after creating/deleting/updating environment(s).
public clearEnvironmentsCache ( string $projectId )
$projectId string

clearProjectsCache() public method

Clear the projects cache.
public clearProjectsCache ( )

getAccount() public method

Get a user's account info.
public getAccount ( Platformsh\Client\Model\ProjectAccess $user, boolean $reset = false ) : array
$user Platformsh\Client\Model\ProjectAccess
$reset boolean
return array An array containing 'email' and 'display_name'.

getCache() public method

public getCache ( ) : CacheProvider
return Doctrine\Common\Cache\CacheProvider

getClient() public method

Get the API client object.
public getClient ( boolean $autoLogin = true ) : Platformsh\Client\PlatformClient
$autoLogin boolean Whether to log in, if the client is not already authenticated (default: true).
return Platformsh\Client\PlatformClient

getEnvironment() public method

Get a single environment.
public getEnvironment ( string $id, Platformsh\Client\Model\Project $project, boolean | null $refresh = null, boolean $tryMachineName = false ) : Platformsh\Client\Model\Environment | false
$id string The environment ID to load.
$project Platformsh\Client\Model\Project The project.
$refresh boolean | null Whether to refresh the list of environments.
$tryMachineName boolean Whether to retry, treating the ID as a machine name.
return Platformsh\Client\Model\Environment | false The environment, or false if not found.

getEnvironments() public method

Return the user's environments.
public getEnvironments ( Platformsh\Client\Model\Project $project, boolean | null $refresh = null, boolean $events = true ) : Platformsh\Client\Model\Environment[]
$project Platformsh\Client\Model\Project The project.
$refresh boolean | null Whether to refresh the list.
$events boolean Whether to update Drush aliases if the list changes.
return Platformsh\Client\Model\Environment[] The user's environments.

getMyAccount() public method

Get the current user's account info.
public getMyAccount ( boolean $reset = false ) : array
$reset boolean
return array An array containing at least 'uuid', 'mail', and 'display_name'.

getNestedProperty() public static method

Get a nested property of a resource, via a dot-separated string path.
public static getNestedProperty ( Platformsh\Client\Model\Resource $resource, string $propertyPath, boolean $lazyLoad = true ) : mixed
$resource Platformsh\Client\Model\Resource
$propertyPath string
$lazyLoad boolean
return mixed

getProject() public method

Return the user's project with the given ID.
public getProject ( string $id, string | null $host = null, boolean | null $refresh = null ) : Platformsh\Client\Model\Project | false
$id string The project ID.
$host string | null The project's hostname.
$refresh boolean | null Whether to bypass the cache.
return Platformsh\Client\Model\Project | false

getProjectLabel() public method

Returns a project label.
public getProjectLabel ( Platformsh\Client\Model\Project $project, string | false $tag = 'info' ) : string
$project Platformsh\Client\Model\Project
$tag string | false
return string

getProjects() public method

Return the user's projects.
public getProjects ( boolean | null $refresh = null ) : Platformsh\Client\Model\Project[]
$refresh boolean | null Whether to refresh the list of projects.
return Platformsh\Client\Model\Project[] The user's projects, keyed by project ID.

getUserAgent() protected method

Get an HTTP User Agent string representing this application.
protected getUserAgent ( ) : string
return string

hasApiToken() public method

Returns whether the CLI is authenticating using an API token.
public hasApiToken ( ) : boolean
return boolean

isLoggedIn() public method

public isLoggedIn ( ) : boolean
return boolean

loadProjectAccessByEmail() public method

Load a project user ("project access" record) by email address.
public loadProjectAccessByEmail ( Platformsh\Client\Model\Project $project, string $email ) : Platformsh\Client\Model\ProjectAccess | false
$project Platformsh\Client\Model\Project
$email string
return Platformsh\Client\Model\ProjectAccess | false

loadTokenFromFile() protected method

Load an API token from a file.
protected loadTokenFromFile ( string $filename ) : string
$filename string A filename, either relative to the user config directory, or absolute.
return string

setUpCache() protected method

protected setUpCache ( )

sortResources() public static method

Sort resources.
public static sortResources ( array &$resources, string $propertyPath ) : Platformsh\Client\Model\Resource[]
$resources array
$propertyPath string
return Platformsh\Client\Model\Resource[]

Property Details

$apiToken protected_oe static_oe property

protected static string|null $apiToken
return string | null

$apiTokenType protected_oe static_oe property

protected static string $apiTokenType
return string

$cache protected_oe static_oe property

protected static CacheProvider,Doctrine\Common\Cache $cache
return Doctrine\Common\Cache\CacheProvider

$client protected_oe static_oe property

protected static PlatformClient,Platformsh\Client $client
return Platformsh\Client\PlatformClient

$config protected_oe property

protected CliConfig,Platformsh\Cli $config
return CliConfig

$dispatcher protected_oe property

protected null|EventDispatcherInterface,Symfony\Component\EventDispatcher $dispatcher
return null | Symfony\Component\EventDispatcher\EventDispatcherInterface

$sessionId protected_oe static_oe property

protected static string $sessionId
return string