PHP Class Pantheon\Terminus\Collections\TerminusCollection

Inheritance: implements Pantheon\Terminus\Request\RequestAwareInterface, implements League\Container\ContainerAwareInterface, use trait Pantheon\Terminus\Request\RequestAwareTrait, use trait League\Container\ContainerAwareTrait
显示文件 Open project: pantheon-systems/terminus Class Usage Examples

Protected Properties

Property Type Description
$args array
$collected_class string
$models TerminusModel[]
$paged boolean
$url string

Public Methods

Method Description
__construct ( array $options = [] ) Instantiates the collection, sets param members as properties
add ( object $model_data, array $options = [] ) : TerminusModel Adds a model to this collection
all ( ) : TerminusModel[] Retrieves all models TODO: Remove automatic fetching and make fetches explicit
fetch ( array $options = [] ) : TerminusCollection Fetches model data from API and instantiates its model instances
get ( string $id ) : TerminusModel Retrieves the model of the given ID
getFilteredMemberList ( array $filters, string $key = 'id', string | array $value = 'name' ) : array Returns an array of data where the keys are the attribute $key and the values are the attribute $value, filtered by the given array
getMemberList ( string $key = 'id', string $value = 'name' ) : array Returns an array of data where the keys are the attribute $key and the values are the attribute $value
getUrl ( ) : string Get the listing URL for this collection
ids ( ) : string[] List Model IDs
listing ( string $key = 'id', mixed $value = 'name' ) : array Returns an array of data where the keys are the attribute $key and the values are the attribute $value

Protected Methods

Method Description
getCollectionData ( array $options = [] ) : array Retrieves collection data from the API
getMembers ( ) : TerminusModel[] Retrieves all members of this collection

Method Details

__construct() public method

Instantiates the collection, sets param members as properties
public __construct ( array $options = [] )
$options array Options with which to configure this collection

add() public method

Adds a model to this collection
public add ( object $model_data, array $options = [] ) : TerminusModel
$model_data object Data to feed into attributes of new model
$options array Data to make properties of the new model
return TerminusModel

all() public method

Retrieves all models TODO: Remove automatic fetching and make fetches explicit
public all ( ) : TerminusModel[]
return TerminusModel[]

fetch() public method

Fetches model data from API and instantiates its model instances
public fetch ( array $options = [] ) : TerminusCollection
$options array params to pass to url request
return TerminusCollection $this

get() public method

Retrieves the model of the given ID
public get ( string $id ) : TerminusModel
$id string ID of desired model instance
return TerminusModel $this->models[$id]

getCollectionData() protected method

Retrieves collection data from the API
protected getCollectionData ( array $options = [] ) : array
$options array params to pass to url request
return array

getFilteredMemberList() public method

Returns an array of data where the keys are the attribute $key and the values are the attribute $value, filtered by the given array
public getFilteredMemberList ( array $filters, string $key = 'id', string | array $value = 'name' ) : array
$filters array Attributes to match during filtration e.g. array('category' => 'other')
$key string Name of attribute to make array keys
$value string | array Name(s) of attribute to make array values
return array Array rendered as requested $this->attribute->$key = $this->attribute->$value

getMemberList() public method

Returns an array of data where the keys are the attribute $key and the values are the attribute $value
public getMemberList ( string $key = 'id', string $value = 'name' ) : array
$key string Name of attribute to make array keys
$value string Name of attribute to make array values
return array Array rendered as requested $this->attribute->$key = $this->attribute->$value

getMembers() protected method

Retrieves all members of this collection
protected getMembers ( ) : TerminusModel[]
return TerminusModel[]

getUrl() public method

Get the listing URL for this collection
public getUrl ( ) : string
return string

ids() public method

List Model IDs
public ids ( ) : string[]
return string[] Array of all model IDs

listing() public method

Returns an array of data where the keys are the attribute $key and the values are the attribute $value
public listing ( string $key = 'id', mixed $value = 'name' ) : array
$key string Name of attribute to make array keys
$value mixed Name(s) of attribute(s) to comprise array values
return array Array rendered as requested $this->attribute->$key = $this->attribute->$value

Property Details

$args protected_oe property

protected array $args
return array

$collected_class protected_oe property

protected string $collected_class
return string

$models protected_oe property

protected TerminusModel[] $models
return TerminusModel[]

$paged protected_oe property

protected bool $paged
return boolean

$url protected_oe property

protected string $url
return string