objects

Record

Base for anything stored as an _index.json + _data.json folder (Page, User).

Owns the uuid, created and updated envelope and splits saves between the two files.

$record Phlat\Data\Record 17 methods
Properties (8)
$record->uri string readonly
$record->path string readonly
$record->objectRoot string readonly
$record->uuid string readonly
$record->locked bool readonly
$record->created ?int readonly
$record->updated ?int readonly
$record->isRoot bool readonly
Show
  • 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.
  • exists Whether the record is on disk.
  • 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.
  • objectType The kind of record: `page`, `user` or `item`.
  • 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.
  • save Merges $data into the record and returns it as saved; this instance is left as it was read.
  • upload Validates and stores an uploaded file (a raw $_FILES-shape array) into this record's own folder.

Methods

$record->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
Record::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
$record->data(): DataFile

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

Returns DataFile

phlat/src/Data/Record.php:180
$record->exists(): bool

Whether the record is on disk.

Returns bool

phlat/src/Data/Record.php:204

generateUuid

static
Record::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
$record->index(): DataFile

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

Returns DataFile

phlat/src/Data/Record.php:174
$record->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
Record::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
$record->name(): string

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

Returns string

phlat/src/Data/Record.php:232
$record->objectType(): string

The kind of record: `page`, `user` or `item`.

Returns string

phlat/src/Data/Record.php:119
$record->path(): string

The record's folder, with a trailing slash.

Returns string

phlat/src/Data/Record.php:210
$record->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
$record->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
$record->registryKey(): string

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

Returns string

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

The path stored in the registry for this object.

Returns string

phlat/src/Data/Record.php:150
$record->save(array $data = []): self

Merges $data into the record and returns it as saved; this instance is left as it was read.

Parameters (1)
$data array = []

Returns self

phlat/src/Data/Record.php:238
$record->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