Class Element
Extends the default storage field by a generalised model interface. Storage entries are uniquely identified by an immutable ID (the primary key).
Complex conditionals are no longer supported.
Usage
Implementations have to create an own subclass and must initialise the key that is suitable as a primary key in the storage back-end, the corresponding reference and the registry name of the storage driver instance to use.
Additionally, subclasses may add arbitrary methods as required by the model they represent.
use Core\Storage; class MyClass extends Storage\Field\Element { const KeyName = 'ItemID'; const ReferenceName = 'DataTable'; const StorageName = 'dbInstance'; // Uses Registry::instance()->dbInstance; }
The following code example creates a proxy element storage field to set a storage driver used by all instances derived from the proxy:
// Use proxy to retrieve a data entry. $model = MyClass::get($id); // Perform live update using shared storage driver instance. $model['some_key'] = 'new value';
- Core\Object implements Core\Chainable
- Core\Set implements Core\Accessor
- Core\Set\Mutable implements Core\Mutator
- Core\Field implements Core\Inquiry
- Core\Field\Mutable implements Core\Variator
- Core\Storage\Field
- Core\Storage\Field\Element
Direct known subclasses
Core\Storage\Field\Element\Pair
,
Core\Storage\Field\Element\Retained
Namespace: Core\Storage\Field
Package: Core\Storage
Since: 3.0
Requires: PHP 5.3
Version: 2.0
Located at Storage/Field/Element.inc.php
Methods summary
public
|
|
public static
|
|
public static
|
|
public
|
|
public static
|
|
public static
|
#
get( mixed $id )
Retrieves an entry from the storage back-end that is automatically wrapped in a model instance. |
public
|
|
public static
|
Methods inherited from Core\Storage\Field
cache()
,
getDataForUndefinedKey()
,
setCacheMode()
,
setDataForKey()
,
setDataForUndefinedKey()
Methods inherited from Core\Field\Mutable
offsetSet()
,
offsetUnset()
,
setDataForKeys()
,
setKeyMasquerade()
,
updateMasqueradedKeys()
Methods inherited from Core\Field
getDataForKey()
,
getDataForKeys()
,
issetDataForKey()
,
offsetExists()
,
offsetGet()
Methods inherited from Core\Set\Mutable
Methods inherited from Core\Object
__autocreateFactory()
,
__call()
,
__processParameters()
,
__toString()
,
attachMethod()
,
chain()
,
getValueForKey()
,
getValueForKeyPath()
,
getValueForUndefinedKey()
,
hash()
,
issetValueForKey()
,
setValueForKey()
,
setValueForKeyPath()
,
setValueForUndefinedKey()
,
uuid()
Constants summary
string |
KeyName
Name of primary key to uniquely identify the associated storage entry. |
#
'id'
|
string |
ReferenceName
Name of storage reference. |
#
'__notSet'
|
string |
StorageName
Name of storage driver instance in global registry. |
#
'db'
|
Constants inherited from Core\Storage\Field
Constants inherited from Core\Object
AnyParameterType
,
AutochainParameterType
,
AutocreateParameterType
,
BooleanParameterType
,
CharParameterType
,
EnumParameterType
,
IntegerParameterType
,
RealParameterType
,
StringParameterType
,
UserParameterType
Properties summary
Properties inherited from Core\Storage\Field
$_v_cacheMode
,
$_v_conditional
,
$_v_driver
,
$_v_reference
,
$_v_virtualData