objects

PageCollection

A RecordCollection of Page objects.

$pageCollection Phlat\Collections\PageCollection extends RecordCollection 23 methods
Properties (1)
$pageCollection->app App readonly
Show
  • delete Deletes every page here and its persisted subtree, as one operation: a match inside another match goes with it, and a locked page or locked descendant refuses the whole call before anything is removed.
  • first The first page, or null when empty.
  • last The last page, or null when empty.
  • nth Returns the item at a 0-based index, or null if out of bounds.

From RecordCollection 19

  • accepts Whether $item is an instance this collection is meant to hold.
  • all Returns true if all items pass $fn (respects limit/offset).
  • any Returns true if any item passes $fn (respects limit/offset).
  • append Adds a record to the end; null is ignored.
  • appendPath Append a page URI string for lazy loading on iteration.
  • contains True if $item's type matches this collection and an item with the same uuid is already present.
  • count Total number of items held, ignoring limit/offset.
  • each Calls $fn for each item (respecting limit/offset) and returns self.
  • filter Returns a new collection of items where the callback returns true.
  • getIterator Yields items respecting limit/offset, hydrating lazy paths in place.
  • import Appends each record in $items.
  • isEmpty Whether the collection holds no records.
  • limit Returns a new collection capped to $limit items on iteration.
  • offset Returns a new collection that skips the first $offset items on iteration.
  • paths The registry path of every item, ignoring limit/offset and hydrating nothing.
  • pluck Returns an array of $field values from each item (respects limit/offset).
  • reverse Returns a new collection with the items in reverse order.
  • toArray Returns all items as a plain array, respecting limit/offset, hydrating any lazy paths.
  • total How many records the whole query matches, ignoring limit/offset - what the builder supplied, else the items held.

Methods

$pageCollection->delete(): int

Deletes every page here and its persisted subtree, as one operation: a match inside another match goes with it, and a locked page or locked descendant refuses the whole call before anything is removed.

Emits page.delete:before for every page that goes and page.delete:after for each match, drops the index rows and collection items in one transaction each, and records several matches in History as one entry. Returns how many pages went, descendants included.

Returns int

phlat/src/Collections/PageCollection.php:48
$pageCollection->first(): ?Page

The first page, or null when empty.

Returns ?Page

phlat/src/Collections/PageCollection.php:22
$pageCollection->last(): ?Page

The last page, or null when empty.

Returns ?Page

phlat/src/Collections/PageCollection.php:29

nth

$pageCollection->nth(int $index): ?Page

Returns the item at a 0-based index, or null if out of bounds.

Ignores limit/offset.

Parameters (1)
$index int

Returns ?Page

phlat/src/Collections/PageCollection.php:35

From RecordCollection

$pageCollection->accepts(Record $item): bool

Whether $item is an instance this collection is meant to hold.

Parameters (1)
$item Record

Returns bool

phlat/src/Collections/RecordCollection.php:136

all

$pageCollection->all(callable $fn): bool

Returns true if all items pass $fn (respects limit/offset).

True for empty collections.

Parameters (1)
$fn callable

Returns bool

phlat/src/Collections/RecordCollection.php:186

any

$pageCollection->any(callable $fn): bool

Returns true if any item passes $fn (respects limit/offset).

Parameters (1)
$fn callable

Returns bool

phlat/src/Collections/RecordCollection.php:176
$pageCollection->append(?Record $item): self

Adds a record to the end; null is ignored.

Parameters (1)
$item ?Record

Returns self

phlat/src/Collections/RecordCollection.php:31
$pageCollection->appendPath(string $path): self

Append a page URI string for lazy loading on iteration.

Parameters (1)
$path string

Returns self

phlat/src/Collections/RecordCollection.php:41
$pageCollection->contains(Record $item): bool

True if $item's type matches this collection and an item with the same uuid is already present.

Parameters (1)
$item Record

Returns bool

phlat/src/Collections/RecordCollection.php:142
$pageCollection->count(): int

Total number of items held, ignoring limit/offset.

Returns int

phlat/src/Collections/RecordCollection.php:81
$pageCollection->each(callable $fn): self

Calls $fn for each item (respecting limit/offset) and returns self.

Parameters (1)
$fn callable

Returns self

phlat/src/Collections/RecordCollection.php:167
$pageCollection->filter(callable $fn): static

Returns a new collection of items where the callback returns true.

Ignores limit/offset.

Parameters (1)
$fn callable

Returns static

phlat/src/Collections/RecordCollection.php:206
$pageCollection->getIterator(): Generator

Yields items respecting limit/offset, hydrating lazy paths in place.

Safe to nest - each loop gets its own generator.

Returns Generator

phlat/src/Collections/RecordCollection.php:222
$pageCollection->import(array $items): self

Appends each record in $items.

Parameters (1)
$items array

Returns self

phlat/src/Collections/RecordCollection.php:48
$pageCollection->isEmpty(): bool

Whether the collection holds no records.

Returns bool

phlat/src/Collections/RecordCollection.php:130
$pageCollection->limit(int $limit): static

Returns a new collection capped to $limit items on iteration.

Parameters (1)
$limit int

Returns static

phlat/src/Collections/RecordCollection.php:65
$pageCollection->offset(int $offset): static

Returns a new collection that skips the first $offset items on iteration.

Parameters (1)
$offset int

Returns static

phlat/src/Collections/RecordCollection.php:73
$pageCollection->paths(): array

The registry path of every item, ignoring limit/offset and hydrating nothing.

Returns array

phlat/src/Collections/RecordCollection.php:151
$pageCollection->pluck(string $field): array

Returns an array of $field values from each item (respects limit/offset).

Parameters (1)
$field string

Returns array

phlat/src/Collections/RecordCollection.php:196
$pageCollection->reverse(): static

Returns a new collection with the items in reverse order.

Returns static

phlat/src/Collections/RecordCollection.php:57
$pageCollection->toArray(): array

Returns all items as a plain array, respecting limit/offset, hydrating any lazy paths.

Returns array

phlat/src/Collections/RecordCollection.php:157
$pageCollection->total(): int

How many records the whole query matches, ignoring limit/offset - what the builder supplied, else the items held.

Pagination reads this.

Returns int

phlat/src/Collections/RecordCollection.php:87