PHP Class DNEnvironment

This dataobject represents a target environment that source code can be deployed to. Permissions are controlled by environment, see the various many-many relationships.
Inheritance: extends DataObject
显示文件 Open project: silverstripe/deploynaut Class Usage Examples

Public Properties

Property Type Description
$db array
$has_many array
$has_one array
$many_many array
$searchable_fields array
$summary_fields array

Public Methods

Method Description
Backend ( ) : DeploymentBackend Get the deployment backend used for this environment.
CurrentBuild ( ) : false | DNDeployment Get the current deployed build for this environment
CurrentMenu ( ) Return the current object from $this->Menu() Good for making titles and things
DNData ( ) : DNData
DeployHistory ( string $orderBy = '' ) : ArrayList A list of past deployments.
DeploymentsLink ( ) : string This provides the link to the deployments depending on whether the feature flag for the new deployment is enabled.
IsNewDeployEnabled ( ) : boolean Check if the new deployment form is enabled by whether the project has it, falling back to environment variables on whether it's enabled.
Link ( string $action = '' ) : string
Menu ( )
array_to_viewabledata ( array $array ) : object Helper function to convert a multi-dimensional array (associative or indexed) to an {@link ArrayList} or {@link ArrayData} object structure, so that values can be used in templates.
canBackup ( Member | null $member = null ) : boolean Allows only selected {@link Member} objects to backup this {@link DNEnvironment} to a {@link DNDataArchive} file.
canDeleteArchive ( Member | null $member = null ) : boolean Allows only selected {@link Member} objects to delete {@link DNDataArchive} objects from this {@link DNEnvironment}.
canDeploy ( Member | null $member = null ) : boolean Allow deploy only to some people.
canDownloadArchive ( Member | null $member = null ) : boolean Allows only selected {@link Member} objects to download {@link DNDataArchive} objects from this {@link DNEnvironment}.
canRestore ( Member | null $member = null ) : boolean Allows only selected {@link Member} objects to restore {@link DNDataArchive} objects into this {@link DNEnvironment}.
canUploadArchive ( Member | null $member = null ) : boolean Allows only selected {@link Member} objects to upload {@link DNDataArchive} objects linked to this {@link DNEnvironment}.
canView ( Member | null $member = null ) : boolean Environments are only viewable by people that can view the environment.
create_from_path ( string $path ) : DNEnvironment Used by the sync task
getArchiveDeletersList ( ) : string Get a string of groups/people that are allowed to delete {@link DNDataArchive} objects from this environment.
getArchiveDownloadersList ( ) : string Get a string of groups/people that are allowed to download {@link DNDataArchive} objects from this environment.
getArchiveUploadersList ( ) : string Get a string of groups/people that are allowed to upload {@link DNDataArchive} objects linked to this environment.
getBareDefaultURL ( )
getBareURL ( )
getCMSFields ( ) : FieldList
getCanBackupMembersList ( ) : string Get a string of groups/people that are allowed to backup {@link DNDataArchive} objects from this environment.
getCanRestoreMembersList ( ) : string Get a string of groups/people that are allowed to restore {@link DNDataArchive} objects into this environment.
getCannotDeployMessage ( ) : string Provide reason why the user cannot deploy.
getCommit ( string $sha ) : Gitonomy\Git\Commit This is a proxy call to gitonmy that caches the information per project and sha
getCommitMessage ( Gitonomy\Git\Commit $commit )
getCommitSubjectMessage ( Gitonomy\Git\Commit $commit )
getCommitTags ( Gitonomy\Git\Commit $commit )
getConfigFilename ( ) : string Returns the path to the ruby config file
getDefaultURL ( ) URL for the environment that can be used if no explicit URL is set.
getDeployStrategy ( SS_HTTPRequest $request ) : DeploymentStrategy
getDeployersList ( ) : string Get a string of groups/people that are allowed to deploy to this environment.
getFullName ( string $separator = ':' ) : string Return a name for this environment.
getSupportedOptions ( ) : ArrayList Return the supported options for this environment.
isCurrent ( ) : boolean Is this environment currently at the root level of the controller that handles it?
isSection ( ) : boolean Is this environment currently in a controller that is handling it or performing a sub-task?
onAfterDelete ( ) Delete any related config files
onAfterWrite ( )
onBeforeWrite ( )
runningDeployments ( ) : DataList Fetchs all deployments in progress. Limits to 1 hour to prevent deployments if an old deployment is stuck.

Protected Methods

Method Description
buildPermissionField ( string $groupField, string $memberField, array $groups, array $members ) : FieldGroup Build a set of multi-select fields for assigning permissions to a pair of group and member many_many relations
checkEnvironmentPath ( ) Ensure that environment paths are setup on the local filesystem
envFileExists ( ) : boolean
getCommitData ( string $sha ) : array
getEnvironmentConfig ( ) : string
setDeployConfigurationFields ( FieldList &$fields )
validate ( )
writeConfigFile ( ) Write the deployment config file to filesystem

Method Details

Backend() public method

Enforces compliance with the allowed_backends setting; if the DNEnvironment.BackendIdentifier value is illegal then that value is ignored.
public Backend ( ) : DeploymentBackend
return DeploymentBackend

CurrentBuild() public method

Dear people of the future: If you are looking to optimize this, simply create a CurrentBuildSHA(), which can be a lot faster. I presume you came here because of the Project display template, which only needs a SHA.
public CurrentBuild ( ) : false | DNDeployment
return false | DNDeployment

CurrentMenu() public method

Return the current object from $this->Menu() Good for making titles and things
public CurrentMenu ( )

DNData() public method

public DNData ( ) : DNData
return DNData

DeployHistory() public method

A list of past deployments.
public DeployHistory ( string $orderBy = '' ) : ArrayList
$orderBy string - the name of a DB column to sort in descending order
return ArrayList

IsNewDeployEnabled() public method

Check if the new deployment form is enabled by whether the project has it, falling back to environment variables on whether it's enabled.
public IsNewDeployEnabled ( ) : boolean
return boolean

Menu() public method

public Menu ( )

array_to_viewabledata() public static method

Helper function to convert a multi-dimensional array (associative or indexed) to an {@link ArrayList} or {@link ArrayData} object structure, so that values can be used in templates.
public static array_to_viewabledata ( array $array ) : object
$array array The (single- or multi-dimensional) array to convert
return object Either an {@link ArrayList} or {@link ArrayData} object, or the original item ($array) if $array isn't an array.

buildPermissionField() protected method

Build a set of multi-select fields for assigning permissions to a pair of group and member many_many relations
protected buildPermissionField ( string $groupField, string $memberField, array $groups, array $members ) : FieldGroup
$groupField string Group field name
$memberField string Member field name
$groups array List of groups
$members array List of members
return FieldGroup

canBackup() public method

Allows only selected {@link Member} objects to backup this {@link DNEnvironment} to a {@link DNDataArchive} file.
public canBackup ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can backup, and false if they can't.

canDeleteArchive() public method

Allows only selected {@link Member} objects to delete {@link DNDataArchive} objects from this {@link DNEnvironment}.
public canDeleteArchive ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can delete archives from this environment, false if they can't.

canDeploy() public method

Allow deploy only to some people.
public canDeploy ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canDownloadArchive() public method

Allows only selected {@link Member} objects to download {@link DNDataArchive} objects from this {@link DNEnvironment}.
public canDownloadArchive ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can download archives from this environment, false if they can't.

canRestore() public method

Allows only selected {@link Member} objects to restore {@link DNDataArchive} objects into this {@link DNEnvironment}.
public canRestore ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can restore, and false if they can't.

canUploadArchive() public method

Note: This is not uploading them to the actual environment itself (e.g. uploading to the live site) - it is the process of uploading a *.sspak file into Deploynaut for later 'restoring' to an environment. See {@link self::canRestore()}.
public canUploadArchive ( Member | null $member = null ) : boolean
$member Member | null The {@link Member} object to test against. If null, uses Member::currentMember();
return boolean true if $member can upload archives linked to this environment, false if they can't.

canView() public method

Environments are only viewable by people that can view the environment.
public canView ( Member | null $member = null ) : boolean
$member Member | null
return boolean

checkEnvironmentPath() protected method

Ensure that environment paths are setup on the local filesystem
protected checkEnvironmentPath ( )

create_from_path() public static method

Used by the sync task
public static create_from_path ( string $path ) : DNEnvironment
$path string
return DNEnvironment

envFileExists() protected method

protected envFileExists ( ) : boolean
return boolean

getArchiveDeletersList() public method

Get a string of groups/people that are allowed to delete {@link DNDataArchive} objects from this environment.
public getArchiveDeletersList ( ) : string
return string

getArchiveDownloadersList() public method

Get a string of groups/people that are allowed to download {@link DNDataArchive} objects from this environment.

getArchiveUploadersList() public method

Get a string of groups/people that are allowed to upload {@link DNDataArchive} objects linked to this environment.
public getArchiveUploadersList ( ) : string
return string

getBareDefaultURL() public method

public getBareDefaultURL ( )

getBareURL() public method

public getBareURL ( )

getCMSFields() public method

public getCMSFields ( ) : FieldList
return FieldList

getCanBackupMembersList() public method

Get a string of groups/people that are allowed to backup {@link DNDataArchive} objects from this environment.
public getCanBackupMembersList ( ) : string
return string

getCanRestoreMembersList() public method

Get a string of groups/people that are allowed to restore {@link DNDataArchive} objects into this environment.
public getCanRestoreMembersList ( ) : string
return string

getCannotDeployMessage() public method

Provide reason why the user cannot deploy.
public getCannotDeployMessage ( ) : string
return string

getCommit() public method

This is a proxy call to gitonmy that caches the information per project and sha
public getCommit ( string $sha ) : Gitonomy\Git\Commit
$sha string
return Gitonomy\Git\Commit

getCommitData() protected method

protected getCommitData ( string $sha ) : array
$sha string
return array

getCommitMessage() public method

public getCommitMessage ( Gitonomy\Git\Commit $commit )
$commit Gitonomy\Git\Commit

getCommitSubjectMessage() public method

public getCommitSubjectMessage ( Gitonomy\Git\Commit $commit )
$commit Gitonomy\Git\Commit

getCommitTags() public method

public getCommitTags ( Gitonomy\Git\Commit $commit )
$commit Gitonomy\Git\Commit

getConfigFilename() public method

Returns the path to the ruby config file
public getConfigFilename ( ) : string
return string

getDefaultURL() public method

URL for the environment that can be used if no explicit URL is set.
public getDefaultURL ( )

getDeployStrategy() public method

public getDeployStrategy ( SS_HTTPRequest $request ) : DeploymentStrategy
$request SS_HTTPRequest
return DeploymentStrategy

getDeployersList() public method

Used in DNRoot_project.ss to list {@link Member}s who have permission to perform this action.
public getDeployersList ( ) : string
return string

getEnvironmentConfig() protected method

protected getEnvironmentConfig ( ) : string
return string

getFullName() public method

Return a name for this environment.
public getFullName ( string $separator = ':' ) : string
$separator string The string used when concatenating project with env name
return string

getSupportedOptions() public method

Return the supported options for this environment.
public getSupportedOptions ( ) : ArrayList
return ArrayList

isCurrent() public method

Is this environment currently at the root level of the controller that handles it?
public isCurrent ( ) : boolean
return boolean

isSection() public method

Is this environment currently in a controller that is handling it or performing a sub-task?
public isSection ( ) : boolean
return boolean

onAfterDelete() public method

Delete any related config files
public onAfterDelete ( )

onAfterWrite() public method

public onAfterWrite ( )

onBeforeWrite() public method

public onBeforeWrite ( )

runningDeployments() public method

Fetchs all deployments in progress. Limits to 1 hour to prevent deployments if an old deployment is stuck.
public runningDeployments ( ) : DataList
return DataList

setDeployConfigurationFields() protected method

protected setDeployConfigurationFields ( FieldList &$fields )
$fields FieldList

validate() protected method

protected validate ( )

writeConfigFile() protected method

Write the deployment config file to filesystem
protected writeConfigFile ( )

Property Details

$db public_oe static_oe property

public static array $db
return array

$has_many public_oe static_oe property

public static array $has_many
return array

$has_one public_oe static_oe property

public static array $has_one
return array

$many_many public_oe static_oe property

public static array $many_many
return array

$searchable_fields public_oe static_oe property

public static array $searchable_fields
return array

$summary_fields public_oe static_oe property

public static array $summary_fields
return array