Properties
A property is a logical piece of information. The property class capsulates everything that has to do with type, validation, semantic meaning and access rights. The data itself is retrieved and stored to a storage.
Reading a property value
A typical read process would be:
- The property is called to return a value
- The property checks if the current user is allowed to read the information
- The property fetches the value from the connected storage
- Optional it formats the output to a human readable form
The method to call to read a property's value is
$property->getValue():mixed;
Calling this method initiates the algorithm as above.
Writing a property value
A typical write/modify process would be:
- The property is called to write/modify a value
- The property checks if the current user is allowed to write or modify the information
- The property checks if the given value is valid for the type and semantic meaning of the property
- The property passes the value to the storage
The method to write a property's value is
$property->setValue(mixed $value)
Calling this method initiates the algorithm as above.
setStorage() and getStorage()
Due the fact that every property needs a storage to handle the values there are these methods that handle the storage
$property->setStorage(AbstractStorage $storage);
This method sets the active storage for this property. Normally this is done by the property manager.
$property->getStorage(): AbstractStorage;
Returns the current set storage for this property.
commit() and rollback()
As users should not interact with storages the call of
$property->commit();
and
$propery->rollback();
are passed to the storage. The meaning of this methods is to make a change to the value of a property persistent (commit) or revoke (rollback) it.
Name of property
Every property should have a name. The name does not have necessarily be unique.
$property->setName(string $name);
Sets the name of the property to the given name if it is a valid name. Inavlid names are:
- Names that start with an underscore _
- Reserved names like 'object', 'string' or 'id'
- Empty names ()
$property->name(string $name);
Is an alias to ->setName();
$property->forceName(string $name);
Skips the validation of the property name and should normally not be uses. It is uses internally for objects to define internal variables like _uuid.
$property->getName()
Returns the name of the property.
$property->isValidPropertyName(string $test);
Tests if the given name would pass the validation test.
Ownership of properties
A property can be owned by another property.This is useful in records and arrays but also for the InfoMarket. The statement
$propertyA->owner == $propertyB;
means that propertyA is a part of propertyB. Both can share the same storage or define a storage on their own.
$property->setOwner(AbstractProperty: $owner): AbstractProperty;
Sets the owner for this property. $owner must be a valid property.
$property->getOwner(): ?AbstractProperty
Returns the current set owner (or null if no owner is set) of this property.
$property->getPath(): string;
This method is used for InfoMarket to identifiy a InfoMarket item. It combines the name of each owning property. Example:
"grandfather.father.son"
==