PHP Class Scalr\Model\Entity\Farm

Author: N.V.
Inheritance: extends Scalr\Model\AbstractEntity, implements Scalr\DataType\AccessPermissionsInterface
Mostrar archivo Open project: scalr/scalr Class Usage Examples

Public Properties

Property Type Description
$accountId integer Account Id
$added DateTime Added time
$changed string Last change time TODO: convert to DateTime with MySQL 5.6
$changedById integer Last editor Id
$comments string Comments
$createdByEmail string Creator E-Mail
$envId integer Environment Id
$hash string Hash
$id integer Identifier
$isCompleted boolean Completion status
$launchOrder boolean Launch order type
$launched DateTime Launched time
$name string Farm name
$ownerId integer Creator Id
$region string Region name
$status integer Status
$termOnSyncFail boolean Synchronization fail flag

Protected Properties

Property Type Description
$_environment Scalr\Model\Entity\Account\Environment
$_farmRoles Scalr\Model\Collections\EntityIterator | FarmRole[] Farm roles collection
$_servers Scalr\Model\Collections\EntityIterator | Server[] Servers collection
$_settings Scalr\Model\Collections\SettingsCollection Farm settings collection
$_teams Scalr\Model\Collections\EntityIterator | Scalr\Model\Entity\Account\Team[] The Farm teams
$_teamsChanged boolean True value indicates that the set of the Teams associated with the Farm has been changed within the object with respect to database.

Public Methods

Method Description
__clone ( ) Reset farm id on clone
__get ( string $name ) : mixed Magic getter.
appendTeams ( Team $team ) : Farm Appends Teams list
checkLocked ( ) Checks if farm is locked
cloneFarm ( string $name, User $user ) : Farm Creates clone for the farm TODO: refactor farms cloning
delete ( )
deleteScheduled ( ) Delete scheduled tasks
findWithTeams ( array $criteria = null, array $group = null, array $order = null, integer $limit = null, integer $offset = null, boolean $countRecords = null ) : ArrayCollection | Farm[] Searches farms by criteria and selecting and initiating their Teams
getEnvironment ( ) : Environment | null Return Environment entity
getStatusName ( integer $status ) : string Translates status codes to status names
getTeams ( ) : EntityIterator | Team[] Gets the list of the Teams which own the Farm
getUserTeamOwnershipSql ( integer $userId, integer $farmId = null ) : string Generate SQL query like "EXISTS(SELECT 1 FROM farm_teams .
hasAccessPermissions ( User $user, Environment $environment = null, string | boolean $modify = null ) : boolean
hasUserTeamOwnership ( User $user ) : boolean Check if given user belongs to team, which has access to farm
isTeamsChanged ( ) : boolean Checks whether the set of the Teams associated with the Farm has been changed.
launch ( User $user = null, array $auditLogExtra = null ) : Farm Launch this farm
lock ( User $user, string $comment, boolean $restrict = false ) : Farm Locks this farm
save ( )
saveTeams ( EntityIterator | Team[] $teams ) Associates a Farm with specified Teams.
setTeams ( EntityIterator | Team[] $teams ) Sets the list of the Teams which own the Farm
unlock ( User $user ) : Farm Unlocks this farm

Method Details

__clone() public method

Reset farm id on clone
public __clone ( )

__get() public method

Gets the values of the properties that require initialization.
public __get ( string $name ) : mixed
$name string Name of property that is accessed
return mixed Returns property value

appendTeams() public method

Appends Teams list
public appendTeams ( Team $team ) : Farm
$team Scalr\Model\Entity\Account\Team The Team entity
return Farm

checkLocked() public method

Checks if farm is locked
public checkLocked ( )

cloneFarm() public method

Creates clone for the farm TODO: refactor farms cloning
public cloneFarm ( string $name, User $user ) : Farm
$name string The name of a new Farm
$user Scalr\Model\Entity\Account\User The User that initiates cloning
return Farm Returns clone

delete() public method

See also: AbstractEntity::delete()
public delete ( )

deleteScheduled() public method

Delete scheduled tasks
public deleteScheduled ( )

findWithTeams() public static method

Searches farms by criteria and selecting and initiating their Teams
public static findWithTeams ( array $criteria = null, array $group = null, array $order = null, integer $limit = null, integer $offset = null, boolean $countRecords = null ) : ArrayCollection | Farm[]
$criteria array optional The search criteria.
$group array optional The group by looks like [property1, ...], by default groups by `id`
$order array optional The results order looks like [property1 => true|false, ... ]
$limit integer optional The records limit
$offset integer optional The offset
$countRecords boolean optional True to calculate total number of the records without limit
return Scalr\Model\Collections\ArrayCollection | Farm[] Returns collection of the entities.

getEnvironment() public method

Return Environment entity
public getEnvironment ( ) : Environment | null
return Scalr\Model\Entity\Account\Environment | null

getStatusName() public static method

Translates status codes to status names
public static getStatusName ( integer $status ) : string
$status integer Status code
return string Status name

getTeams() public method

Gets the list of the Teams which own the Farm
public getTeams ( ) : EntityIterator | Team[]
return Scalr\Model\Collections\EntityIterator | Scalr\Model\Entity\Account\Team[]

getUserTeamOwnershipSql() public static method

... WHERE ...) to check FARM_TEAMS permission. Table farms should have alias f. If farmId is set, when JOIN table farms to get envId from it.
public static getUserTeamOwnershipSql ( integer $userId, integer $farmId = null ) : string
$userId integer Identifier of User
$farmId integer optional Identifier of Farm
return string

hasAccessPermissions() public method

public hasAccessPermissions ( User $user, Environment $environment = null, string | boolean $modify = null ) : boolean
$user Scalr\Model\Entity\Account\User The User Entity
$environment Scalr\Model\Entity\Account\Environment optional The Environment Entity
$modify string | boolean optional ACL Permission Identifier or boolean flag whether it should check modify permissions or not.
return boolean

hasUserTeamOwnership() public method

Check if given user belongs to team, which has access to farm
public hasUserTeamOwnership ( User $user ) : boolean
$user Scalr\Model\Entity\Account\User User entity
return boolean

isTeamsChanged() public method

Checks whether the set of the Teams associated with the Farm has been changed.
public isTeamsChanged ( ) : boolean
return boolean Returns true if the set of the Teams that is associated with the Farm has been changed

launch() public method

Launch this farm
public launch ( User $user = null, array $auditLogExtra = null ) : Farm
$user Scalr\Model\Entity\Account\User optional The user who initiates Farm launch
$auditLogExtra array optional Audit log extra fields to record
return Farm

lock() public method

Locks this farm
public lock ( User $user, string $comment, boolean $restrict = false ) : Farm
$user Scalr\Model\Entity\Account\User The User on whose behalf the lock set
$comment string Comment describing the reason and/or purpose of the lock
$restrict boolean optional Strict lock flag (I have no idea what that means [author's note])
return Farm

save() public method

See also: AbstractEntity::save()
public save ( )

saveTeams() public method

This method should only be called within a transaction.
public saveTeams ( EntityIterator | Team[] $teams )
$teams Scalr\Model\Collections\EntityIterator | Scalr\Model\Entity\Account\Team[] Collection of the Teams

setTeams() public method

Sets the list of the Teams which own the Farm
public setTeams ( EntityIterator | Team[] $teams )
$teams Scalr\Model\Collections\EntityIterator | Scalr\Model\Entity\Account\Team[] The list of the Teams that which own the Farm

unlock() public method

Unlocks this farm
public unlock ( User $user ) : Farm
$user Scalr\Model\Entity\Account\User The User on whose behalf the lock unset
return Farm

Property Details

$_environment protected_oe property

protected Environment,Scalr\Model\Entity\Account $_environment
return Scalr\Model\Entity\Account\Environment

$_farmRoles protected_oe property

Farm roles collection
protected EntityIterator,Scalr\Model\Collections|FarmRole[],Scalr\Model\Entity $_farmRoles
return Scalr\Model\Collections\EntityIterator | FarmRole[]

$_servers protected_oe property

Servers collection
protected EntityIterator,Scalr\Model\Collections|Server[],Scalr\Model\Entity $_servers
return Scalr\Model\Collections\EntityIterator | Server[]

$_settings protected_oe property

Farm settings collection
protected SettingsCollection,Scalr\Model\Collections $_settings
return Scalr\Model\Collections\SettingsCollection

$_teams protected_oe property

The Farm teams
protected EntityIterator,Scalr\Model\Collections|Team[],Scalr\Model\Entity\Account $_teams
return Scalr\Model\Collections\EntityIterator | Scalr\Model\Entity\Account\Team[]

$_teamsChanged protected_oe property

True value indicates that the set of the Teams associated with the Farm has been changed within the object with respect to database.
protected bool $_teamsChanged
return boolean

$accountId public_oe property

Account Id
public int $accountId
return integer

$added public_oe property

Added time
public DateTime $added
return DateTime

$changed public_oe property

Last change time TODO: convert to DateTime with MySQL 5.6
public string $changed
return string

$changedById public_oe property

Last editor Id
public int $changedById
return integer

$comments public_oe property

Comments
public string $comments
return string

$createdByEmail public_oe property

Creator E-Mail
public string $createdByEmail
return string

$envId public_oe property

Environment Id
public int $envId
return integer

$hash public_oe property

Hash
public string $hash
return string

$id public_oe property

Identifier
public int $id
return integer

$isCompleted public_oe property

Completion status
public bool $isCompleted
return boolean

$launchOrder public_oe property

Launch order type
public bool $launchOrder
return boolean

$launched public_oe property

Launched time
public DateTime $launched
return DateTime

$name public_oe property

Farm name
public string $name
return string

$ownerId public_oe property

Creator Id
public int $ownerId
return integer

$region public_oe property

Region name
public string $region
return string

$status public_oe property

Status
public int $status
return integer

$termOnSyncFail public_oe property

Synchronization fail flag
public bool $termOnSyncFail
return boolean