objects

Item

One entry of a collection field.

It lives in its Collection's database, not in files: the collection hands it over from a row, and a save or delete goes back through the collection.

$item Phlat\Data\Item extends Record 19 methods
Properties (10)
$item->parent string readonly
$item->field string readonly
$item->uri string readonly
$item->path string readonly
$item->objectRoot string readonly
$item->uuid string readonly
$item->locked bool readonly
$item->created ?int readonly
$item->updated ?int readonly
$item->isRoot bool readonly
Show
  • delete Removes the item from its collection.
  • exists Still in its collection - false once it has been deleted.
  • fields This item's declared fields (its collection field's options.fields) as resolved FieldValue instances - mirrors Page::fields().
  • objectType Always `item`.
  • save Merges $data into the item, in the collection, and returns the item as saved.

From Record 14

  • assertUnlocked A locked record is protected: it can't be changed or deleted until `locked` is turned off.
  • create The one way a record comes into being: under the lock for $key (default: the path) $guard refuses a conflict, then $make builds the record at $path and save() applies $data.
  • data The `_data.json` file: the record's content.
  • generateUuid The current system uuid format - the single source of truth for tooling that needs to mint or recognize one.
  • index The `_index.json` file: uuid, timestamps and the type's structural keys.
  • isSiteObject Whether it lives in the site rather than in `phlat/` or an addon.
  • keyFor Builds a registry uuid key from a type and identity value, e.g. keyFor('page', $uuid) -> "page:{uuid}".
  • name The folder name: the last segment of a page's URL, or a username.
  • path The record's folder, with a trailing slash.
  • publishedData The canonical _data.json contents, bypassing any draft/preview override (e.g.
  • registryFields Extra registry columns this object type contributes (e.g. view for pages, role for users).
  • registryKey The registry's uuid key for this object, e.g. "page:{uuid}".
  • registryPath The path stored in the registry for this object.
  • upload Validates and stores an uploaded file (a raw $_FILES-shape array) into this record's own folder.

Methods

$item->delete(): void

Removes the item from its collection.

phlat/src/Data/Item.php:73
$item->exists(): bool

Still in its collection - false once it has been deleted.

Returns bool

phlat/src/Data/Item.php:61
$item->fields(): FieldValueSet

This item's declared fields (its collection field's options.fields) as resolved FieldValue instances - mirrors Page::fields().

Returns FieldValueSet

phlat/src/Data/Item.php:79
$item->objectType(): string

Always `item`.

Returns string

phlat/src/Data/Item.php:31
$item->save(array $data = []): Item

Merges $data into the item, in the collection, and returns the item as saved.

Parameters (1)
$data array = []

Returns Item

phlat/src/Data/Item.php:67

From Record

$item->assertUnlocked(): void

A locked record is protected: it can't be changed or deleted until `locked` is turned off.

phlat/src/Data/Record.php:288

create

static
Item::create(App $app, string $path, array $data, callable $make, callable $guard, string $uuid = '', ?string $key = null): T

The one way a record comes into being: under the lock for $key (default: the path) $guard refuses a conflict, then $make builds the record at $path and save() applies $data.

Emits {page|user|item}.create:after.

Parameters (7)
$app App
$path string
$data array
$make callable
$guard callable
$uuid string = ''
$key ?string = null

Returns T

phlat/src/Data/Record.php:90
$item->data(): DataFile

The `_data.json` file: the record's content.

Returns DataFile

phlat/src/Data/Record.php:180

generateUuid

static
Item::generateUuid(App $app): string

The current system uuid format - the single source of truth for tooling that needs to mint or recognize one.

Parameters (1)
$app App

Returns string

phlat/src/Data/Record.php:76
$item->index(): DataFile

The `_index.json` file: uuid, timestamps and the type's structural keys.

Returns DataFile

phlat/src/Data/Record.php:174
$item->isSiteObject(): bool

Whether it lives in the site rather than in `phlat/` or an addon.

Returns bool

phlat/src/Data/Record.php:168

keyFor

static
Item::keyFor(string $type, string $value): string

Builds a registry uuid key from a type and identity value, e.g. keyFor('page', $uuid) -> "page:{uuid}".

Parameters (2)
$type string
$value string

Returns string

phlat/src/Data/Record.php:156
$item->name(): string

The folder name: the last segment of a page's URL, or a username.

Returns string

phlat/src/Data/Record.php:232
$item->path(): string

The record's folder, with a trailing slash.

Returns string

phlat/src/Data/Record.php:210
$item->publishedData(): DataFile

The canonical _data.json contents, bypassing any draft/preview override (e.g.

Page's autosave-aware data()). Writes and search indexing must always go through this, never the overridable data() accessor, so a draft in progress can never clobber or leak into the persisted record.

Returns DataFile

phlat/src/Data/Record.php:191
$item->registryFields(): array

Extra registry columns this object type contributes (e.g. view for pages, role for users).

Returns array

phlat/src/Data/Record.php:125
$item->registryKey(): string

The registry's uuid key for this object, e.g. "page:{uuid}".

Returns string

phlat/src/Data/Record.php:162
$item->registryPath(): string

The path stored in the registry for this object.

Returns string

phlat/src/Data/Record.php:150
$item->upload(array $file, array $options = []): PageFile

Validates and stores an uploaded file (a raw $_FILES-shape array) into this record's own folder.

Only a page or a user owns files.

Parameters (2)
$file array
$options array = []

Returns PageFile

phlat/src/Data/Record.php:216