Flex Collection is an ordered map of objects that can also be used like a list.
Collection provides a few useful methods, which can be used to render the output, fetch objects, filter and sort and so on.
TIP: Flex Collection extends Doctrine Collections.
render( [layout], [context] ): Block Renders the collection.
Parameters:
string)array)Returns:
object) HtmlBlock class containing the outputNOTE: In twig there is a {% render %} tag, which should be used instead of calling the method directly. This will allow JS/CSS assets from the collection to work properly.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set page = 2 %}
{% set limit = 10 %}
{% set start = (page - 1) * limit %}
<h2>Contacts:</h2>
{% render contacts.limit(start, limit) layout: 'cards' with { background: 'gray', color: 'white' } %}
use Grav\Common\Grav;
use Grav\Framework\ContentBlock\HtmlBlock;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$page = 2;
$limit = 10;
$start = ($page-1)*$limit;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->limit($start, $limit);
/** @var HtmlBlock $block */
$block = $collection->render('cards', ['background' =>'gray', 'color' => 'white']);
}
All of these methods return a modified copy of the collection. The original collection remains unchanged.
sort( orderings ): Collection Sort the collection by list of property: direction pairs.
Parameters:
property: direction where direction is either 'ASC' or 'DESC' (array)Returns:
object) New sorted instance of the collectionTIP: Default sort order can be set for the frontend in the Flex Type blueprints.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.sort({last_name: 'ASC', first_name: 'ASC'}) %}
<div>Displaying all contacts in alphabetical order:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->sort(['last_name' => 'ASC', 'first_name' => 'ASC']);
// Collection has now be sorted by last name, first name...
}
limit( start, limit ): Collection Return subset of collection starting from start and including only limit number of objects.
Parameters:
int)int)Returns:
object) New filtered instance of the collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set page = 3 %}
{% set limit = 6 %}
{% set start = (page - 1) * limit %}
{% set contacts = contacts.limit(start, limit) %}
<div>Displaying page {{ page|e }}:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$start = 0;
$limit = 6;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->limit($start, $limit);
// Collection contains only the objects in the current page...
}
filterBy( filters ): Collection Filter collection by list of property: value pairs.
Parameters:
property: value which are used to filter he collection (array)Returns:
object) New filtered instance of the collectionTIP: Default filtering can be set for the frontend in the Flex Type blueprints.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.filterBy({'published': true}) %}
<div>Displaying only published contacts:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$start = 0;
$limit = 6;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->filterBy(['published' => true]);
// Collection contains only published objects...
}
reverse(): Collection Reverse the order of the objects in the Collection.
Returns:
object) New reversed instance of the collectionTIP: If you're using sort(), it is recommended to reverse the ordering in there as it saves an extra step.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.reverse() %}
<div>Displaying contacts in reverse ordering:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$start = 0;
$limit = 6;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->reverse();
// Collection is now in reverse ordering...
}
shuffle(): Collection Shuffle objects to a random order.
Returns:
object) New randomly ordered instance of the collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.shuffle().limit(0, 6) %}
<div>Displaying 6 random contacts:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->shuffle()->limit(0,6);
// Collection contains 6 random contacts...
}
select( keys ): Collection Select objects (by their keys) from the collection.
Parameters:
array)Returns:
object) New instance of the collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set selected = ['gizwsvkyo5xtms2s', 'gjmva53uoncdo4sb', 'mfzwwtcugv5hkocd', 'k5nfctkeoftwi4zu'] %}
{% set contacts = contacts.select(selected) %}
<div>Displaying 4 selected contacts:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$selected = ['gizwsvkyo5xtms2s', 'gjmva53uoncdo4sb', 'mfzwwtcugv5hkocd', 'k5nfctkeoftwi4zu'];
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->select($selected);
// Collection now contains the 4 selected contacts...
}
unselect( keys ): Collection Remove objects (by their keys) from the collection.
Parameters:
array)Returns:
object) New instance of the collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set ignore = ['gizwsvkyo5xtms2s', 'gjmva53uoncdo4sb', 'mfzwwtcugv5hkocd', 'k5nfctkeoftwi4zu'] %}
{% set contacts = contacts.unselect(ignore) %}
<div>Displaying all but 4 ignored contacts:</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
$ignore = ['gizwsvkyo5xtms2s', 'gjmva53uoncdo4sb', 'mfzwwtcugv5hkocd', 'k5nfctkeoftwi4zu'];
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->unselect($ignore);
// Collection now contains all but 4 ignored contacts...
}
search( string, [properties], [options] ): Collection Search a string from the collection.
Parameters:
string)array or null)array)
boolboolboolboolReturns:
object) New filtered instance of the collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.search('Jack', ['first_name', 'last_name', 'email'], {'contains': true}) %}
<div>Displaying all search results for 'Jack':</div>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->search('Jack', ['first_name', 'last_name', 'email'], ['contains' => true]);
// Collection now contains all search results...
}
copy(): Collection Create a copy from the collection by cloning all the objects in the collection.
Returns:
object) New instance of the collection, now with cloned objectsWARNING: If you modify objects in your collection, you should always use copies!
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contacts = contacts.shuffle().limit(0, 10) %}
{% set fakes = contacts.copy() %}
{% do fakes.setProperty('first_name', 'JACK') %}
<h2>Fake cards</h2>
{% render fakes layout: 'cards' %}
<h2>Original cards</h2>
{% render contacts layout: 'cards' %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
$collection = $collection->search('Jack', ['first_name', 'last_name', 'email'], ['contains' => true]);
// Collection now contains all search results...
}
Collections can be iterated over.
{% set contacts = grav.get('flex').collection('contacts') %}
<h2>All contacts:</h2>
<ul>
{% for contact in contacts %}
<li>{{ contact.first_name|e }} {{ contact.last_name|e }}</li>
{% endfor %}
</ul>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface $object */
foreach ($collection as $object) {
// Do something with the object...
}
}
first(): Object | false Sets the iterator to the first object in the collection and returns this object.
Returns:
object) First objectfalse No objects in the Collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set contact = contacts.first() %}
{% if contact %}
<h2>First contact:</h2>
<div>{{ contact.first_name|e }} {{ contact.last_name|e }}</div>
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface|false $object */
$object = $collection->first();
if ($object) {
// Do something with the object...
}
}
last(): Object | false Sets the iterator to the last object in the collection and returns this object.
Returns:
object) Last objectfalse No objects in the Collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set contact = contacts.last() %}
{% if contact %}
<h2>Last contact:</h2>
<div>{{ contact.first_name|e }} {{ contact.last_name|e }}</div>
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface|false $object */
$object = $collection->last();
if ($object) {
// Do something with the object...
}
}
next(): object | false Moves the iterator position to the next object and returns this element.
Returns:
object) Next objectfalse No more objects in the Collection{% set contacts = grav.get('flex').collection('contacts') %}
{% set first = contacts.first() %}
...
{% set contact = contacts.next() %}
{% if contact %}
<h2>Next contact is:</h2>
<div>{{ contact.first_name|e }} {{ contact.last_name|e }}</div>
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface|false $object */
while ($object = $collection->next()) {
// Do something with the object...
}
}
current(): object | false Gets the object of the collection at the current iterator position.
Returns:
object) Current objectfalse No more objects in the Collection{% set contacts = grav.get('flex').collection('contacts') %}
{% do contacts.next() %}
{% do contacts.next() %}
...
{% set contact = contacts.current() %}
{% if contact %}
<h2>Current contact is:</h2>
<div>{{ contact.first_name|e }} {{ contact.last_name|e }}</div>
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
while ($collection->next()) {
/** @var FlexObjectInterface|false $object */
$object = $collection->current();
// Do something with the object...
}
}
key(): key | null Gets the key of the object at the current iterator position.
Returns:
string) Object keynull No more objects in the Collection{% set contacts = grav.get('flex').collection('contacts') %}
{% do contacts.next() %}
{% do contacts.next() %}
...
{% set key = contacts.key() %}
{% if key %}
Current contact key is: <strong>{{ key|e }}</strong>
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
while ($collection->next()) {
$key = $collection->key();
// Do something with the key...
}
}
Collections can be accessed just like associative arrays or maps.
NOTE: null is being returned if object with given key is not in the collection.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contact = contacts['ki2ts4cbivggmtlj']
{# Do something #}
{% if contact %}
{# Got Bruce Day #}
Email for {{ contact.first_name|e }} {{ contact.last_name|e }} is {{ contact.email|e }}
{% else %}
Oops, contact has been removed!
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface|null $object */
$object = $collection['ki2ts4cbivggmtlj'];
if ($object) {
// Object exists, do something with it...
}
}
get( key ): Object | null Gets the object with the specified key.
Parameters:
string)Returns:
object)null Object with given key is not in the collectionAlternative to Array Access
{% set contacts = grav.get('flex').collection('contacts') %}
{% set contact = contacts.get('ki2ts4cbivggmtlj')
{# Do something #}
{% if contact %}
{# Got Bruce Day #}
Email for {{ contact.first_name|e }} {{ contact.last_name|e }} is {{ contact.email|e }}
{% else %}
Oops, contact has been removed!
{% endif %}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface|null $object */
$object = $collection->get('ki2ts4cbivggmtlj');
if ($object) {
// Object exists, do something with it...
}
}
getKeys(): array Gets all keys of the collection.
Returns:
array List of keys{% set contacts = grav.get('flex').collection('contacts') %}
{% set keys = contacts.keys() %}
Keys are: {{ keys|join(', ')|e }}
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var string[] $keys */
$keys = $collection->getKeys();
$keysList = implode(', ', $keys);
}
GetObjectKeys(): array Alias to the getKeys() method.
Returns:
array List of keysgetValues(): array Gets all objects of the collection.
Converts collection into an array. Keys are not preserved.
Returns:
array){% set contacts = grav.get('flex').collection('contacts') %}
{% set list = contacts.values() %}
<ol>
{% for i,object in list %}
<li>#{{ (i+1)|e }}: {{ object.email|e }}</li>
{% endfor %}
</ol>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var FlexObjectInterface[] $objects */
$objects = $collection->getValues();
foreach ($objects as $pos => $object) {
// Do something with the object and its position...
}
}
toArray(): array Gets a native PHP array representation of the collection.
Similar to getValues() but preserves the keys.
Returns:
array List of key: Object pairs{% set contacts = grav.get('flex').collection('contacts') %}
{% set list = contacts.toArray() %}
<ol>
{% for key,object in list %}
<li>ID: {{ key|e }}: {{ object.email|e }}</li>
{% endfor %}
</ol>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var array<string, FlexObjectInterface> $objects */
$objects = $collection->toArray();
foreach ($objects as $key => $object) {
// Do something with the object and its key...
}
}
slice( offset, length ): array Extracts a slice of length elements starting at position offset from the Collection.
Parameters:
int)int)Returns:
array List of key: Object pairsTIP: This method can be used for pagination.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set list = contacts.slice(10, 5) %}
<div>Displaying 5 emails starting from offset 10:</div>
<ol>
{% for key,object in list %}
<li>ID: {{ key|e }}: {{ object.email|e }}</li>
{% endfor %}
</ol>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var array<string, FlexObjectInterface> $objects */
$objects = $collection->slice(10, 5);
// Do something with the object and its key...
}
chunk( size ): array Split collection into chunks of size objects.
Parameters:
int)Returns:
array Two dimensional list of key: Object pairsTIP: This method can be used to split content into rows and columns.
{% set contacts = grav.get('flex').collection('contacts') %}
{% set columns = contacts.limit(0, 10).chunk(5) %}
<div>Displaying two columns of 5 emails each:</div>
<div class="columns">
{% for column,list in columns %}
<div class="column">
{% for object in list %}
<div>{{ object.email|e }}</div>
{% endfor %}
</div>
{% endfor %}
</div>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var array $columns */
$columns = $collection->limit(0, 10)->chunk(5);
/** @var
int $column
array<string, FlexObjectInterface> $objects
*/
foreach ($columns as $column => $objects) {
// Do something with the objects...
}
}
}
group( property ): array Group objects in the collection by a property and return them as associated array.
Parameters:
string)Returns:
array Two dimensional list of key: Object pairs, where value of the property is the key of the first level{% set contacts = grav.get('flex').collection('contacts') %}
{% set by_name = contacts.sort({last_name: 'ASC', first_name: 'ASC'}).group('last_name') %}
<div>Displaying contacts grouped by last name:</div>
<div>
{% for last_name,list in by_name %}
{{ last_name|e }}:
<ul>
{% for object in list %}
<li>{{ object.first_name|e }}</li>
{% endfor %}
</ul>
{% endfor %}
</div>
use Grav\Common\Grav;
use Grav\Framework\Flex\Interfaces\FlexCollectionInterface;
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
/** @var FlexCollectionInterface|null $collection */
$collection = Grav::instance()->get('flex')->getCollection('contacts');
if ($collection) {
/** @var array $byName */
$byName = $collection->group('last_name');
/** @var
string $lastName
array<string, FlexObjectInterface> $objects
*/
foreach ($byName as $lastName => $objects) {
// Do something with the objects...
}
}
}
add( Object ) Adds an Object at the end of the collection.
Parameters:
object)remove( key ): Object | null Removes the element at the specified index from the collection.
Parameters:
object)Returns:
object) or null if it was not foundremoveElement( Object ): bool Removes the specified object from the collection, if it is found.
Parameters:
object)Returns:
true if object was in the collection, false if notclear() Clears the collection, removing all elements.
containsKey( key ): bool Checks whether the collection contains an object with the specified key.
Parameters:
string)Returns:
true if object is in the collection, false if notcontains( object ): bool Checks whether an element is contained in the collection.
Parameters:
object)Returns:
true if object is in the collection, false if notindexOf( object ): string | false Gets the index/key of a given object.
Parameters:
object)Returns:
string index/key of the object, false if not object was not foundisEmpty(): bool Checks whether the collection is empty (contains no objects).
Returns:
true if collection is empty, false otherwisecount(): int
Returns:
int Number of objects in the collectionhasProperty( property ): array Returns a list of key: boolean pairs whether object with key has property defined or not.
Parameters:
string)Returns:
array of key: bool pairs, where key is the object key and bool is either true or false.getProperty( property, default ): array Returns a list of key: value for each object.
Parameters:
string)Returns:
array of key: value pairs, where key is the object key and value is the value of the property.setProperty( property, value ): Collection Set new value to the property for every object in the collection.
Parameters:
string)mixed)Returns:
object) The collection for chaining the method calls.WARNING: This method modifies the object instances shared between all the collections, if that is not intended, please copy() collection before using this method.
defProperty( property, default ): Collection Define default value to the property for every object in the collection.
Parameters:
string)mixed)Returns:
object) The collection for chaining the method calls.WARNING: This method modifies the object instances shared between all the collections, if that is not intended, please copy() collection before using this method.
unsetProperty( property ): Collection Remove value of the property for every object in the collection.
Parameters:
string)Returns:
object) The collection for chaining the method calls.WARNING: This method modifies the object instances shared between all the collections, if that is not intended, please copy() collection before using this method.
call( method, arguments): array Calls a method for every object in the collection. Return results of each call.
Parameters:
string)array)Returns:
key: result pairs (array)WARNING: If the method modifies the object, please copy() collection before using this method.
getTimestamps(): array Returns a list of key: timestamp for each object.
Returns:
key: timestamp pairs, where timestamp is integer (array)getStorageKeys(): array Returns a list of key: storage_key for each object.
Returns:
key: storage_key pairs (array)getFlexKeys(): array Returns a list of key: flex_key for each object.
Returns:
key: flex_key pairs (array)withKeyField( field ): Collection Return new collection with a different key.
Parameters:
string)
Returns:
object) The collection, but indexed with the new key.exists( Closure ): bool Tests for the existence of an object that satisfies the given predicate.
Parameters:
Returns:
bool True if your callback function returns true for any object.forAll( Closure ): bool Tests whether the given predicate holds for all objects of this collection.
Parameters:
Returns:
bool True if your callback function returns true for all objects.filter( Closure ): Collection Returns all the objects of this collection that satisfy the predicate.
The order of the elements is preserved.
Parameters:
Returns:
object) New collection with all the objects for which your callback function returns true.map( Closure ): Collection Applies the given function to each object in the collection and returns a new collection with the objects returned by the function.
Parameters:
Returns:
object) New collection with objects returned by the callback function.collectionGroup( property ): Collection[] Group objects in the collection by a field and return them as associated array of collections.
Parameters:
string) Property used to group the objects.Returns:
array Multiple collections in an array, key being the value of the property.matching( Criteria ): Collection Selects all objects that match the expression and returns a new collection containing these objects.
Parameters:
Returns:
object) New collection with objects matching the criteria.TIP: Check Doctrine documentation for Expression Builder and Expressions.
orderBy( array ): Collection Reorder collection by list of property/value pairs.
Parameters:
arrayReturns:
object) New collection with the new ordering.partition( Closure ): array Partitions this collection in two collections according to a predicate.
Keys are preserved in the resulting collections.
Parameters:
Returns:
array Partitioned objects [[a, b], [c, d, e]]Found errors? Think you can improve this documentation? Simply click the Edit link at the top of the page, and then the icon on Github to make your changes.
Powered by Grav + with by Trilby Media.