eZPublishCommunityProject  2013.5
eZ\Publish\Core\Persistence\InMemory\Backend Class Reference

The Storage Engine backend for in memory storage Reads input from js files in provided directory and fills in memory db store. More...

Public Member Functions

 __construct (array $data)
 Construct backend and assign data. More...
 
 beginTransaction ()
 Begin transaction. More...
 
 commit ()
 Commit transaction. More...
 
 count ($type, array $match=array(), array $joinInfo=array())
 Find count of objects of a given type matching a simple $match (empty array will match all) More...
 
 create ($type, array $data, $autoIncrement=true, $idColumn= 'id')
 Creates data in in memory store. More...
 
 delete ($type, $id, $idColumn= 'id')
 Deletes data in in memory store. More...
 
 deleteByMatch ($type, array $match)
 Deletes data in in memory store. More...
 
 find ($type, array $match=array(), array $joinInfo=array())
 Find data from in memory store for a specific type that matches $match (empty array will match all) More...
 
 load ($type, $id, $idColumn= 'id')
 Reads data from in memory store. More...
 
 resetData ()
 Reset data structure. More...
 
 rollback ()
 Rollback transaction. More...
 
 update ($type, $id, array $data, $union=true, $idColumn= 'id')
 Updates data in in memory store. More...
 
 updateByMatch ($type, array $match, array $data, $union=true, $idColumn= 'id')
 Updates data in in memory store by match. More...
 

Protected Member Functions

 getFieldTypeNamespace ($obj)
 
 rawFind ($type, array $match=array(), array $joinInfo=array())
 Find data from in memory store for a specific type that matches $match (empty array will match all) More...
 

Protected Attributes

 $data = array()
 
 $initialData = array()
 
 $transactionDataStack = array()
 

Private Member Functions

 getNextId ($type, $idColumn= 'id')
 Finds the max id number and that +1. More...
 
 joinToValue (ValueObject $item, array $joinInfo=array())
 Creates value objects on join properties. More...
 
 match (array $item, array $match)
 Checks if a $item (a raw VO item) matches $match recursively. More...
 

Private Attributes

 $tempFieldTypeMapping
 

Detailed Description

The Storage Engine backend for in memory storage Reads input from js files in provided directory and fills in memory db store.

The in memory db store and also json representation have a one to one mapping to defined value objects. But only their plain properties, associations are not handled and all data is stored in separate "buckets" similar to how it would be in a RDBMS servers.

Constructor & Destructor Documentation

eZ\Publish\Core\Persistence\InMemory\Backend::__construct ( array  $data)

Construct backend and assign data.

Use: new Backend( json_decode( file_get_contents( DIR . '/data.json' ), true ) );

Parameters
array$dataData where key is type like "Content" or "Content\\Type" which then have to map to Value objects in eZ*, data is an array of hash values with same structure as the corresponding value object. Foreign keys: In some cases value objects does not contain these as they are internal, so this needs to be handled in InMemory handlers by assigning keys like "_typeId" on Type hash values for instance. These will be stored and can be matched with find(), but will not be returned as part of VO so purely internal.

Member Function Documentation

eZ\Publish\Core\Persistence\InMemory\Backend::beginTransaction ( )

Begin transaction.

Begins an transaction, make sure you'll call commit or rollback when done, otherwise work will be lost.

eZ\Publish\Core\Persistence\InMemory\Backend::commit ( )

Commit transaction.

Commit transaction, or throw exceptions if no transactions has been started.

Exceptions
\RuntimeExceptionIf no transaction has been started
eZ\Publish\Core\Persistence\InMemory\Backend::count (   $type,
array  $match = array(),
array  $joinInfo = array() 
)

Find count of objects of a given type matching a simple $match (empty array will match all)

Note does not support joins, so only properties on $type is matched.

Parameters
string$type
array$matchA flat array with property => value to match against
array$joinInfoSee find()

rawFind()

Returns
int
eZ\Publish\Core\Persistence\InMemory\Backend::create (   $type,
array  $data,
  $autoIncrement = true,
  $idColumn = 'id' 
)

Creates data in in memory store.

Parameters
string$type
array$data
boolean$autoIncrement
string$idColumnBy default, id column is 'id', but this can be customized here (e.g. for 'contentId')
Returns
object
Exceptions
InvalidArgumentValueOn invalid $type
LogicExceptionIf $autoIncrement is false but $data does not include an id
LogicExceptionIf provided id already exists (and if defined, data contain same status property value)
eZ\Publish\Core\Persistence\InMemory\Backend::delete (   $type,
  $id,
  $idColumn = 'id' 
)

Deletes data in in memory store.

Parameters
string$type
int | string$id
Exceptions
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionIf data does not exist deleteByMatch()
eZ\Publish\Core\Persistence\InMemory\Backend::deleteByMatch (   $type,
array  $match 
)

Deletes data in in memory store.

Useful in cases where a specific state of an object should be updated, Type with version=0 for instance.

Parameters
string$type
array$matchA flat array with property => value to match against
Exceptions
InvalidArgumentValueOn invalid $type
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionIf no data to delete have been found

Referenced by eZ\Publish\Core\Persistence\InMemory\Backend\delete().

eZ\Publish\Core\Persistence\InMemory\Backend::find (   $type,
array  $match = array(),
array  $joinInfo = array() 
)

Find data from in memory store for a specific type that matches $match (empty array will match all)

Note does not support joins, so only properties on $type is matched.

Parameters
string$type
array$matchA multi level array with property => value to match against
array$joinInfoOptional info on how to join in other objects to become part of a aggregate where $type is root. Format: array( '<property>' => array( 'type' => '<foreign-type>', 'match' => array( '<foreign-key-property>' => '<key-property>' ) ), ['sub' => < $joininfo>="">] ) Example (joining Location when finding Content): array( 'locations' => array( 'type' => 'Content\Location', 'match' => array( 'contentId' => 'id' ) ) ) Value of 'sub' follows exactly same format as $joinInfo allowing recursive joining. rawFind()
Returns
object[]
eZ\Publish\Core\Persistence\InMemory\Backend::getFieldTypeNamespace (   $obj)
protected
Parameters
\eZ\Publish\SPI\Persistence\ValueObject$obj
Returns
string
eZ\Publish\Core\Persistence\InMemory\Backend::getNextId (   $type,
  $idColumn = 'id' 
)
private

Finds the max id number and that +1.

Makes sure no id conflicts occur if data for some reason contains gaps in id numbers.

Parameters
string$type
Returns
int

Referenced by eZ\Publish\Core\Persistence\InMemory\Backend\create().

eZ\Publish\Core\Persistence\InMemory\Backend::joinToValue ( ValueObject  $item,
array  $joinInfo = array() 
)
private

Creates value objects on join properties.

Parameters
\eZ\Publish\SPI\Persistence\ValueObject$item
array$joinInfoSee find()
Returns
ValueObject
eZ\Publish\Core\Persistence\InMemory\Backend::load (   $type,
  $id,
  $idColumn = 'id' 
)

Reads data from in memory store.

Parameters
string$type
int | string$id
string$idColumn
Returns
object
Exceptions
\eZ\Publish\Core\Base\Exceptions\InvalidArgumentValueOn invalid $type
\eZ\Publish\API\Repository\Exceptions\NotFoundExceptionIf data does not exist
LogicExceptionIf several items exists with same id
eZ\Publish\Core\Persistence\InMemory\Backend::match ( array  $item,
array  $match 
)
private

Checks if a $item (a raw VO item) matches $match recursively.

Parameters
array$item
array$match
Returns
boolean

Referenced by eZ\Publish\Core\Persistence\InMemory\Backend\deleteByMatch(), eZ\Publish\Core\Persistence\InMemory\Backend\rawFind(), and eZ\Publish\Core\Persistence\InMemory\Backend\updateByMatch().

eZ\Publish\Core\Persistence\InMemory\Backend::rawFind (   $type,
array  $match = array(),
array  $joinInfo = array() 
)
protected

Find data from in memory store for a specific type that matches $match (empty array will match all)

Note does not support joins, so only properties on $type is matched.

Parameters
string$type
array$matchA multi level array with property => value to match against
array$joinInfoSee find()
Returns
array[]
Exceptions
InvalidArgumentValueOn invalid $type
LogicExceptionWhen there is a collision between match rules in $joinInfo and $match

Referenced by eZ\Publish\Core\Persistence\InMemory\Backend\count(), and eZ\Publish\Core\Persistence\InMemory\Backend\find().

eZ\Publish\Core\Persistence\InMemory\Backend::resetData ( )

Reset data structure.

eZ\Publish\Core\Persistence\InMemory\Backend::rollback ( )

Rollback transaction.

Rollback transaction, or throw exceptions if no transactions has been started.

Exceptions
\RuntimeExceptionIf no transaction has been started
eZ\Publish\Core\Persistence\InMemory\Backend::update (   $type,
  $id,
array  $data,
  $union = true,
  $idColumn = 'id' 
)

Updates data in in memory store.

Parameters
string$type
int | string$id
array$data
boolean$unionSpecifies if data should be merged with existing data or not

updateByMatch()

Returns
boolean False if data does not exist and can not be updated
eZ\Publish\Core\Persistence\InMemory\Backend::updateByMatch (   $type,
array  $match,
array  $data,
  $union = true,
  $idColumn = 'id' 
)

Updates data in in memory store by match.

Useful in cases where a specific state of an object should be updated, Type with version=0 for instance.

Parameters
string$type
array$matchA flat array with property => value to match against
array$data
boolean$unionSpecifies if data should be merged with existing data or not
Exceptions
InvalidArgumentValueOn invalid $type
Returns
boolean False if data does not exist and can not be updated

Referenced by eZ\Publish\Core\Persistence\InMemory\Backend\update().

Member Data Documentation

eZ\Publish\Core\Persistence\InMemory\Backend::$initialData = array()
protected
eZ\Publish\Core\Persistence\InMemory\Backend::$tempFieldTypeMapping
private
Initial value:
= array(
'ezstring' => 'eZ\\Publish\\Core\\FieldType\\TextLine',
'ezinteger' => 'eZ\\Publish\\Core\\FieldType\\Integer',
'ezauthor' => 'eZ\\Publish\\Core\\FieldType\\Author',
'ezfloat' => 'eZ\\Publish\\Core\\FieldType\\Float',
'eztext' => 'eZ\\Publish\\Core\\FieldType\\TextBlock',
'ezboolean' => 'eZ\\Publish\\Core\\FieldType\\Checkbox',
'ezdatetime' => 'eZ\\Publish\\Core\\FieldType\\DateAndTime',
'ezkeyword' => 'eZ\\Publish\\Core\\FieldType\\Keyword',
'ezurl' => 'eZ\\Publish\\Core\\FieldType\\Url',
'ezcountry' => 'eZ\\Publish\\Core\\FieldType\\Country',
'ezbinaryfile' => 'eZ\\Publish\\Core\\FieldType\\BinaryFile',
'ezmedia' => 'eZ\\Publish\\Core\\FieldType\\Media',
'ezxmltext' => 'eZ\\Publish\\Core\\FieldType\\XmlText',
'ezobjectrelationlist' => 'eZ\\Publish\\Core\\FieldType\\RelationList',
'ezselection' => 'eZ\\Publish\\Core\\FieldType\\Selection',
'ezsrrating' => 'eZ\\Publish\\Core\\FieldType\\Rating',
'ezimage' => 'eZ\\Publish\\Core\\FieldType\\Image',
'ezobjectrelation' => 'eZ\\Publish\\Core\\FieldType\\Relation',
)
eZ\Publish\Core\Persistence\InMemory\Backend::$transactionDataStack = array()
protected

The documentation for this class was generated from the following file: