Documentation

ResponseCollection extends Collection
in package

Table of Contents

$itemStack  : mixed
$total  : mixed
__construct()  : mixed
__toArray()  : mixed
__toString()  : mixed
count()  : int
Alias for length, implementation for Countable interface
first()  : object
Allows the collection to behave somewhat like a query operation.
getIterator()  : mixed
grab()  : object
Grab all the models whose property matches the passed value
length()  : mixed
Return the number of objects in the stack. Can also be accessed as a property
merge()  : object
Merges two collections together. If you pass a second argument it attempts to sort it via that property (both models must have that property).
metaContains()  : mixed
metaIs()  : mixed
offsetExists()  : mixed
offsetGet()  : mixed
offsetSet()  : mixed
offsetUnset()  : mixed
peekBack()  : mixed
Return the last model on the stack, but don't remove it
peekFront()  : mixed
Return, but don't remove, the first item on the stack
pop()  : mixed
Remove and return the last object in the stack
push()  : mixed
Push a foundry\model object onto the stack
shift()  : mixed
Remove and return the first item from the stack
sort()  : object
Sort a collection by an item property
splat()  : array<string|int, mixed>
Flattens the collection into a single property array This is useful for returning elements for an auto complete search system implemented via AJAX
unshift()  : mixed
Push a foundry\model object into the front of the stack

Properties

Methods

__construct()

public __construct([mixed $itemStack = [] ]) : mixed
Parameters
$itemStack : mixed = []
Return values
mixed

count()

Alias for length, implementation for Countable interface

public count() : int
Return values
int

number of elements

first()

Allows the collection to behave somewhat like a query operation.

public first() : object

Mostly allows you to call first() on a findby operation:

$section = M::init('section')->findBySlug('foo')->first()
Return values
object

getIterator()

public getIterator() : mixed
Return values
mixed

grab()

Grab all the models whose property matches the passed value

public grab(string $prop, mixed $val[, bool $greedy = false ]) : object
$authors = $allAuthors->grab('status', 1);
// grabs all the objects with a status of '1'
Parameters
$prop : string

property to check

$val : mixed

value to test against

$greedy : bool = false

if TRUE, matched objects are removed from the stack

Return values
object

foundry\model\collection

length()

Return the number of objects in the stack. Can also be accessed as a property

public length() : mixed
> echo $collection->length(); // 3
> echo $collection->length; // 3
Return values
mixed

merge()

Merges two collections together. If you pass a second argument it attempts to sort it via that property (both models must have that property).

public merge(object $collection[, string $sort = false ][, bool $sortFlag = false ]) : object
	> $coll->merge($other, 'foo', \foundry\collection\SORT_REVERSE);
Parameters
$collection : object

the other collection

$sort : string = false

property to sort by

$sortFlag : bool = false

set to SORT_REVERSE to sort... in reverse

Return values
object

foundry\collection

metaContains()

public metaContains(mixed $value[, mixed $label = false ][, mixed $greedy = false ]) : mixed
Parameters
$value : mixed
$label : mixed = false
$greedy : mixed = false
Return values
mixed

metaIs()

public metaIs(mixed $value[, mixed $label = false ][, mixed $greedy = false ]) : mixed
Parameters
$value : mixed
$label : mixed = false
$greedy : mixed = false
Return values
mixed

offsetExists()

public offsetExists(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetGet()

public offsetGet(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

offsetSet()

public offsetSet(mixed $offset, mixed $val) : mixed
Parameters
$offset : mixed
$val : mixed
Return values
mixed

offsetUnset()

public offsetUnset(mixed $offset) : mixed
Parameters
$offset : mixed
Return values
mixed

peekBack()

Return the last model on the stack, but don't remove it

public peekBack(int $count) : mixed
Parameters
$count : int

return number of models

Return values
mixed

if count is omitted a single object is returned. If count is set, a collection is returned

peekFront()

Return, but don't remove, the first item on the stack

public peekFront(int $count) : mixed
Parameters
$count : int

return number of objects

Return values
mixed

if count is omitted a single object is returned. If count is set, a collection is returned

pop()

Remove and return the last object in the stack

public pop(int $count) : mixed
Parameters
$count : int

return number of models

Return values
mixed

if count is omitted a single object is returned. If count is set, a collection is returned

push()

Push a foundry\model object onto the stack

public push(object $obj) : mixed
Parameters
$obj : object

a foundry\model

Return values
mixed

shift()

Remove and return the first item from the stack

public shift(int $count) : mixed
Parameters
$count : int

return a number of objects

Return values
mixed

if count is omitted a single object is returned. If count is set, a collection is returned

sort()

Sort a collection by an item property

public sort(string $by[, bool $sortFlag = false ]) : object
Parameters
$by : string

sort value

$sortFlag : bool = false

if TRUE, will sort reverse

Return values
object

this

splat()

Flattens the collection into a single property array This is useful for returning elements for an auto complete search system implemented via AJAX

public splat(string $property[, string $key = false ]) : array<string|int, mixed>
$authors = _M( 'authors' )->find( ... );
return $authors->splat( 'name' );
// returns array( 'Author One', 'Author Two' );

return $authors->splat('name', 'uid');
// array( '1234' => 'Author One', '5678' => 'Author Two');
Parameters
$property : string

property to extract

$key : string = false

return array as k->v pair

Return values
array<string|int, mixed>

unshift()

Push a foundry\model object into the front of the stack

public unshift(object $obj) : mixed
Parameters
$obj : object

foundry\model object

Return values
mixed

Search results