objects

User

A user account.

Login credentials and role live in _data.json like any other record content.

$user Phlat\User extends Record 27 methods
Properties (10)
$user->username string readonly
$user->role string readonly
$user->uri string readonly
$user->path string readonly
$user->objectRoot string readonly
$user->uuid string readonly
$user->locked bool readonly
$user->created ?int readonly
$user->updated ?int readonly
$user->isRoot bool readonly
Show
  • authenticate Whether $password matches the stored hash.
  • can Whether the user's role grants permission $key.
  • childFields The fields a new account is made from - username, password and role - like Page::childFields(); asked of the user root.
  • delete Deletes this user's folder, emitting user.delete:before and dropping the index rows first so they don't outlive the files they point to.
  • fields This user's declared profile fields (roles/_index.json's "fields") as resolved FieldValue instances - mirrors Page::fields().
  • new Creates a new user under the users root: mints its uuid and writes a minimal _index.json, then applies $data via the normal save() path (role, an already-hashed password, ...).
  • objectType Always `user`.
  • passwordFields A password change: the new one twice, and the current one first when the user changes their own.
  • registryFields Extra registry columns this object type contributes (e.g. view for pages, role for users).
  • role The user's role, with its permissions.
  • save Persists user data like Record::save(), then emits user.update:after so the field/search index follows.
  • setPassword Hashes and saves a new password.
  • settingFields The account settings an admin sets - role and locked - as FieldValues, like Page::settingFields().

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.
  • 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.
  • path The record's folder, with a trailing slash.
  • publishedData The canonical _data.json contents, bypassing any draft/preview override (e.g.
  • 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

$user->authenticate(string $password): bool

Whether $password matches the stored hash.

Parameters (1)
$password string

Returns bool

phlat/src/User.php:158

can

$user->can(string $key): bool

Whether the user's role grants permission $key.

Parameters (1)
$key string

Returns bool

phlat/src/User.php:177
$user->childFields(): FieldValueSet

The fields a new account is made from - username, password and role - like Page::childFields(); asked of the user root.

Returns FieldValueSet

phlat/src/User.php:92
$user->delete(): void

Deletes this user's folder, emitting user.delete:before and dropping the index rows first so they don't outlive the files they point to.

phlat/src/User.php:149
$user->fields(): FieldValueSet

This user's declared profile fields (roles/_index.json's "fields") as resolved FieldValue instances - mirrors Page::fields().

Excludes password: it's a real, validated field, but already has dedicated admin UI (change form with confirm-match) rather than the generic per-field editor. "role" is never reachable here regardless - $role is a real typed property, which always shadows Record::__get().

Returns FieldValueSet

phlat/src/User.php:66

new

$user->new(string $name, array $data = []): User

Creates a new user under the users root: mints its uuid and writes a minimal _index.json, then applies $data via the normal save() path (role, an already-hashed password, ...).

Call on $app->userRoot(). Throws ConflictException if the username is taken.

Parameters (2)
$name string
$data array = []

Returns User

phlat/src/User.php:117
$user->objectType(): string

Always `user`.

Returns string

phlat/src/User.php:37
$user->passwordFields(bool $current = false): FieldValueSet

A password change: the new one twice, and the current one first when the user changes their own.

Parameters (1)
$current bool = false

Returns FieldValueSet

phlat/src/User.php:102
$user->registryFields(): array

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

Returns array

phlat/src/User.php:48
$user->role(): UserRole

The user's role, with its permissions.

Returns UserRole

phlat/src/User.php:171
$user->save(array $data = []): User

Persists user data like Record::save(), then emits user.update:after so the field/search index follows.

Parameters (1)
$data array = []

Returns User

phlat/src/User.php:141
$user->setPassword(string $password): void

Hashes and saves a new password.

Parameters (1)
$password string
phlat/src/User.php:165
$user->settingFields(): FieldValueSet

The account settings an admin sets - role and locked - as FieldValues, like Page::settingFields().

A locked user's role is read-only: unlock first to change it.

Returns FieldValueSet

phlat/src/User.php:78

From Record

$user->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
User::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
$user->data(): DataFile

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

Returns DataFile

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

Whether the record is on disk.

Returns bool

phlat/src/Data/Record.php:204

generateUuid

static
User::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
$user->index(): DataFile

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

Returns DataFile

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

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

Returns string

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

The record's folder, with a trailing slash.

Returns string

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

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

Returns string

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

The path stored in the registry for this object.

Returns string

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