ResponseCollection
class ResponseCollection extends Collection
Properties
protected | $itemStack | from Collection |
Methods
Return the last model on the stack, but don't remove it
Return, but don't remove, the first item on the stack
Return the number of objects in the stack. Can also be accessed as a property
Sort a collection by an item property
Merges two collections together. If you pass a second argument it attempts to sort it via that property (both models must have that property).
Flattens the collection into a single property array This is useful for returning elements for an auto complete search system implemented via AJAX
Grab all the models whose property matches the passed value
No description
No description
Details
in Collection at line 12
__construct($itemStack = [])
in Collection at line 28
push(object $obj)
Push a foundry\model object onto the stack
in Collection at line 39
mixed
pop(int $count = 0)
Remove and return the last object in the stack
in Collection at line 66
mixed
peekBack(int $count = 0)
Return the last model on the stack, but don't remove it
in Collection at line 96
object
first()
Allows the collection to behave somewhat like a query operation.
Mostly allows you to call first()
on a findby operation:
$section = M::init('section')->findBySlug('foo')->first()
in Collection at line 106
unshift(object $obj)
Push a foundry\model object into the front of the stack
in Collection at line 119
mixed
shift(int $count = 0)
Remove and return the first item from the stack
in Collection at line 146
mixed
peekFront(int $count = 0)
Return, but don't remove, the first item on the stack
in Collection at line 169
getIterator()
in Collection at line 173
offsetGet($offset)
in Collection at line 180
offsetExists($offset)
in Collection at line 191
offsetSet($offset, $val)
in Collection at line 195
offsetUnset($offset)
in Collection at line 208
length()
Return the number of objects in the stack. Can also be accessed as a property
> echo $collection->length(); // 3 > echo $collection->length; // 3
in Collection at line 216
int
count()
Alias for length, implementation for Countable interface
in Collection at line 227
object
sort(string $by, bool $sortFlag = false)
Sort a collection by an item property
in Collection at line 259
object
merge(object $collection, string $sort = false, bool $sortFlag = false)
Merges two collections together. If you pass a second argument it attempts to sort it via that property (both models must have that property).
> $coll->merge($other, 'foo', \foundry\collection\SORT_REVERSE);
in Collection at line 322
array
splat(string $property, string $key = false)
Flattens the collection into a single property array This is useful for returning elements for an auto complete search system implemented via AJAX
$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');
in Collection at line 349
object
grab(string $prop, mixed $val, bool $greedy = false)
Grab all the models whose property matches the passed value
$authors = $allAuthors->grab('status', 1); // grabs all the objects with a status of '1'