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
Afficher le fichier Open project: pantheon-systems/terminus Class Usage Examples

Protected Properties

Свойство Type Description
$args array
$collected_class string
$models TerminusModel[]
$paged boolean
$url string

Méthodes publiques

Méthode 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

Méthodes protégées

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

Method Details

__construct() public méthode

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

add() public méthode

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
Résultat TerminusModel

all() public méthode

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

fetch() public méthode

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

get() public méthode

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

getCollectionData() protected méthode

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

getFilteredMemberList() public méthode

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
Résultat array Array rendered as requested $this->attribute->$key = $this->attribute->$value

getMemberList() public méthode

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
Résultat array Array rendered as requested $this->attribute->$key = $this->attribute->$value

getMembers() protected méthode

Retrieves all members of this collection
protected getMembers ( ) : TerminusModel[]
Résultat TerminusModel[]

getUrl() public méthode

Get the listing URL for this collection
public getUrl ( ) : string
Résultat string

ids() public méthode

List Model IDs
public ids ( ) : string[]
Résultat string[] Array of all model IDs

listing() public méthode

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
Résultat array Array rendered as requested $this->attribute->$key = $this->attribute->$value

Property Details

$args protected_oe property

protected array $args
Résultat array

$collected_class protected_oe property

protected string $collected_class
Résultat string

$models protected_oe property

protected TerminusModel[] $models
Résultat TerminusModel[]

$paged protected_oe property

protected bool $paged
Résultat boolean

$url protected_oe property

protected string $url
Résultat string