PHP Class Yosymfony\Spress\Core\Support\ItemCollection

Author: Victor Puertas ([email protected])
Inheritance: implements IteratorAggregate, implements Countable
Afficher le fichier Open project: spress/spress Class Usage Examples

Méthodes publiques

Méthode Description
__construct ( array $items = [] ) Constructor.
add ( Yosymfony\Spress\Core\DataSource\ItemInterface $item ) Adds an new item.
all ( array $collections = [], boolean $groupByCollection = false ) : array Returns all items in this collection.
clear ( ) Clears all items in this collection.
count ( ) : integer Counts the items registered.
get ( string $id ) : Yosymfony\Spress\Core\DataSource\ItemInterface Gets an item.
getIterator ( ) : ArrayIterator Gets the current ItemCollection as an Iterator that includes all items.
has ( string $id ) : boolean Checks if a item exists.
remove ( string $id ) Removes an item.
set ( Yosymfony\Spress\Core\DataSource\ItemInterface $item ) Sets an item.
sortItems ( string $attribute, boolean $descending = true, array $collections = [] ) : Yosymfony\Spress\Core\Support\ItemCollection Sorts items in this collection.

Method Details

__construct() public méthode

Yosymfony\Spress\Core\DataSource\ItemInterface[] $items
public __construct ( array $items = [] )
$items array

add() public méthode

Adds an new item.
public add ( Yosymfony\Spress\Core\DataSource\ItemInterface $item )
$item Yosymfony\Spress\Core\DataSource\ItemInterface

all() public méthode

Returns all items in this collection.
public all ( array $collections = [], boolean $groupByCollection = false ) : array
$collections array The name of the item collections affected. Array empty means all
$groupByCollection boolean First level of array is the collection name
Résultat array

clear() public méthode

Clears all items in this collection.
public clear ( )

count() public méthode

Counts the items registered.
public count ( ) : integer
Résultat integer

get() public méthode

Gets an item.
public get ( string $id ) : Yosymfony\Spress\Core\DataSource\ItemInterface
$id string The identifier of the item
Résultat Yosymfony\Spress\Core\DataSource\ItemInterface

getIterator() public méthode

The key of each item is the item's id.
public getIterator ( ) : ArrayIterator
Résultat ArrayIterator An \ArrayIterator object for iterating over items

has() public méthode

Checks if a item exists.
public has ( string $id ) : boolean
$id string The identifier of the item
Résultat boolean

remove() public méthode

Removes an item.
public remove ( string $id )
$id string The identifier of the item

set() public méthode

Sets an item.
public set ( Yosymfony\Spress\Core\DataSource\ItemInterface $item )
$item Yosymfony\Spress\Core\DataSource\ItemInterface

sortItems() public méthode

e.g:. $itemCollection = new ItemCollection(); warm-up... $items = $itemCollection->sortItems('date', true)->all();
public sortItems ( string $attribute, boolean $descending = true, array $collections = [] ) : Yosymfony\Spress\Core\Support\ItemCollection
$attribute string The name of the attribute used to sort
$descending boolean Is descending sort?
$collections array Only the items belong to Collections will be affected
Résultat Yosymfony\Spress\Core\Support\ItemCollection An intance of itself