PageIndex
extends FlexPageIndex
in package
implements
PageCollectionInterface
uses
FlexGravTrait, FlexIndexTrait
Class GravPageObject
Tags
Table of Contents
Interfaces
- PageCollectionInterface
- Interface PageCollectionInterface
Constants
- ORDER_LIST_REGEX = '/(\/\d+)\.[^\/]+/u'
- ORDER_PREFIX_REGEX = '/^\d+\./u'
- PAGE_ROUTE_REGEX = '/\/\d+\./u'
- VERSION = parent::VERSION . '.5'
Properties
- $_key : string
- $_params : array<string|int, mixed>|null
- $_root : PageObject|array<string|int, mixed>
- $type : string
Methods
- __call() : mixed
- __construct() : mixed
- Initializes a new FlexIndex.
- __debugInfo() : array<string|int, mixed>
- __serialize() : array<string|int, mixed>
- __toString() : string
- Returns a string representation of this object.
- __unserialize() : void
- add() : mixed
- {@inheritDoc}
- addPage() : PageCollection
- Add a single page to a collection
- adjacentSibling() : PageObject|false
- Returns the adjacent sibling based on a direction.
- all() : $this
- Mimicks Pages class.
- batch() : array<string|int, PageCollection>
- Split collection into array of smaller collections.
- call() : array<string|int, mixed>|mixed
- chunk() : array<string|int, mixed>
- Split collection into chunks.
- clear() : mixed
- {@inheritDoc}
- collectionGroup() : array<string|int, ObjectCollectionInterface>
- Group items in the collection by a field and return them as associated array of collections.
- contains() : mixed
- {@inheritDoc}
- containsKey() : mixed
- {@inheritDoc}
- copy() : static
- Create a copy of this collection
- count() : mixed
- {@inheritDoc}
- createFromArray() : static
- Creates a Flex Collection from an array.
- createFromStorage() : static
- Helper method to create Flex Index.
- current() : mixed
- {@inheritDoc}
- currentPosition() : int|null
- Returns the item in the current position.
- dateRange() : static
- Returns the items between a set of date ranges of either the page date field (default) or an arbitrary datetime page field where start date and end date are optional Dates must be passed in as text that strtotime() can process http://php.net/manual/en/function.strtotime.php
- defNestedProperty() : ObjectCollectionInterface
- defProperty() : ObjectCollectionInterface
- exists() : mixed
- {@inheritDoc}
- filter() : mixed
- {@inheritDoc}
- filterBy() : static
- Filter pages by given filters.
- first() : mixed
- {@inheritDoc}
- forAll() : mixed
- {@inheritDoc}
- get() : PageObject|null
- {@inheritDoc}
- getCache() : CacheInterface
- getCacheChecksum() : string
- Get cache checksum for the object / collection.
- getCacheKey() : string
- Get a cache key which is used for caching the object / collection.
- getCollection() : FlexCollectionInterface
- Load all the objects into memory,
- getFlexDirectory() : FlexDirectory
- Get Flex Directory for the object / collection.
- getFlexFeatures() : array<string|int, mixed>
- Get full list of features the object / collection implements.
- getFlexKeys() : array<string|int, string>
- Get Flex keys from all the objects in the collection.
- getFlexType() : string
- Get Flex Type of the object / collection.
- getIndex() : FlexIndexInterface
- Get Flex Index from the Flex Collection.
- getIndexMap() : array<string|int, mixed>
- getIterator() : mixed
- Required by interface IteratorAggregate.
- getKey() : string
- getKeyField() : string
- getKeys() : mixed
- {@inheritDoc}
- getLanguage() : string|null
- getLevelListing() : array<string|int, mixed>
- getMetaData() : array<string|int, mixed>
- Get metadata associated to the object
- getNestedProperty() : array<string|int, mixed>
- getObjectKeys() : array<string|int, mixed>
- getParam() : mixed
- Get the collection param
- getParams() : array<string|int, mixed>
- Get the collection params
- getProperty() : array<string|int, mixed>
- getRoot() : PageInterface
- getStorageKeys() : array<string|int, string>
- Get storage keys from all the objects in the collection.
- getTimestamp() : int
- Get last updated timestamp for the object / collection.
- getTimestamps() : array<string|int, int>
- Get timestamps from all the objects in the collection.
- getType() : string
- getValues() : mixed
- {@inheritDoc}
- group() : array<string|int, mixed>
- Group items in the collection by a field and return them as associated array.
- hasFlexFeature() : bool
- Test whether the feature is implemented in the object / collection.
- hasNestedProperty() : array<string|int, bool>
- hasProperty() : array<string|int, bool>
- indexOf() : mixed
- {@inheritDoc}
- intersect() : PageCollection
- Intersect another collection with the current collection
- isEmpty() : mixed
- {@inheritDoc}
- isFirst() : bool
- Check to see if this item is the first in the collection.
- isLast() : bool
- Check to see if this item is the last in the collection.
- jsonSerialize() : array<string|int, mixed>
- Implements JsonSerializable interface.
- key() : mixed
- {@inheritDoc}
- last() : mixed
- {@inheritDoc}
- limit() : static
- loadEntriesFromStorage() : array<string|int, mixed>
- Method to load index from the object storage, usually filesystem.
- map() : mixed
- {@inheritDoc}
- matching() : ObjectCollectionInterface
- merge() : PageCollection
- Merge another collection with the current collection
- modular() : static
- Creates new collection with only modular pages
- modules() : static
- Creates new collection with only modular pages
- next() : mixed
- {@inheritDoc}
- nextSibling() : PageObject|null
- Gets the next sibling based on current position.
- nonModular() : static
- Creates new collection with only non-modular pages
- nonPublished() : static
- Creates new collection with only non-published pages
- nonRoutable() : static
- Creates new collection with only non-routable pages
- nonVisible() : static
- Creates new collection with only non-visible pages
- offsetExists() : bool
- Required by interface ArrayAccess.
- offsetGet() : mixed
- Required by interface ArrayAccess.
- offsetSet() : void
- Required by interface ArrayAccess.
- offsetUnset() : void
- Required by interface ArrayAccess.
- ofOneOfTheseAccessLevels() : static
- Creates new collection with only pages of one of the specified access levels
- ofOneOfTheseTypes() : static
- Creates new collection with only pages of one of the specified types
- ofType() : static
- Creates new collection with only pages of the specified type
- order() : static
- Reorder collection.
- orderBy() : static
- pages() : static
- Creates new collection with only non-modular pages
- params() : array<string|int, mixed>
- Get the collection params
- partition() : mixed
- {@inheritDoc}
- prevSibling() : PageObject|null
- Gets the previous sibling based on current position.
- published() : static
- Creates new collection with only published pages
- remove() : PageObject|null
- Remove item from the list.
- removeElement() : mixed
- {@inheritDoc}
- render() : ContentBlockInterface|HtmlBlock
- Renders the object.
- reverse() : static
- Reverse the order of the items.
- routable() : static
- Creates new collection with only routable pages
- search() : FlexCollectionInterface
- Search a string from the collection.
- select() : static
- Select items from collection.
- serialize() : string
- set() : mixed
- {@inheritDoc}
- setKey() : $this
- setNestedProperty() : ObjectCollectionInterface
- setParam() : $this
- Set a parameter to the Collection
- setParams() : $this
- Set parameters to the Collection
- setProperty() : ObjectCollectionInterface
- shuffle() : static
- Shuffle items.
- slice() : mixed
- {@inheritDoc}
- sort() : FlexCollectionInterface
- Sort the collection.
- toArray() : array<string|int, mixed>
- Converts collection into an array.
- toExtendedArray() : array<string|int, mixed>
- Get the extended version of this Collection with each page keyed by route
- unselect() : static
- Un-select items from collection.
- unserialize() : void
- unsetNestedProperty() : ObjectCollectionInterface
- unsetProperty() : ObjectCollectionInterface
- updateObjectMeta() : void
- You can define indexes for fast lookup.
- visible() : static
- Creates new collection with only visible pages
- withKeyField() : static
- Return new collection with a different key.
- withModules() : PageIndex
- withPages() : PageIndex
- withPublished() : FlexPageIndex
- withRoutable() : FlexPageIndex
- withTranslated() : static
- withTranslation() : PageIndex
- withVisible() : FlexPageIndex
- createFrom() : static
- Creates a new instance from the specified elements.
- filterByParent() : static
- getActiveUser() : UserInterface|null
- getAuthorizeScope() : string
- getContainer() : Grav
- getCurrentKey() : string
- getElementMeta() : mixed
- getEntries() : array<string|int, mixed>
- getFallbackLanguages() : array<string|int, mixed>
- getFlexContainer() : Flex
- getIndexFile() : CompiledJsonFile|CompiledYamlFile|null
- getIndexKeys() : array<string|int, mixed>
- getLanguageTemplates() : array<string|int, mixed>
- getLevelListingRecurse() : array<string|int, mixed>
- getListingActions() : array<string|int, mixed>
- getTypePrefix() : string
- getUnserializeAllowedClasses() : array<string|int, mixed>|bool
- isAdminSite() : bool
- isAllowedElement() : bool
- loadCollection() : CollectionInterface
- loadElement() : ObjectInterface|null
- loadElements() : array<string|int, ObjectInterface>
- loadEntriesFromIndex() : array<string|int, mixed>
- loadIndex() : array<string|int, mixed>
- onChanges() : void
- onException() : void
- setEntries() : void
- setIndexKeys() : void
- setKeyField() : void
- translateEntries() : array<string|int, mixed>
- updateIndexData() : void
- updateIndexFile() : array<string|int, mixed>
- jsDate() : string|null
Constants
ORDER_LIST_REGEX
public
mixed
ORDER_LIST_REGEX
= '/(\/\d+)\.[^\/]+/u'
ORDER_PREFIX_REGEX
public
mixed
ORDER_PREFIX_REGEX
= '/^\d+\./u'
PAGE_ROUTE_REGEX
public
mixed
PAGE_ROUTE_REGEX
= '/\/\d+\./u'
VERSION
public
mixed
VERSION
= parent::VERSION . '.5'
Properties
$_key
protected
string
$_key
$_params
protected
array<string|int, mixed>|null
$_params
$_root
protected
PageObject|array<string|int, mixed>
$_root
$type
protected
static string
$type
Methods
__call()
public
__call(string $name, array<string|int, mixed> $arguments) : mixed
Parameters
- $name : string
- $arguments : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
__construct()
Initializes a new FlexIndex.
public
__construct([array<string|int, mixed> $entries = [] ][, FlexDirectory|null $directory = null ]) : mixed
Parameters
- $entries : array<string|int, mixed> = []
- $directory : FlexDirectory|null = null
__debugInfo()
public
__debugInfo() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>__serialize()
public
__serialize() : array<string|int, mixed>
Return values
array<string|int, mixed>__toString()
Returns a string representation of this object.
public
__toString() : string
Attributes
- #[ReturnTypeWillChange]
Return values
string__unserialize()
public
__unserialize(array<string|int, mixed> $data) : void
Parameters
- $data : array<string|int, mixed>
add()
{@inheritDoc}
public
add(mixed $element) : mixed
Parameters
- $element : mixed
addPage()
Add a single page to a collection
public
addPage(PageInterface $page) : PageCollection
Parameters
- $page : PageInterface
Tags
Return values
PageCollectionadjacentSibling()
Returns the adjacent sibling based on a direction.
public
adjacentSibling(string $path[, int $direction = 1 ]) : PageObject|false
Parameters
- $path : string
- $direction : int = 1
-
either -1 or +1
Tags
Return values
PageObject|false —The sibling item.
all()
Mimicks Pages class.
public
all() : $this
Not needed anymore in Flex Pages (does nothing).
Return values
$thisbatch()
Split collection into array of smaller collections.
public
batch(int $size) : array<string|int, PageCollection>
Parameters
- $size : int
Tags
Return values
array<string|int, PageCollection>call()
public
call(mixed $method[, array<string|int, mixed> $arguments = [] ]) : array<string|int, mixed>|mixed
Parameters
- $method : mixed
- $arguments : array<string|int, mixed> = []
Return values
array<string|int, mixed>|mixedchunk()
Split collection into chunks.
public
chunk(int $size) : array<string|int, mixed>
Parameters
- $size : int
-
Size of each chunk.
Tags
Return values
array<string|int, mixed>clear()
{@inheritDoc}
public
clear() : mixed
collectionGroup()
Group items in the collection by a field and return them as associated array of collections.
public
collectionGroup(string $property) : array<string|int, ObjectCollectionInterface>
Parameters
- $property : string
Tags
Return values
array<string|int, ObjectCollectionInterface>contains()
{@inheritDoc}
public
contains(mixed $element) : mixed
Parameters
- $element : mixed
containsKey()
{@inheritDoc}
public
containsKey(mixed $key) : mixed
Parameters
- $key : mixed
copy()
Create a copy of this collection
public
copy() : static
Tags
Return values
staticcount()
{@inheritDoc}
public
count() : mixed
Attributes
- #[ReturnTypeWillChange]
createFromArray()
Creates a Flex Collection from an array.
public
static createFromArray(array<string|int, mixed> $entries, FlexDirectory $directory[, string $keyField = null ]) : static
Parameters
- $entries : array<string|int, mixed>
-
Associated array of Flex Objects to be included in the collection.
- $directory : FlexDirectory
-
Flex Directory where all the objects belong into.
- $keyField : string = null
-
Key field used to index the collection.
Tags
Return values
static —Returns a new Flex Collection.
createFromStorage()
Helper method to create Flex Index.
public
static createFromStorage(FlexDirectory $directory) : static
Parameters
- $directory : FlexDirectory
Tags
Return values
staticcurrent()
{@inheritDoc}
public
current() : mixed
Attributes
- #[ReturnTypeWillChange]
currentPosition()
Returns the item in the current position.
public
currentPosition(string $path) : int|null
Parameters
- $path : string
-
the path the item
Return values
int|null —The index of the current page, null if not found.
dateRange()
Returns the items between a set of date ranges of either the page date field (default) or an arbitrary datetime page field where start date and end date are optional Dates must be passed in as text that strtotime() can process http://php.net/manual/en/function.strtotime.php
public
dateRange([string|null $startDate = null ][, string|null $endDate = null ][, string|null $field = null ]) : static
Parameters
- $startDate : string|null = null
- $endDate : string|null = null
- $field : string|null = null
Tags
Return values
staticdefNestedProperty()
public
defNestedProperty(string $property, mixed $default[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfacedefProperty()
public
defProperty(string $property, mixed $default) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be defined.
- $default : mixed
-
Default value.
Tags
Return values
ObjectCollectionInterfaceexists()
{@inheritDoc}
public
exists(Closure $p) : mixed
Parameters
- $p : Closure
filter()
{@inheritDoc}
public
filter(Closure $p) : mixed
Parameters
- $p : Closure
filterBy()
Filter pages by given filters.
public
filterBy(array<string|int, mixed> $filters[, bool $recursive = false ]) : static
- search: string
- page_type: string|string[]
- modular: bool
- visible: bool
- routable: bool
- published: bool
- page: bool
- translated: bool
Parameters
- $filters : array<string|int, mixed>
- $recursive : bool = false
Tags
Return values
staticfirst()
{@inheritDoc}
public
first() : mixed
forAll()
{@inheritDoc}
public
forAll(Closure $p) : mixed
Parameters
- $p : Closure
get()
{@inheritDoc}
public
get(string $key) : PageObject|null
Parameters
- $key : string
Tags
Return values
PageObject|nullgetCache()
public
getCache([string|null $namespace = null ]) : CacheInterface
Parameters
- $namespace : string|null = null
Return values
CacheInterfacegetCacheChecksum()
Get cache checksum for the object / collection.
public
getCacheChecksum() : string
Tags
Return values
string —Returns cache checksum.
getCacheKey()
Get a cache key which is used for caching the object / collection.
public
getCacheKey() : string
Tags
Return values
string —Returns cache key.
getCollection()
Load all the objects into memory,
public
getCollection() : FlexCollectionInterface
Tags
Return values
FlexCollectionInterfacegetFlexDirectory()
Get Flex Directory for the object / collection.
public
getFlexDirectory() : FlexDirectory
Tags
Return values
FlexDirectory —Returns associated Flex Directory.
getFlexFeatures()
Get full list of features the object / collection implements.
public
getFlexFeatures() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>getFlexKeys()
Get Flex keys from all the objects in the collection.
public
getFlexKeys() : array<string|int, string>
Tags
Return values
array<string|int, string> —Returns[key => flex_key, ...] pairs.
getFlexType()
Get Flex Type of the object / collection.
public
getFlexType() : string
Tags
Return values
string —Returns Flex Type of the collection.
getIndex()
Get Flex Index from the Flex Collection.
public
getIndex() : FlexIndexInterface
Tags
Return values
FlexIndexInterface —Returns a Flex Index from the current collection.
getIndexMap()
public
getIndexMap([string $indexKey = null ]) : array<string|int, mixed>
Parameters
- $indexKey : string = null
Tags
Return values
array<string|int, mixed>getIterator()
Required by interface IteratorAggregate.
public
getIterator() : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
getKey()
public
getKey() : string
Return values
stringgetKeyField()
public
getKeyField() : string
Return values
stringgetKeys()
{@inheritDoc}
public
getKeys() : mixed
getLanguage()
public
getLanguage() : string|null
Return values
string|nullgetLevelListing()
public
getLevelListing(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
Return values
array<string|int, mixed>getMetaData()
Get metadata associated to the object
public
getMetaData(string $key) : array<string|int, mixed>
Parameters
- $key : string
Return values
array<string|int, mixed>getNestedProperty()
public
getNestedProperty(string $property[, mixed $default = null ][, string|null $separator = null ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, mixed> —Property values.
getObjectKeys()
public
getObjectKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>getParam()
Get the collection param
public
getParam(string $name) : mixed
Parameters
- $name : string
getParams()
Get the collection params
public
getParams() : array<string|int, mixed>
Return values
array<string|int, mixed>getProperty()
public
getProperty(string $property[, mixed $default = null ]) : array<string|int, mixed>
Parameters
- $property : string
-
Object property to be fetched.
- $default : mixed = null
-
Default value if property has not been set.
Return values
array<string|int, mixed> —Property values.
getRoot()
public
getRoot() : PageInterface
Return values
PageInterfacegetStorageKeys()
Get storage keys from all the objects in the collection.
public
getStorageKeys() : array<string|int, string>
Tags
Return values
array<string|int, string> —Returns [key => storage_key, ...] pairs.
getTimestamp()
Get last updated timestamp for the object / collection.
public
getTimestamp() : int
Tags
Return values
int —Returns Unix timestamp.
getTimestamps()
Get timestamps from all the objects in the collection.
public
getTimestamps() : array<string|int, int>
Tags
Return values
array<string|int, int> —Returns [key => timestamp, ...] pairs.
getType()
public
getType([bool $prefix = false ]) : string
Use ->getFlexType() instead.
Parameters
- $prefix : bool = false
Return values
stringgetValues()
{@inheritDoc}
public
getValues() : mixed
group()
Group items in the collection by a field and return them as associated array.
public
group(string $property) : array<string|int, mixed>
Parameters
- $property : string
Return values
array<string|int, mixed>hasFlexFeature()
Test whether the feature is implemented in the object / collection.
public
hasFlexFeature(string $name) : bool
Parameters
- $name : string
Tags
Return values
boolhasNestedProperty()
public
hasNestedProperty(string $property[, string|null $separator = null ]) : array<string|int, bool>
Parameters
- $property : string
-
Object property name.
- $separator : string|null = null
-
Separator, defaults to '.'
Return values
array<string|int, bool> —True if property has been defined (can be null).
hasProperty()
public
hasProperty(string $property) : array<string|int, bool>
Parameters
- $property : string
-
Object property name.
Return values
array<string|int, bool> —True if property has been defined (can be null).
indexOf()
{@inheritDoc}
public
indexOf(mixed $element) : mixed
Parameters
- $element : mixed
intersect()
Intersect another collection with the current collection
public
intersect(PageCollectionInterface $collection) : PageCollection
Parameters
- $collection : PageCollectionInterface
Tags
Return values
PageCollectionisEmpty()
{@inheritDoc}
public
isEmpty() : mixed
isFirst()
Check to see if this item is the first in the collection.
public
isFirst(string $path) : bool
Parameters
- $path : string
Return values
bool —True if item is first.
isLast()
Check to see if this item is the last in the collection.
public
isLast(string $path) : bool
Parameters
- $path : string
Return values
bool —True if item is last.
jsonSerialize()
Implements JsonSerializable interface.
public
jsonSerialize() : array<string|int, mixed>
Attributes
- #[ReturnTypeWillChange]
Return values
array<string|int, mixed>key()
{@inheritDoc}
public
key() : mixed
Attributes
- #[ReturnTypeWillChange]
last()
{@inheritDoc}
public
last() : mixed
limit()
public
limit(int $start[, int|null $limit = null ]) : static
Parameters
- $start : int
- $limit : int|null = null
Tags
Return values
staticloadEntriesFromStorage()
Method to load index from the object storage, usually filesystem.
public
static loadEntriesFromStorage(FlexStorageInterface $storage) : array<string|int, mixed>
Parameters
- $storage : FlexStorageInterface
Return values
array<string|int, mixed>map()
{@inheritDoc}
public
map(Closure $func) : mixed
Parameters
- $func : Closure
matching()
public
matching(Criteria $criteria) : ObjectCollectionInterface
Parameters
- $criteria : Criteria
Tags
Return values
ObjectCollectionInterfacemerge()
Merge another collection with the current collection
public
merge(PageCollectionInterface $collection) : PageCollection
Parameters
- $collection : PageCollectionInterface
Tags
Return values
PageCollectionmodular()
Creates new collection with only modular pages
public
modular() : static
Tags
Return values
static —The collection with only modular pages
modules()
Creates new collection with only modular pages
public
modules() : static
Tags
Return values
static —The collection with only modular pages
next()
{@inheritDoc}
public
next() : mixed
Attributes
- #[ReturnTypeWillChange]
nextSibling()
Gets the next sibling based on current position.
public
nextSibling(string $path) : PageObject|null
Parameters
- $path : string
Tags
Return values
PageObject|null —The next item.
nonModular()
Creates new collection with only non-modular pages
public
nonModular() : static
Tags
Return values
static —The collection with only non-modular pages
nonPublished()
Creates new collection with only non-published pages
public
nonPublished() : static
Tags
Return values
static —The collection with only non-published pages
nonRoutable()
Creates new collection with only non-routable pages
public
nonRoutable() : static
Tags
Return values
static —The collection with only non-routable pages
nonVisible()
Creates new collection with only non-visible pages
public
nonVisible() : static
Tags
Return values
static —The collection with only non-visible pages
offsetExists()
Required by interface ArrayAccess.
public
offsetExists(string|int|null $offset) : bool
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
Return values
booloffsetGet()
Required by interface ArrayAccess.
public
offsetGet(string|int|null $offset) : mixed
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
offsetSet()
Required by interface ArrayAccess.
public
offsetSet(string|int|null $offset, mixed $value) : void
Parameters
- $offset : string|int|null
- $value : mixed
Tags
Attributes
- #[ReturnTypeWillChange]
offsetUnset()
Required by interface ArrayAccess.
public
offsetUnset(string|int|null $offset) : void
Parameters
- $offset : string|int|null
Tags
Attributes
- #[ReturnTypeWillChange]
ofOneOfTheseAccessLevels()
Creates new collection with only pages of one of the specified access levels
public
ofOneOfTheseAccessLevels(array<string|int, mixed> $accessLevels) : static
Parameters
- $accessLevels : array<string|int, mixed>
Tags
Return values
static —The collection
ofOneOfTheseTypes()
Creates new collection with only pages of one of the specified types
public
ofOneOfTheseTypes(array<string|int, string> $types) : static
Parameters
- $types : array<string|int, string>
Tags
Return values
static —The collection
ofType()
Creates new collection with only pages of the specified type
public
ofType(string $type) : static
Parameters
- $type : string
Tags
Return values
static —The collection
order()
Reorder collection.
public
order(string $by[, string $dir = 'asc' ][, array<string|int, mixed> $manual = null ][, string $sort_flags = null ]) : static
Parameters
- $by : string
- $dir : string = 'asc'
- $manual : array<string|int, mixed> = null
- $sort_flags : string = null
Tags
Return values
staticorderBy()
public
orderBy(array<string|int, mixed> $orderings) : static
Parameters
- $orderings : array<string|int, mixed>
Tags
Return values
staticpages()
Creates new collection with only non-modular pages
public
pages() : static
Tags
Return values
static —The collection with only non-modular pages
params()
Get the collection params
public
params() : array<string|int, mixed>
Return values
array<string|int, mixed>partition()
{@inheritDoc}
public
partition(Closure $p) : mixed
Parameters
- $p : Closure
prevSibling()
Gets the previous sibling based on current position.
public
prevSibling(string $path) : PageObject|null
Parameters
- $path : string
Tags
Return values
PageObject|null —The previous item.
published()
Creates new collection with only published pages
public
published() : static
Tags
Return values
static —The collection with only published pages
remove()
Remove item from the list.
public
remove(string $key) : PageObject|null
Parameters
- $key : string
Tags
Return values
PageObject|nullremoveElement()
{@inheritDoc}
public
removeElement(mixed $element) : mixed
Parameters
- $element : mixed
render()
Renders the object.
public
render([string $layout = null ][, array<string|int, mixed> $context = [] ]) : ContentBlockInterface|HtmlBlock
Parameters
- $layout : string = null
-
Layout to be used.
- $context : array<string|int, mixed> = []
-
Extra context given to the renderer.
Tags
Return values
ContentBlockInterface|HtmlBlock —Returns HtmlBlock containing the rendered output.
reverse()
Reverse the order of the items.
public
reverse() : static
Tags
Return values
staticroutable()
Creates new collection with only routable pages
public
routable() : static
Tags
Return values
static —The collection with only routable pages
search()
Search a string from the collection.
public
search(string $search[, mixed $properties = null ][, array<string|int, mixed> $options = null ]) : FlexCollectionInterface
Parameters
- $search : string
-
Search string.
- $properties : mixed = null
-
Properties to search for, defaults to configured properties.
- $options : array<string|int, mixed> = null
-
Search options, defaults to configured options.
Tags
Return values
FlexCollectionInterface —Returns a Flex Collection with only matching objects.
select()
Select items from collection.
public
select(array<string|int, mixed> $keys) : static
Collection is returned in the order of $keys given to the function.
Parameters
- $keys : array<string|int, mixed>
Tags
Return values
staticserialize()
public
final serialize() : string
Return values
stringset()
{@inheritDoc}
public
set(mixed $key, mixed $value) : mixed
Parameters
- $key : mixed
- $value : mixed
setKey()
public
setKey(string $key) : $this
Parameters
- $key : string
Return values
$thissetNestedProperty()
public
setNestedProperty(string $property, mixed $value[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be updated.
- $value : mixed
-
New value.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfacesetParam()
Set a parameter to the Collection
public
setParam(string $name, mixed $value) : $this
Parameters
- $name : string
- $value : mixed
Return values
$thissetParams()
Set parameters to the Collection
public
setParams(array<string|int, mixed> $params) : $this
Parameters
- $params : array<string|int, mixed>
Return values
$thissetProperty()
public
setProperty(string $property, string $value) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be updated.
- $value : string
-
New value.
Tags
Return values
ObjectCollectionInterfaceshuffle()
Shuffle items.
public
shuffle() : static
Tags
Return values
staticslice()
{@inheritDoc}
public
slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
- $offset : mixed
- $length : mixed = null
sort()
Sort the collection.
public
sort(array<string|int, mixed> $orderings) : FlexCollectionInterface
Parameters
- $orderings : array<string|int, mixed>
-
Pair of [property => 'ASC'|'DESC', ...].
Tags
Return values
FlexCollectionInterface —Returns a sorted version from the collection.
toArray()
Converts collection into an array.
public
toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>toExtendedArray()
Get the extended version of this Collection with each page keyed by route
public
toExtendedArray() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed>unselect()
Un-select items from collection.
public
unselect(array<string|int, mixed> $keys) : static
Parameters
- $keys : array<string|int, mixed>
Tags
Return values
staticunserialize()
public
final unserialize(string $serialized) : void
Parameters
- $serialized : string
unsetNestedProperty()
public
unsetNestedProperty(string $property[, string|null $separator = null ]) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be unset.
- $separator : string|null = null
-
Separator, defaults to '.'
Tags
Return values
ObjectCollectionInterfaceunsetProperty()
public
unsetProperty(string $property) : ObjectCollectionInterface
Parameters
- $property : string
-
Object property to be unset.
Tags
Return values
ObjectCollectionInterfaceupdateObjectMeta()
You can define indexes for fast lookup.
public
static updateObjectMeta(array<string|int, mixed> &$meta, array<string|int, mixed> $data, FlexStorageInterface $storage) : void
Primary key: $meta['key'] Secondary keys: $meta['my_field']
Parameters
- $meta : array<string|int, mixed>
- $data : array<string|int, mixed>
- $storage : FlexStorageInterface
visible()
Creates new collection with only visible pages
public
visible() : static
Tags
Return values
static —The collection with only visible pages
withKeyField()
Return new collection with a different key.
public
withKeyField([string $keyField = null ]) : static
Parameters
- $keyField : string = null
-
Switch key field of the collection.
Tags
Return values
static —Returns a new Flex Collection with new key field.
withModules()
public
withModules([bool $bool = = 'true' ]) : PageIndex
Parameters
- $bool : bool = = 'true'
Return values
PageIndexwithPages()
public
withPages([bool $bool = = 'true' ]) : PageIndex
Parameters
- $bool : bool = = 'true'
Return values
PageIndexwithPublished()
public
withPublished([bool $bool = = 'true' ]) : FlexPageIndex
Parameters
- $bool : bool = = 'true'
Return values
FlexPageIndexwithRoutable()
public
withRoutable([bool $bool = = 'true' ]) : FlexPageIndex
Parameters
- $bool : bool = = 'true'
Return values
FlexPageIndexwithTranslated()
public
withTranslated([string|null $languageCode = null ][, bool|null $fallback = null ]) : static
Parameters
- $languageCode : string|null = null
- $fallback : bool|null = null
Tags
Return values
staticwithTranslation()
public
withTranslation([bool $bool = = 'true' ][, string $languageCode = = 'null' ][, bool $fallback = = 'null' ]) : PageIndex
Parameters
- $bool : bool = = 'true'
- $languageCode : string = = 'null'
- $fallback : bool = = 'null'
Return values
PageIndexwithVisible()
public
withVisible([bool $bool = = 'true' ]) : FlexPageIndex
Parameters
- $bool : bool = = 'true'
Return values
FlexPageIndexcreateFrom()
Creates a new instance from the specified elements.
protected
createFrom(array<string|int, mixed> $entries[, string|null $keyField = null ]) : static
Parameters
- $entries : array<string|int, mixed>
- $keyField : string|null = null
Tags
Return values
staticfilterByParent()
protected
filterByParent(array<string|int, mixed> $filters) : static
Parameters
- $filters : array<string|int, mixed>
Tags
Return values
staticgetActiveUser()
protected
getActiveUser() : UserInterface|null
Return values
UserInterface|nullgetAuthorizeScope()
protected
getAuthorizeScope() : string
Return values
stringgetContainer()
protected
getContainer() : Grav
Return values
GravgetCurrentKey()
protected
getCurrentKey(FlexObjectInterface $element) : string
Parameters
- $element : FlexObjectInterface
Return values
stringgetElementMeta()
protected
getElementMeta(FlexObjectInterface $object) : mixed
Parameters
- $object : FlexObjectInterface
getEntries()
protected
getEntries() : array<string|int, mixed>
Return values
array<string|int, mixed>getFallbackLanguages()
protected
getFallbackLanguages([string|null $languageCode = null ][, bool|null $fallback = null ]) : array<string|int, mixed>
Parameters
- $languageCode : string|null = null
- $fallback : bool|null = null
Return values
array<string|int, mixed>getFlexContainer()
protected
getFlexContainer() : Flex
Return values
FlexgetIndexFile()
protected
static getIndexFile(FlexStorageInterface $storage) : CompiledJsonFile|CompiledYamlFile|null
Parameters
- $storage : FlexStorageInterface
Return values
CompiledJsonFile|CompiledYamlFile|nullgetIndexKeys()
protected
getIndexKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>getLanguageTemplates()
protected
getLanguageTemplates(string $key) : array<string|int, mixed>
Parameters
- $key : string
Return values
array<string|int, mixed>getLevelListingRecurse()
protected
getLevelListingRecurse(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
- $options : array<string|int, mixed>
Return values
array<string|int, mixed>getListingActions()
protected
getListingActions(PageObject $object, UserInterface $user) : array<string|int, mixed>
Parameters
- $object : PageObject
- $user : UserInterface
Return values
array<string|int, mixed>getTypePrefix()
protected
getTypePrefix() : string
Return values
stringgetUnserializeAllowedClasses()
protected
getUnserializeAllowedClasses() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|boolisAdminSite()
protected
isAdminSite() : bool
Return values
boolisAllowedElement()
protected
isAllowedElement(mixed $value) : bool
Parameters
- $value : mixed
Return values
boolloadCollection()
protected
loadCollection([array<string|int, mixed>|null $entries = null ]) : CollectionInterface
Parameters
- $entries : array<string|int, mixed>|null = null
Tags
Return values
CollectionInterfaceloadElement()
protected
loadElement(string $key, mixed $value) : ObjectInterface|null
Parameters
- $key : string
- $value : mixed
Tags
Return values
ObjectInterface|nullloadElements()
protected
loadElements([array<string|int, mixed>|null $entries = null ]) : array<string|int, ObjectInterface>
Parameters
- $entries : array<string|int, mixed>|null = null
Tags
Return values
array<string|int, ObjectInterface>loadEntriesFromIndex()
protected
static loadEntriesFromIndex(FlexStorageInterface $storage) : array<string|int, mixed>
Parameters
- $storage : FlexStorageInterface
Return values
array<string|int, mixed>loadIndex()
protected
static loadIndex(FlexStorageInterface $storage) : array<string|int, mixed>
Parameters
- $storage : FlexStorageInterface
Return values
array<string|int, mixed>onChanges()
protected
static onChanges(array<string|int, mixed> $entries, array<string|int, mixed> $added, array<string|int, mixed> $updated, array<string|int, mixed> $removed) : void
Parameters
- $entries : array<string|int, mixed>
- $added : array<string|int, mixed>
- $updated : array<string|int, mixed>
- $removed : array<string|int, mixed>
onException()
protected
static onException(Exception $e) : void
Parameters
- $e : Exception
setEntries()
protected
setEntries(array<string|int, mixed> $entries) : void
Parameters
- $entries : array<string|int, mixed>
Tags
setIndexKeys()
protected
setIndexKeys(array<string|int, mixed> $indexKeys) : void
Parameters
- $indexKeys : array<string|int, mixed>
setKeyField()
protected
setKeyField([string|null $keyField = null ]) : void
Parameters
- $keyField : string|null = null
translateEntries()
protected
translateEntries(array<string|int, mixed> $entries, string $lang[, bool|null $fallback = null ]) : array<string|int, mixed>
Parameters
- $entries : array<string|int, mixed>
- $lang : string
- $fallback : bool|null = null
Return values
array<string|int, mixed>updateIndexData()
protected
static updateIndexData(array<string|int, mixed> &$entry, array<string|int, mixed> $data) : void
Use static ::updateObjectMeta() method instead.
Parameters
- $entry : array<string|int, mixed>
- $data : array<string|int, mixed>
updateIndexFile()
protected
static updateIndexFile(FlexStorageInterface $storage, array<string|int, mixed> $index, array<string|int, mixed> $entries[, array<string|int, mixed> $options = [] ]) : array<string|int, mixed>
Parameters
- $storage : FlexStorageInterface
- $index : array<string|int, mixed>
-
Saved index
- $entries : array<string|int, mixed>
-
Updated index
- $options : array<string|int, mixed> = []
Return values
array<string|int, mixed> —Compiled list of entries
jsDate()
private
jsDate([int|null $timestamp = null ]) : string|null
Parameters
- $timestamp : int|null = null