xplo.re Medusa Core Framework 3.1
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Aggregate
  • Element

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
Extended by Core\Set implements Core\Accessor
Extended by Core\Set\Mutable implements Core\Mutator
Extended by Core\Field implements Core\Inquiry
Extended by Core\Field\Mutable implements Core\Variator
Extended by Core\Storage\Field
Extended by Core\Storage\Field\Element

Direct known subclasses

Core\Storage\Field\Element\Pair, Core\Storage\Field\Element\Retained

Abstract
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
# __construct( array $row = null )

Parameters

$row

Associative array of data fetched from storage back-end. Automatically provided by queries with their RowClass parameter set to the class name of the model.

Since

3.0

Overrides

Core\Storage\Field::__construct
public static Core\Storage_Result
# add( array $entry )

Adds a new entry to the storage back-end.

Adds a new entry to the storage back-end.

Parameters

$entry
Associative key-value set of entry data.

Returns

Core\Storage_Result
Storage result of insert operation.

Since

3.0
public static Core\Storage
# driver( )

Retrieves the storage driver instance used by the class.

Retrieves the storage driver instance used by the class.

Returns

Core\Storage

Since

3.0
public Core\Storage_Result
# erase( )

Deletes the entry from the storage back-end that this instance represents.

Deletes the entry from the storage back-end that this instance represents.

Returns

Core\Storage_Result
Storage result of erase operation.

Since

3.0
public static Core\Storage_Result
# eraseID( mixed $id )

Deletes an entry from the storage back-end.

Deletes an entry from the storage back-end.

Parameters

$id
ID of entry to delete.

Returns

Core\Storage_Result
Storage result of erase operation.

Since

3.0
public static static
# get( mixed $id )

Retrieves an entry from the storage back-end that is automatically wrapped in a model instance.

Retrieves an entry from the storage back-end that is automatically wrapped in a model instance.

Parameters

$id
ID of entry to fetch.

Returns

static
New instance of model for retrieved storage entry or false on error.

Since

3.0
public Core\Storage_Result
# update( array $set )

Updates storage entry values.

Updates storage entry values.

Parameters

$set
Associative array of key-value pairs to update.

Returns

Core\Storage_Result
Storage result of update operation.

Remark

Changes to the element identifier Core\Storage\Field\Element::KeyName are silently discarded.

This method does not invoke Core\Storage\Field\Element::updateID(), derived classes that overwrite this method should implemented these changes for both Core\Storage\Field\Element::update() and Core\Storage\Field\Element::updateID() methods. The reason for this behaviour are inconsistency issues with data modified in the Core\Storage\Field\Element::updateID() method that are not reflected to the Core\Storage\Field\Element::update() method, or data modifications performed twice if the Core\Storage\Field\Element::update() and Core\Storage\Field\Element::updateID() methods both perform changes to the supplied data set prior to calling the parent implementation to correctly reflect changed data values in an instance.


See

Core\Storage\Field\Element::updateID()

Since

3.0
public static Core\Storage_Result
# updateID( mixed $id, array $set )

Updates storage entry values.

Updates storage entry values.

Parameters

$id
ID of storage entry to update.
$set
Associative array of key-value pairs to update.

Returns

Core\Storage_Result
Storage result of update operation.

See

Core\Storage\Field\Element::update()

Since

3.0

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

__set(), __unset()

Methods inherited from Core\Set

__get(), __isset()

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.

Name of primary key to uniquely identify the associated storage entry.

Remark

Derived classes should overwrite this value with the corresponding name of the primary key of the storage back-end in use, if it differs from the default value "id".


Since

3.0
# 'id'
string ReferenceName

Name of storage reference.

Name of storage reference.

Remark

Derived classes must overwrite this value with the name of the reference the element is stored under.


Since

3.0
# '__notSet'
string StorageName

Name of storage driver instance in global registry.

Name of storage driver instance in global registry.

Remark

Derived classes should overwrite this value to the name of a registered storage driver instance, if it differs from the default registry key "db".


Since

3.0
# 'db'

Constants inherited from Core\Storage\Field

FullCache, IncrementalCache, NoCache

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

Properties inherited from Core\Field\Mutable

$_v_masqueradedKeys

Properties inherited from Core\Field

$_v_data

Magic properties inherited from Core\Storage\Field

$cacheMode, $conditional, $driver, $reference, $virtualData

Magic properties inherited from Core\Field\Mutable

$masqueradedKeys

Magic properties inherited from Core\Field

$data

Magic properties inherited from Core\Object

$hash, $uuid

xplo.re Medusa Core Framework 3.1 API documentation generated by ApiGen