Index

File

MMO\edms\entities · 1 symbol · generated 5 Oct 2026

class

File

File.php:25

A stored file: its name is the entity's label, its bytes are kept by the storage (FileManager::getStorage) under getStorageKey.

#[MMO\core\attributes\ArrayProperty(name: 'extension', getter: 'getExtension', schema: ['type' => 'string', 'description' => 'File extension'])] #[MMO\core\attributes\ArrayProperty(name: 'url', getter: 'getUrl', schema: […4 items])] class MMO\edms\entities\File extends MMO\core\entities\Entity implements MMO\oauth\interfaces\iWithScope, MMO\oauth\interfaces\iGuarded
Namespace
MMO\edms\entities
Extends
Entity
Implements
iWithScope, iGuarded
What describes the bytes (`size`, `mime`, `sha256`, `storageKey`) and the owner are set by edms only: a client changing them could make a file of another's bytes. Rights: [`Access`](https://mcp.mmoframework.fr/documentation/mmo.edms/php/helpers/Access.md#access) -- edms guards its files itself (iGuarded): mmo.oauth's AccessController asks for no `data.*` scope but in the generic data api.

Index

attachmentA file can be attached to another entity
dataThe custom fields of the file, as its labels define them (getPropertiesSchema)
descriptionFile description
labels
mimeThe media type, read from the bytes
ownerFile owner
sha256The SHA-256 of the bytes, in hexadecimal
size
storageKeyWhere the storage keeps the bytes: null for a file of edms 2, whose bytes are at {ownerId}/{id}
addLabel($label)
getClientId()
getExtension()
getFilePath($absolute)
getLabels()
getMime()
getOwner()
getPropertiesSchema()
getSha256()
getSize()
getStorageKey()
getUrl()
hasAllLabel($labels)
hasLabel($labels)
isOwnedBy($client)
isTrashed()
open()
ownScopeID($action)
removeLabel($label)
scopeID($action)The scope of the file: its id, and when it was made -- a repository can give the id of a file deleted to a new one (a JsonRepository does), which must not get the rights granted on the first
toResponse($headers, $name, $inline)A response sending the file
update()Read the size of the bytes again

Properties9

attachment

A file can be attached to another entity

#[MMO\core\attributes\ArrayProperty()] protected ?MMO\core\entities\Entity $attachment = null
Type
null | Entity

data

The custom fields of the file, as its labels define them (getPropertiesSchema)

#[MMO\core\attributes\ArrayProperty(schema: ['order' => 1000])] protected array $data = []
Type
array

description

File description

#[MMO\core\attributes\ArrayProperty()] protected string $description = ''
Type
string

labels

#[MMO\core\attributes\ArrayProperty()] protected array $labels = []
Type
array

mime

The media type, read from the bytes

#[MMO\core\attributes\ArrayProperty(setter: false, store: true)] protected ?string $mime = null
Type
null | string

owner

File owner

#[MMO\core\attributes\ArrayProperty(setter: false, store: true)] protected MMO\oauth\interfaces\iClient $owner
Type
iClient

sha256

The SHA-256 of the bytes, in hexadecimal

#[MMO\core\attributes\ArrayProperty(setter: false, store: true)] protected ?string $sha256 = null
Type
null | string

size

#[MMO\core\attributes\ArrayProperty(setter: false, store: true)] protected ?int $size = null
Type
null | int

storageKey

Where the storage keeps the bytes: null for a file of edms 2, whose bytes are at {ownerId}/{id}

#[MMO\core\attributes\ArrayProperty(setter: false, store: true, schema: ['hidden' => true])] protected ?string $storageKey = null
Type
null | string

Methods22

addLabel($label)

File.php:191
function addLabel(MMO\edms\entities\Label $label): bool
$labelLabel
returnsbool

getClientId()

File.php:95
function getClientId()
returnsthe id of the client that owns the file

getFilePath($absolute)

File.php:155
function getFilePath(bool $absolute = true): string
$absolute = truebool
returnsstringthe local file holding the bytes
throwsif the storage has none

getStorageKey()

File.php:123
function getStorageKey(): string
returnsstringwhere the storage keeps the bytes

hasAllLabel($labels)

File.php:215
function hasAllLabel(MMO\edms\entities\Label ...$labels): bool
...$labelsLabel
returnsbool

hasLabel($labels)

File.php:208
function hasLabel(MMO\edms\entities\Label ...$labels): bool
...$labelsLabel
returnsbool

isOwnedBy($client)

File.php:90
function isOwnedBy(MMO\oauth\interfaces\iClient $client): bool
$clientiClient
returnsbooltrue if $client owns the file

removeLabel($label)

File.php:198
function removeLabel(MMO\edms\entities\Label $label): bool
$labelLabel
returnsbool

scopeID($action)

File.php:106

The scope of the file: its id, and when it was made -- a repository can give the id of a file deleted to a new one (a JsonRepository does), which must not get the rights granted on the first

function scopeID(string $action = ''): string
$action = ''stringshow, edit, delete or share (Access)
returnsstringthe scope granting $action on this file
$user->allow($file->scopeID('show')); // edms.files.12-1727539200#show

toResponse($headers, $name, $inline)

File.php:168

A response sending the file

function toResponse(array $headers = [], ?string $name = null, bool $inline = false): MMO\edms\server\FileResponse
$headers = []array
$name = nullnull | stringthe name for the file when downloaded
$inline = falseboolif true, the browser shows the file rather than saving it (only when that is safe: FileResponse::IsInline)
returnsFileResponse

update()

File.php:141

Read the size of the bytes again

function update(): void
returnsvoid
Inherited members (111)
ConstantsDeclared byDescription
FLAG_CHANGEDiEntity
FLAG_CREATEDiEntity
FLAG_IGNORE_CHANGEiEntity
FLAG_IGNORE_ENTITYiEntity
FLAG_OPACIFYiEntity
FLAG_REMOVEDiEntity
PropertiesDeclared byDescription
ArrayPropertiesaEntity
changesaEntity
collectionEntity
ctimeEntity
errorsaEntity
flagsaEntity
idEntityidentifier in collection
labelEntityshort name
linksaEntity
mtimeEntity
SearchPropertiesaEntity
statusaEntity
titleEntitylong name
MethodsDeclared byDescription
addFlags($flags)aEntity
addLink($link)aEntityAppend a link.
archive()aEntityThis function is called to 'delete' the entity.
ArrayProperties()aEntityBuild (once per class, then cached in the static $ArrayProperties array) the list of every #[ArrayProperty] declared on this class, its parent classes, and the traits they use -- by reflection…
ArrayProperty($name)aEntity
CheckData($data, $errors)aEntityCheck data before it touches any entity: would an entity made from $data be valid?
clearChanges()aEntityReset change tracking: clears iEntity::FLAG_CHANGED and forgets every recorded change.
compareTo($value)aEntityCompare value
conversionError($key, $e)aEntityThe error recorded for a value that could not be set at all (usually: it could not be converted to its property's type), in the same form as a validation error.
Copy($entity, $properties)EntityBuild a new entity from $entity's own stored data (a duplicate, minus its id -- so saving it creates a genuinely new record -- in the same collection).
debugName()aEntity
get($path, $default)aEntityRead a (possibly nested) value by json-path, e.g.
getArrayProperty($key, $isRef, $store)aEntityRead a single array property's current value, through its getter (a direct property, a path alias, or a method).
getChanges($asArray, $store)aEntity
getCollection()Entity
getCtime()Entity
getErrors()aEntity
getFlags()aEntity
getId()Entity
getLabel()Entity
getLinks()aEntity
getLinksByRel($rels, $all)aEntityGet a list of Reference that have a specific relationship.
getMetadata()aEntity
getMtime()Entity
getRepository()Entity
getStatus()aEntity
getTitle()Entity
getView()aEntity
hasChanged($keys)aEntity
hasFlags($flags, $strict)aEntity
hasStatusChanged()aEntity
HiddenPath($path)aEntityThe hidden property (ArrayProperty::isHidden) a json-path goes through, known from the declared types alone: of this class, or of a class a property on the way may hold -- every class of its t…
ignore()EntityIgnore everything about this entity: discard its pending changes and flag it so it's skipped by future commits (aRepository::onCommit).
ignoreChanges($value)aEntityTemporarily suppress markChanged (used e.g.
isActive()aEntity
isArchive()aEntity
isArrayPropertySet($key, $store)EntitySame as aEntity::isArrayPropertySet, but 'ctime'/'mtime' are never reported as "set" (they're always present, so listing them adds no information), and neither is 'id' once the entity is alrea…
isChanged()aEntity
isCreated()aEntity
isDraft()aEntity
isEmpty()aEntity
isFinal()aEntity
isHiddenPath($path)aEntity
isIgnored()Entity
isOpacified()aEntity
isPending()aEntity
isRemoved()aEntity
isSimilar($value)Entity
isUnique()aEntityTells if an entity has enough information to be unique (at least one unique group has no null)
isValid()aEntity
isValidated()aEntity
ListClassReferences($onlyStorable)aEntityGet a list of all the classes and their properties that are using references to this class.
loadArray($data, $coerceOptions, $fromStore)EntitySame as aEntity::loadArray, but 'ctime'/'mtime' are never taken from $data: they belong to the server (set when the entity is created, bumped by markChanged), and a client sending back th…
loadFromStore($data)EntityRestore from stored data, setting 'ctime'/'mtime' directly (bypassing their normal setters -- see setCtime/setMtime, which are read-only via #[ArrayProperty]).
localName()Entity
loopReferences()EntityYield all the entities in the repository that have a reference on this one.
markChanged($keys)EntitySame as aEntity::markChanged, also bumping $mtime to now -- unless the change itself was to 'ctime'/'mtime' (avoiding infinite recursion via setMtime's own markChanged call).
mutate($type, $path, $value, $oldValue)aEntity\MMO\core\interfaces\iMutationObserver::mutate -- besides the normal tArrayProperties::mutate behavior, walks up $path to find the nearest enclosing aEntity (the mutation may have happened dee…
offsetExists($key)aEntity\ArrayAccess::offsetExists -- tells whether $key is a *declared* #[ArrayProperty], not whether it currently holds a non-default value (use isArrayPropertySet for that).
offsetGet($key)aEntity\ArrayAccess::offsetGet
offsetSet($key, $value)aEntity\ArrayAccess::offsetSet
offsetUnset($key)aEntity\ArrayAccess::offsetUnset -- equivalent to setting the property to null (its coerced value depends on the property's schema: e.g.
opacify($value)aEntityHide this entity's properties from toArray output (typically used to redact an entity the current viewer isn't allowed to see the details of, while still letting it be referenced by uid/metadata).
push($path, $value)aEntityAppend a value to a (possibly nested) list property by json-path.
reload()EntityReload entity from its repository
removeFlags($flags)aEntity
removeLink($link)aEntityRemove a link (by identity).
removePermanently($force)EntityRemove entity from database
replaceBy($replace, $mergeData)EntityReplace this entity by another one, trying to change all references to this entity to the new one.
Schema()aEntityThe JSON-Schema describing every #[ArrayProperty] of this class (built once and cached by ArrayProperties).
SearchProperty($name)aEntity
set($path, $value)aEntityWrite a (possibly nested) value by json-path, creating intermediate structure as needed.
setArrayProperty($key, $value, $coerceOptions, $ignoreReadonly)aEntitySame as tArrayProperties::setArrayProperty, plus: any coercion/validation failure is caught and recorded in getErrors (making the entity isValid()-false) instead of propagating as an…
setArrayPropertyOffset($key, $offset, $value, $coerceOptions)aEntitySame as tArrayProperties::setArrayPropertyOffset, plus: when pushing (offset === null) a new entity onto a list property, if an existing item is isSimilar to the new value, that item's of…
setCollection($collection, $removeFromCollection)EntityMove this entity to (or out of, if null) a collection.
setCtime($date, $force)EntitySet creation time
setId($id)EntitySet the id, re-registering this entity in its $collection under the new id (Collection's entities are keyed by id).
setLinks($links)aEntityReplace every link with $links.
setMtime($date, $force)EntitySet modification time
setStatus($status)aEntity
store()aEntityExport all array properties with store set to true.
test($filter)aEntity
toArray($fields, $flatten, $recursive)aEntitySame as tArrayProperties::toArray, except an isOpacified entity always exports only its 'uid' and 'metadata' (its other properties are hidden from output).
toLink($attributes)aEntity
traitMutate($type, $path, $value, $oldValue)aEntity\MMO\core\interfaces\iMutationObserver::mutate -- reacts to a mutation that happened deep inside one of this object's array properties (e.g.
traitSetArrayProperty($key, $value, $coerceOptions, $fromStore)aEntitySet array property
traitSetArrayPropertyOffset($key, $offset, $value, $coerceOptions)aEntitySet/push a value into an array property
traitToArray($fields, $flatten, $recursive)aEntityExport fields to an array.
uid()Entity
validate($errors)aEntityValidate this entity: its current values against its own tArrayProperties::Schema, plus every value that could not even be set -- one that could not be converted to its property's type never r…
View()aEntity
__construct($data, $collection)Entity