Documentation

FlexPageIndex extends FlexIndex

Class FlexPageObject

Tags
template
template
extends

Table of Contents

Constants

ORDER_PREFIX_REGEX  = '/^\d+\./u'
VERSION  = 1

Properties

$_key  : string
$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}
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 from this collection by cloning all objects in the collection.
count()  : mixed
{@inheritDoc}
createFromArray()  : static
Creates a Flex Collection from an array.
createFromStorage()  : static
Helper method to create Flex Index.
current()  : mixed
{@inheritDoc}
defNestedProperty()  : ObjectCollectionInterface
defProperty()  : ObjectCollectionInterface
exists()  : mixed
{@inheritDoc}
filter()  : mixed
{@inheritDoc}
filterBy()  : FlexCollectionInterface
Filter collection by filter array with keys and values.
first()  : mixed
{@inheritDoc}
forAll()  : mixed
{@inheritDoc}
get()  : mixed
{@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}
getMetaData()  : array<string|int, mixed>
Get metadata associated to the object
getNestedProperty()  : array<string|int, mixed>
getObjectKeys()  : array<string|int, mixed>
getProperty()  : array<string|int, mixed>
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}
isEmpty()  : mixed
{@inheritDoc}
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
next()  : mixed
{@inheritDoc}
offsetExists()  : bool
Required by interface ArrayAccess.
offsetGet()  : mixed
Required by interface ArrayAccess.
offsetSet()  : void
Required by interface ArrayAccess.
offsetUnset()  : void
Required by interface ArrayAccess.
orderBy()  : static
partition()  : mixed
{@inheritDoc}
remove()  : mixed
{@inheritDoc}
removeElement()  : mixed
{@inheritDoc}
render()  : ContentBlockInterface|HtmlBlock
Renders the object.
reverse()  : static
Reverse the order of the items.
search()  : FlexCollectionInterface
Search a string from the collection.
select()  : static
Select items from collection.
serialize()  : string
set()  : mixed
{@inheritDoc}
setKey()  : $this
setNestedProperty()  : ObjectCollectionInterface
setProperty()  : ObjectCollectionInterface
shuffle()  : static
Shuffle items.
slice()  : mixed
{@inheritDoc}
sort()  : FlexCollectionInterface
Sort the collection.
toArray()  : mixed
{@inheritDoc}
unselect()  : static
Un-select items from collection.
unserialize()  : void
unsetNestedProperty()  : ObjectCollectionInterface
unsetProperty()  : ObjectCollectionInterface
updateObjectMeta()  : void
You can define indexes for fast lookup.
withKeyField()  : static
Return new collection with a different key.
withPublished()  : FlexPageIndex
withRoutable()  : FlexPageIndex
withVisible()  : FlexPageIndex
createFrom()  : static
Creates a new instance from the specified elements.
getCurrentKey()  : string
getElementMeta()  : mixed
getEntries()  : array<string|int, mixed>
getIndexFile()  : CompiledYamlFile|CompiledJsonFile|null
getIndexKeys()  : array<string|int, mixed>
getTypePrefix()  : string
getUnserializeAllowedClasses()  : array<string|int, mixed>|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
updateIndexData()  : void
updateIndexFile()  : array<string|int, mixed>

Constants

ORDER_PREFIX_REGEX

public mixed ORDER_PREFIX_REGEX = '/^\d+\./u'

Properties

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>

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>|mixed

chunk()

Split collection into chunks.

public chunk(int $size) : array<string|int, mixed>
Parameters
$size : int

Size of each chunk.

Tags
phpstan-return

array<array<TKey,T>>

Return values
array<string|int, 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
phpstan-return

C[]

Return values
array<string|int, ObjectCollectionInterface>

copy()

Create a copy from this collection by cloning all objects in the collection.

public copy() : static
Return values
static

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
see
FlexCollectionInterface::createFromArray()
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
phpstan-return

static<T,C>

Return values
static

defNestedProperty()

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
phpstan-return

C

Return values
ObjectCollectionInterface

getCacheChecksum()

Get cache checksum for the object / collection.

public getCacheChecksum() : string
Tags
see
FlexCollectionInterface::getCacheChecksum()
Return values
string

Returns cache checksum.

getCacheKey()

Get a cache key which is used for caching the object / collection.

public getCacheKey() : string
Tags
see
FlexCollectionInterface::getCacheKey()
Return values
string

Returns cache key.

getFlexDirectory()

Get Flex Directory for the object / collection.

public getFlexDirectory() : FlexDirectory
Tags
see
FlexCollectionInterface::getFlexDirectory()
Return values
FlexDirectory

Returns associated Flex Directory.

getFlexFeatures()

Get full list of features the object / collection implements.

public getFlexFeatures() : array<string|int, mixed>
Tags
see
FlexCommonInterface::hasFlexFeature()
Return values
array<string|int, mixed>

getFlexKeys()

Get Flex keys from all the objects in the collection.

public getFlexKeys() : array<string|int, string>
Tags
see
FlexCollectionInterface::getFlexKeys()
Return values
array<string|int, string>

Returns[key => flex_key, ...] pairs.

getFlexType()

Get Flex Type of the object / collection.

public getFlexType() : string
Tags
see
FlexCollectionInterface::getFlexType()
Return values
string

Returns Flex Type of the collection.

getIndexMap()

public getIndexMap([string $indexKey = null ]) : array<string|int, mixed>
Parameters
$indexKey : string = null
Tags
see
FlexIndexInterface::getFlexKeys()
Return values
array<string|int, mixed>

getIterator()

Required by interface IteratorAggregate.

public getIterator() : mixed
Tags
phpstan-return

Iterator<TKey,T>

Attributes
#[ReturnTypeWillChange]

getKey()

public getKey() : string
Return values
string

getKeyField()

public getKeyField() : string
Return values
string

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>

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.

getStorageKeys()

Get storage keys from all the objects in the collection.

public getStorageKeys() : array<string|int, string>
Tags
see
FlexCollectionInterface::getStorageKeys()
Return values
array<string|int, string>

Returns [key => storage_key, ...] pairs.

getTimestamp()

Get last updated timestamp for the object / collection.

public getTimestamp() : int
Tags
see
FlexCollectionInterface::getTimestamp()
Return values
int

Returns Unix timestamp.

getTimestamps()

Get timestamps from all the objects in the collection.

public getTimestamps() : array<string|int, int>
Tags
see
FlexCollectionInterface::getTimestamps()
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
string

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
see
FlexCommonInterface::hasFlexFeature()
Return values
bool

hasNestedProperty()

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).

jsonSerialize()

Implements JsonSerializable interface.

public jsonSerialize() : array<string|int, mixed>
Attributes
#[ReturnTypeWillChange]
Return values
array<string|int, mixed>

limit()

public limit(int $start[, int|null $limit = null ]) : static
Parameters
$start : int
$limit : int|null = null
Tags
phpstan-return

static<TKey,T,C>

Return values
static

loadEntriesFromStorage()

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>

offsetExists()

Required by interface ArrayAccess.

public offsetExists(string|int|null $offset) : bool
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]
Return values
bool

offsetGet()

Required by interface ArrayAccess.

public offsetGet(string|int|null $offset) : mixed
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

offsetSet()

Required by interface ArrayAccess.

public offsetSet(string|int|null $offset, mixed $value) : void
Parameters
$offset : string|int|null
$value : mixed
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

offsetUnset()

Required by interface ArrayAccess.

public offsetUnset(string|int|null $offset) : void
Parameters
$offset : string|int|null
Tags
phpstan-param

TKey|null $offset

Attributes
#[ReturnTypeWillChange]

orderBy()

public orderBy(array<string|int, mixed> $orderings) : static
Parameters
$orderings : array<string|int, mixed>
Tags
phpstan-return

static<T,C>

Return values
static

removeElement()

{@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
see
FlexCollectionInterface::render()
Return values
ContentBlockInterface|HtmlBlock

Returns HtmlBlock containing the rendered output.

reverse()

Reverse the order of the items.

public reverse() : static
Tags
phpstan-return

static<TKey,T,C>

Return values
static

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
see
FlexCollectionInterface::search()
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
phpstan-return

static<TKey,T,C>

Return values
static

serialize()

public final serialize() : string
Return values
string

set()

{@inheritDoc}

public set(mixed $key, mixed $value) : mixed
Parameters
$key : mixed
$value : mixed

setKey()

public setKey(string $key) : $this
Parameters
$key : string
Return values
$this

setNestedProperty()

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
phpstan-return

C

Return values
ObjectCollectionInterface

shuffle()

Shuffle items.

public shuffle() : static
Tags
phpstan-return

static<TKey,T,C>

Return values
static

slice()

{@inheritDoc}

public slice(mixed $offset[, mixed $length = null ]) : mixed
Parameters
$offset : mixed
$length : mixed = null

unselect()

Un-select items from collection.

public unselect(array<string|int, mixed> $keys) : static
Parameters
$keys : array<string|int, mixed>
Tags
phpstan-return

static<TKey,T,C>

Return values
static

unserialize()

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
phpstan-return

C

Return values
ObjectCollectionInterface

updateObjectMeta()

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

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
see
FlexIndexInterface::withKeyField()
Return values
static

Returns a new Flex Collection with new key field.

createFrom()

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
phpstan-return

static<T,C>

Return values
static

getEntries()

protected getEntries() : array<string|int, mixed>
Return values
array<string|int, mixed>

getIndexKeys()

protected getIndexKeys() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTypePrefix()

protected getTypePrefix() : string
Return values
string

getUnserializeAllowedClasses()

protected getUnserializeAllowedClasses() : array<string|int, mixed>|bool
Return values
array<string|int, mixed>|bool

isAllowedElement()

protected isAllowedElement(mixed $value) : bool
Parameters
$value : mixed
Return values
bool

loadElements()

protected loadElements([array<string|int, mixed>|null $entries = null ]) : array<string|int, ObjectInterface>
Parameters
$entries : array<string|int, mixed>|null = null
Tags
phpstan-return

T[]

Return values
array<string|int, ObjectInterface>

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
phpstan-param

array<TKey,T> $entries

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

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


        
On this page

Search results