PHP Class Yosymfony\Spress\Core\Support\ItemCollection

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

Public Methods

Method 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 method

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

add() public method

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

all() public method

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
return array

clear() public method

Clears all items in this collection.
public clear ( )

count() public method

Counts the items registered.
public count ( ) : integer
return integer

get() public method

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

getIterator() public method

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

has() public method

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

remove() public method

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

set() public method

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

sortItems() public method

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
return Yosymfony\Spress\Core\Support\ItemCollection An intance of itself