PHP Класс Yosymfony\Spress\Core\Support\ItemCollection

Автор: Victor Puertas ([email protected])
Наследование: implements IteratorAggregate, implements Countable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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.

Описание методов

__construct() публичный Метод

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

add() публичный Метод

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

all() публичный Метод

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
Результат array

clear() публичный Метод

Clears all items in this collection.
public clear ( )

count() публичный Метод

Counts the items registered.
public count ( ) : integer
Результат integer

get() публичный Метод

Gets an item.
public get ( string $id ) : Yosymfony\Spress\Core\DataSource\ItemInterface
$id string The identifier of the item
Результат Yosymfony\Spress\Core\DataSource\ItemInterface

getIterator() публичный Метод

The key of each item is the item's id.
public getIterator ( ) : ArrayIterator
Результат ArrayIterator An \ArrayIterator object for iterating over items

has() публичный Метод

Checks if a item exists.
public has ( string $id ) : boolean
$id string The identifier of the item
Результат boolean

remove() публичный Метод

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

set() публичный Метод

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

sortItems() публичный Метод

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
Результат Yosymfony\Spress\Core\Support\ItemCollection An intance of itself