PHP Class DNProject

Inheritance: extends DataObject
ファイルを表示 Open project: silverstripe/deploynaut Class Usage Examples

Protected Properties

Property Type Description
$_current_member_cache boolean | Member
$relation_cache array In-memory cache for currentBuilds per environment since fetching them from disk is pretty resource hungry.

Public Methods

Method Description
APILink ( string $action ) : string
CreateEnvironmentLink ( ) : string | null
CurrentMenu ( ) : DataObject Return the current object from $this->Menu() Good for making titles and things
DNBranchList ( ) : DNBranchList Provides a list of the branches in this project.
DNBuildList ( ) : DNReferenceList Provides a DNBuildList of builds found in this project.
DNData ( ) : DNData
DNEnvironmentList ( ) : ArrayList Provides a list of environments found in this project.
DNTagList ( ) : DNReferenceList Provides a list of the tags in this project.
DataArchives ( ) : DataList
DiskQuotaUsagePercent ( ) : integer Returns the current disk quota usage as a percentage
EnvironmentsByUsage ( string $usage ) : ArrayList
HasDiskQuota ( ) : boolean Is there a disk quota set for this project?
HasExceededDiskQuota ( ) : boolean Has the disk quota been exceeded?
IsStarred ( ) : boolean
Link ( $action = '' ) : string
Menu ( ) : ArrayList Get the menu to be shown on projects
PendingManualUploadDataArchives ( ) : DataList Return all archives which are "manual upload requests", meaning they don't have a file attached to them (yet).
ToggleStarLink ( ) : string
allowed ( string $code, Member | null $member = null ) : boolean Convenience wrapper for a single permission code.
allowedAny ( array | string $codes, Member | null $member = null ) : boolean Check if member has a permission code in this project.
canBackup ( Member | null $member = null ) : boolean
canCreate ( Member $member = null ) : boolean
canCreateEnvironments ( Member | null $member = null ) : boolean This is a permission check for the front-end only.
canDownloadArchive ( Member | null $member = null ) : boolean
canRestore ( Member | null $member = null ) : boolean
canUploadArchive ( Member | null $member = null ) : boolean
canView ( Member | null $member = null ) : boolean Restrict access to viewing this project
clearGitCache ( ) This will clear the cache for the git getters and should be called when the local git repo is updated
cloneRepo ( ) : string Setup a job to clone a git repository.
create_from_path ( string $path ) : DNProject Used by the sync task
currentBuilds ( ) : false | DNDeployment Returns a map of envrionment name to build name
getCMSFields ( ) : FieldList
getCommit ( string $sha ) : false | Gitonomy\Git\Commit This is a proxy call to gitonmy that caches the information per project and sha
getCommitMessage ( Gitonomy\Git\Commit $commit ) : string
getCommitSubjectMessage ( Gitonomy\Git\Commit $commit ) : string get the commit "subject", getCommitMessage get the full message
getCommitTags ( Gitonomy\Git\Commit $commit ) : mixed
getCompleteInitialEnvironmentCreations ( ) : DataList Returns a list of completed initial environment creations. This includes failed tasks.
getDiskQuotaMB ( ) : string | integer Getter for DiskQuotaMB field to provide a default for existing records that have no quota field set, as it will need to default to a globally set size.
getInitialEnvironmentCreations ( ) : DataList Returns a list of initial environments created for this project.
getKeyDir ( ) : string | null Returns the location of the projects key dir if one exists.
getLocalCVSPath ( ) : string
getPrivateKeyPath ( ) : string | null This returns that path of the private key if a key directory is set. It doesn't check whether the file exists.
getProcessEnv ( ) : array Build an environment variable array to be used with this project.
getPublicKey ( ) : string | void Fetch the public key for this project.
getPublicKeyPath ( ) : string | null This returns that path of the public key if a key directory is set. It doesn't check whether the file exists.
getRepository ( ) : false | Gitonomy\Git\Repository
getRepositoryInterface ( ) : ArrayData Get a ViewableData structure describing the UI tool that lets the user view the repository code
getRepositoryURL ( ) : void | string Provide current repository URL to the users.
getRunningEnvironmentCreations ( ) : SS_List Returns a list of environments still being created.
getRunningInitialEnvironmentCreations ( ) : DataList Only returns initial environments that are being created.
getUsedQuotaMB ( integer $round = 2 ) : double Return the used quota in MB.
getViewersList ( ) : string Get a string of people allowed to view this project
get_git_cache ( ) : Zend_Cache_Frontend_Output
groupAllowed ( string $permissionCode, Group $group ) : boolean Checks if a group is allowed to the project and the permission code
isCurrent ( ) : boolean Is this project currently at the root level of the controller that handles it?
isProjectReady ( ) : boolean Checks if the environment has been fully built.
isSection ( ) : boolean Is this project currently in a controller that is handling it or performing a sub-task?
onAfterDelete ( ) Delete related environments and folders
onAfterWrite ( )
onBeforeWrite ( )
projectFolderExists ( ) : boolean
repoExists ( ) : boolean
resolveRevision ( $value ) : boolean | string Resolve a git reference like a branch or tag into a SHA.
setCreateProjectFolderField ( FieldList &$fields ) If there isn't a capistrano env project folder, show options to create one
whoIsAllowed ( string $code ) : SS_List Convenience wrapper for a single permission code.
whoIsAllowedAny ( array | string $codes ) : SS_List List members who have $codes on this project.

Protected Methods

Method Description
getProjectFolderPath ( ) : string
setEnvironmentFields ( FieldList &$fields, GridField $environments ) Setup a gridfield for the environment configs
validate ( ) : ValidationResult

Method Details

CurrentMenu() public method

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

DNBranchList() public method

Provides a list of the branches in this project.
public DNBranchList ( ) : DNBranchList
return DNBranchList

DNBuildList() public method

Provides a DNBuildList of builds found in this project.
public DNBuildList ( ) : DNReferenceList
return DNReferenceList

DNData() public method

public DNData ( ) : DNData
return DNData

DNEnvironmentList() public method

CAUTION: filterByCallback will change this into an ArrayList!
public DNEnvironmentList ( ) : ArrayList
return ArrayList

DNTagList() public method

Provides a list of the tags in this project.
public DNTagList ( ) : DNReferenceList
return DNReferenceList

DataArchives() public method

public DataArchives ( ) : DataList
return DataList

DiskQuotaUsagePercent() public method

Returns the current disk quota usage as a percentage
public DiskQuotaUsagePercent ( ) : integer
return integer

EnvironmentsByUsage() public method

public EnvironmentsByUsage ( string $usage ) : ArrayList
$usage string
return ArrayList

HasDiskQuota() public method

Is there a disk quota set for this project?
public HasDiskQuota ( ) : boolean
return boolean

HasExceededDiskQuota() public method

Has the disk quota been exceeded?
public HasExceededDiskQuota ( ) : boolean
return boolean

IsStarred() public method

public IsStarred ( ) : boolean
return boolean

Menu() public method

Get the menu to be shown on projects
public Menu ( ) : ArrayList
return ArrayList

PendingManualUploadDataArchives() public method

Return all archives which are "manual upload requests", meaning they don't have a file attached to them (yet).
public PendingManualUploadDataArchives ( ) : DataList
return DataList

allowed() public method

Convenience wrapper for a single permission code.
public allowed ( string $code, Member | null $member = null ) : boolean
$code string
$member Member | null
return boolean

allowedAny() public method

Check if member has a permission code in this project.
public allowedAny ( array | string $codes, Member | null $member = null ) : boolean
$codes array | string
$member Member | null
return boolean

canBackup() public method

public canBackup ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canCreate() public method

public canCreate ( Member $member = null ) : boolean
$member Member
return boolean

canCreateEnvironments() public method

Only admins can create environments for now. Also, we need to check the value of AllowedEnvironmentType which dictates which backend to use to render the form.
public canCreateEnvironments ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canDownloadArchive() public method

public canDownloadArchive ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canRestore() public method

public canRestore ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canUploadArchive() public method

public canUploadArchive ( Member | null $member = null ) : boolean
$member Member | null
return boolean

canView() public method

Restrict access to viewing this project
public canView ( Member | null $member = null ) : boolean
$member Member | null
return boolean

clearGitCache() public method

This will clear the cache for the git getters and should be called when the local git repo is updated
public clearGitCache ( )

cloneRepo() public method

Setup a job to clone a git repository.
public cloneRepo ( ) : string
return string resque token

create_from_path() public static method

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

currentBuilds() public method

Returns a map of envrionment name to build name
public currentBuilds ( ) : false | DNDeployment
return false | DNDeployment

getCMSFields() public method

public getCMSFields ( ) : FieldList
return FieldList

getCommit() public method

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

getCommitMessage() public method

public getCommitMessage ( Gitonomy\Git\Commit $commit ) : string
$commit Gitonomy\Git\Commit
return string

getCommitSubjectMessage() public method

get the commit "subject", getCommitMessage get the full message
public getCommitSubjectMessage ( Gitonomy\Git\Commit $commit ) : string
$commit Gitonomy\Git\Commit
return string

getCommitTags() public method

public getCommitTags ( Gitonomy\Git\Commit $commit ) : mixed
$commit Gitonomy\Git\Commit
return mixed

getCompleteInitialEnvironmentCreations() public method

Returns a list of completed initial environment creations. This includes failed tasks.
public getCompleteInitialEnvironmentCreations ( ) : DataList
return DataList

getDiskQuotaMB() public method

Getter for DiskQuotaMB field to provide a default for existing records that have no quota field set, as it will need to default to a globally set size.
public getDiskQuotaMB ( ) : string | integer
return string | integer The quota size in MB

getInitialEnvironmentCreations() public method

Returns a list of initial environments created for this project.
public getInitialEnvironmentCreations ( ) : DataList
return DataList

getKeyDir() public method

Returns the location of the projects key dir if one exists.
public getKeyDir ( ) : string | null
return string | null

getLocalCVSPath() public method

public getLocalCVSPath ( ) : string
return string

getPrivateKeyPath() public method

This returns that path of the private key if a key directory is set. It doesn't check whether the file exists.
public getPrivateKeyPath ( ) : string | null
return string | null

getProcessEnv() public method

This is relevant if every project needs to use an individual SSH pubkey. Include this with all Gitonomy\Git\Repository, and \Symfony\Component\Process\Processes.
public getProcessEnv ( ) : array
return array

getProjectFolderPath() protected method

protected getProjectFolderPath ( ) : string
return string

getPublicKey() public method

Fetch the public key for this project.
public getPublicKey ( ) : string | void
return string | void

getPublicKeyPath() public method

This returns that path of the public key if a key directory is set. It doesn't check whether the file exists.
public getPublicKeyPath ( ) : string | null
return string | null

getRepository() public method

public getRepository ( ) : false | Gitonomy\Git\Repository
return false | Gitonomy\Git\Repository

getRepositoryInterface() public method

Get a ViewableData structure describing the UI tool that lets the user view the repository code
public getRepositoryInterface ( ) : ArrayData
return ArrayData

getRepositoryURL() public method

Provide current repository URL to the users.
public getRepositoryURL ( ) : void | string
return void | string

getRunningEnvironmentCreations() public method

Returns a list of environments still being created.
public getRunningEnvironmentCreations ( ) : SS_List
return SS_List

getRunningInitialEnvironmentCreations() public method

Only returns initial environments that are being created.
public getRunningInitialEnvironmentCreations ( ) : DataList
return DataList

getUsedQuotaMB() public method

Return the used quota in MB.
public getUsedQuotaMB ( integer $round = 2 ) : double
$round integer Number of decimal places to round to
return double The used quota size in MB

getViewersList() public method

Get a string of people allowed to view this project
public getViewersList ( ) : string
return string

get_git_cache() public static method

public static get_git_cache ( ) : Zend_Cache_Frontend_Output
return Zend_Cache_Frontend_Output

groupAllowed() public method

Checks if a group is allowed to the project and the permission code
public groupAllowed ( string $permissionCode, Group $group ) : boolean
$permissionCode string
$group Group
return boolean

isCurrent() public method

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

isProjectReady() public method

Checks if the environment has been fully built.
public isProjectReady ( ) : boolean
return boolean

isSection() public method

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

onAfterDelete() public method

Delete related environments and folders
public onAfterDelete ( )

onAfterWrite() public method

public onAfterWrite ( )

onBeforeWrite() public method

public onBeforeWrite ( )

projectFolderExists() public method

public projectFolderExists ( ) : boolean
return boolean

repoExists() public method

public repoExists ( ) : boolean
return boolean

resolveRevision() public method

Resolve a git reference like a branch or tag into a SHA.
public resolveRevision ( $value ) : boolean | string
return boolean | string

setCreateProjectFolderField() public method

If there isn't a capistrano env project folder, show options to create one
public setCreateProjectFolderField ( FieldList &$fields )
$fields FieldList

setEnvironmentFields() protected method

Setup a gridfield for the environment configs
protected setEnvironmentFields ( FieldList &$fields, GridField $environments )
$fields FieldList
$environments GridField

validate() protected method

protected validate ( ) : ValidationResult
return ValidationResult

whoIsAllowed() public method

Convenience wrapper for a single permission code.
public whoIsAllowed ( string $code ) : SS_List
$code string
return SS_List

whoIsAllowedAny() public method

Does not support Permission::DENY_PERMISSION malarky, same as Permission::get_groups_by_permission anyway...
public whoIsAllowedAny ( array | string $codes ) : SS_List
$codes array | string
return SS_List

Property Details

$_current_member_cache protected_oe static_oe property

protected static bool|Member $_current_member_cache
return boolean | Member

$relation_cache protected_oe static_oe property

In-memory cache for currentBuilds per environment since fetching them from disk is pretty resource hungry.
protected static array $relation_cache
return array