Documentation

PageCollection extends FlexPageCollection implements PageCollectionInterface uses FlexGravTrait, FlexCollectionTrait

Class GravPageCollection

Tags
template
extends
implements

Incompatibilities with Grav\Common\Page\Collection: $page = $collection->key() will not work at all $clone = clone $collection does not clone objects inside the collection, does it matter? $string = (string)$collection returns collection id instead of comma separated list $collection->add() incompatible method signature $collection->remove() incompatible method signature $collection->filter() incompatible method signature (takes closure instead of callable) $collection->prev() does not rewind the internal pointer AND most methods are immutable; they do not update the current collection, but return updated one

Table of Contents

Interfaces

PageCollectionInterface
Interface PageCollectionInterface

Properties

$_params  : array<string|int, mixed>|null

Methods

addPage()  : $this
Add a single page to a collection
adjacentSibling()  : PageInterface|false
Returns the adjacent sibling based on a direction.
all()  : $this
Mimicks Pages class.
append()  : static
Append new elements to the list.
batch()  : array<string|int, static>
Split collection into array of smaller collections.
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
filterBy()  : static
Filter pages by given filters.
getCachedMethods()  : array<string|int, mixed>
getIndex()  : PageIndex
getLevelListing()  : array<string|int, mixed>
getNextOrder()  : string
getParams()  : array<string|int, mixed>
Get the collection params
getRoot()  : PageInterface
intersect()  : static
Intersect another collection with the current collection
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.
merge()  : static
Merge another collection with the current collection
modular()  : static
Alias of modules()
modules()  : static
Creates new collection with only modules
nextSibling()  : PageInterface|false
Gets the next sibling based on current position.
nonModular()  : static
Alias of 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
nth()  : PageInterface|bool
Return nth item.
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.
pages()  : static
Creates new collection with only pages
params()  : array<string|int, mixed>
Get the collection params
prev()  : PageInterface|false
Return previous item.
prevSibling()  : PageInterface|false
Gets the previous sibling based on current position.
published()  : static
Creates new collection with only published pages
random()  : static
Pick one or more random entries.
routable()  : static
Creates new collection with only routable pages
setCurrent()  : void
Set current page.
setParams()  : $this
Set parameters to the Collection
toExtendedArray()  : array<string|int, mixed>
Get the extended version of this Collection with each page keyed by route
triggerEvent()  : $this
visible()  : static
Creates new collection with only visible pages
withModules()  : static
withOrdered()  : static
withPages()  : static
withPublished()  : static
withRoutable()  : static
withTranslated()  : PageIndex
withTranslation()  : static
withVisible()  : static
buildSort()  : array<string|int, mixed>
getActiveUser()  : UserInterface|null
getAuthorizeScope()  : string
getContainer()  : Grav
getFlexContainer()  : Flex
isAdminSite()  : bool

Properties

Methods

adjacentSibling()

Returns the adjacent sibling based on a direction.

public adjacentSibling(string $path[, int $direction = 1 ]) : PageInterface|false
Parameters
$path : string
$direction : int = 1

either -1 or +1

Tags
phpstan-return

T|false

Return values
PageInterface|false

The sibling item.

all()

Mimicks Pages class.

public all() : $this

Not needed anymore in Flex Pages (does nothing).

Return values
$this

append()

Append new elements to the list.

public append(array<string|int, mixed> $items) : static
Parameters
$items : array<string|int, mixed>

Items to be appended. Existing keys will be overridden with the new values.

Tags
phpstan-return

static<T>

Return values
static

batch()

Split collection into array of smaller collections.

public batch(int $size) : array<string|int, static>
Parameters
$size : int
Tags
phpstan-return

static<T>[]

Return values
array<string|int, static>

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

static<T>

throws
Exception
Return values
static

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

static<T>

Return values
static

getCachedMethods()

public static getCachedMethods() : array<string|int, mixed>
Return values
array<string|int, mixed>

getLevelListing()

public getLevelListing(array<string|int, mixed> $options) : array<string|int, mixed>
Parameters
$options : array<string|int, mixed>
Return values
array<string|int, mixed>

getParams()

Get the collection params

public getParams() : array<string|int, mixed>
Return values
array<string|int, 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.

modular()

Alias of modules()

public modular() : static
Tags
phpstan-return

static<T>

Return values
static

modules()

Creates new collection with only modules

public modules() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only modules

nextSibling()

Gets the next sibling based on current position.

public nextSibling(string $path) : PageInterface|false
Parameters
$path : string
Tags
phpstan-return

T|false

Return values
PageInterface|false

The next item.

nonModular()

Alias of pages()

public nonModular() : static
Tags
phpstan-return

static<T>

Return values
static

nonPublished()

Creates new collection with only non-published pages

public nonPublished() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only non-published pages

nonRoutable()

Creates new collection with only non-routable pages

public nonRoutable() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only non-routable pages

nonVisible()

Creates new collection with only non-visible pages

public nonVisible() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only non-visible pages

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

static<T>

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

static<T>

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

static<T>

Return values
static

The collection

order()

Reorder collection.

public order(string $by[, string $dir = 'asc' ][, array<string|int, mixed>|null $manual = null ][, int|null $sort_flags = null ]) : static
Parameters
$by : string
$dir : string = 'asc'
$manual : array<string|int, mixed>|null = null
$sort_flags : int|null = null
Tags
phpstan-return

static<T>

Return values
static

pages()

Creates new collection with only pages

public pages() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only pages

params()

Get the collection params

public params() : array<string|int, mixed>
Return values
array<string|int, mixed>

prevSibling()

Gets the previous sibling based on current position.

public prevSibling(string $path) : PageInterface|false
Parameters
$path : string
Tags
phpstan-return

T|false

Return values
PageInterface|false

The previous item.

published()

Creates new collection with only published pages

public published() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only published pages

random()

Pick one or more random entries.

public random([int $num = 1 ]) : static
Parameters
$num : int = 1

Specifies how many entries should be picked.

Tags
phpstan-return

static<T>

Return values
static

routable()

Creates new collection with only routable pages

public routable() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only routable pages

setCurrent()

Set current page.

public setCurrent(string $path) : void
Parameters
$path : string

setParams()

Set parameters to the Collection

public setParams(array<string|int, mixed> $params) : $this
Parameters
$params : array<string|int, mixed>
Return values
$this

toExtendedArray()

Get the extended version of this Collection with each page keyed by route

public toExtendedArray() : array<string|int, mixed>
Tags
throws
Exception
Return values
array<string|int, mixed>

triggerEvent()

public triggerEvent(string $name[, object|null $event = null ]) : $this
Parameters
$name : string
$event : object|null = null
Return values
$this

visible()

Creates new collection with only visible pages

public visible() : static
Tags
phpstan-return

static<T>

Return values
static

The collection with only visible pages

withModules()

public withModules([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

withOrdered()

public withOrdered([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

withPages()

public withPages([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

withPublished()

public withPublished([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

withRoutable()

public withRoutable([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

withTranslated()

public withTranslated([string|null $languageCode = null ][, bool|null $fallback = null ]) : PageIndex
Parameters
$languageCode : string|null = null
$fallback : bool|null = null
Return values
PageIndex

withTranslation()

public withTranslation([bool $bool = true ][, string|null $languageCode = null ][, bool|null $fallback = null ]) : static
Parameters
$bool : bool = true
$languageCode : string|null = null
$fallback : bool|null = null
Tags
phpstan-return

static<T>

Return values
static

withVisible()

public withVisible([bool $bool = true ]) : static
Parameters
$bool : bool = true
Tags
phpstan-return

static<T>

Return values
static

buildSort()

protected buildSort([string $order_by = 'default' ][, string $order_dir = 'asc' ][, array<string|int, mixed>|null $manual = null ][, int|null $sort_flags = null ]) : array<string|int, mixed>
Parameters
$order_by : string = 'default'
$order_dir : string = 'asc'
$manual : array<string|int, mixed>|null = null
$sort_flags : int|null = null
Return values
array<string|int, mixed>

getAuthorizeScope()

protected getAuthorizeScope() : string
Return values
string

isAdminSite()

protected isAdminSite() : bool
Return values
bool

        
On this page

Search results