PHP Class Jarves\Storage\AbstractStorage

Please do not handle 'permissionCheck' in $options. This is handled in \Jarves\Object. You will get in getList() a complex $pCondition object instead (if there are any ACL items) $pk is an array with following format array( '' => '' => ) example array( 'id' => 1234 )
Exibir arquivo Open project: jarves/jarves Class Usage Examples

Public Properties

Property Type Description
$definition Jarves\Configuration\Object Cached the object definition.
$objectKey string The current object key.
$primaryKeys array Only keys.

Public Methods

Method Description
add ( array $values, array $targetPk = null, string $position = 'first', integer $scope = null ) : array
clear ( ) : boolean Do whatever is needed, to clear all items out of this object scope.
clearCache ( ) Clears the internal cache. This is called when the defined object has been changed.
configure ( string $objectKey, Object $definition ) Important call directly after the creation of this class.
drop ( ) : boolean Removes anything that is required to hold the data. E.g. SQL Tables, Drop Sequences, etc.
export ( Condition $condition = null ) : array Exports all data as array
getBranch ( array $pk = null, Condition $condition = null, integer $depth = 1, mixed $scope = null, array $options = null ) : array Returns a branch if the object is a nested set.
getBranchChildrenCount ( null $pk = null, Condition $condition = null, null $scope = null ) : array
getCount ( Condition $condition = null ) : integer
getDefinition ( )
getField ( string $fieldKey ) : array Returns a field definition.
getItem ( array $pk, array $options = null ) : array $pOptions is a array which can contain following options. All options are optional.
getItems ( array $filter = null, Condition $condition = null, array $options = null ) $pOptions is a array which can contain following options. All options are optional.
getNestedSubCondition ( Condition $condition ) : Condition Builds a condition for the sub-items check in \Jarves\Permissions::getListingCondition() for nested set objects.
getObjectKey ( ) : string Returns the object key.
getParent ( array $pk, array $options = null ) : mixed Returns the parent if exists otherwise false.
getParentId ( array $pk ) : array Returns parent's pk, if exists, otherwise null.
getParents ( array $pk ) : array Returns all parents.
getPrimaryKeys ( ) : array Returns the primary keys as array.
getRoots ( Condition $condition = null, array $options = null )
move ( array $pk, array $targetPk, string $position = 'first', $targetObjectKey = null ) : boolean Moves a item to a new position.
normalizePrimaryKey ( mixed $pk ) : array Normalizes a primary key, that is normally used inside PHP classes, since developers are lazy and we need to convert the lazy primary key to the full definition.
patch ( array $pk, array $values ) Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will not be overwritten.
primaryStringToArray ( string $pk ) : array Converts given primary values from type string into proper normalized array definition.
remove ( array $pk )
search ( string $query, Condition $condition = null, integer $max = 20 ) : array | null Executes a search to this object, filter by $query and optional by a more complet condition $condition.
setDefinition ( $definition )
setPrimaryKeys ( $pks )
update ( array $pk, array $values ) Updates an object entry. This means, all fields which are not defined will be saved as NULL.

Method Details

add() abstract public method

abstract public add ( array $values, array $targetPk = null, string $position = 'first', integer $scope = null ) : array
$values array
$targetPk array If nested set
$position string `first` (child), `last` (last child), `prev` (sibling), `next` (sibling)
$scope integer If nested set with scope
return array inserted/new primary key/s always as a array.

clear() abstract public method

Do whatever is needed, to clear all items out of this object scope.
abstract public clear ( ) : boolean
return boolean

clearCache() public method

Clears the internal cache. This is called when the defined object has been changed.
public clearCache ( )

configure() public method

Important call directly after the creation of this class.
public configure ( string $objectKey, Object $definition )
$objectKey string
$definition Object

drop() public method

Removes anything that is required to hold the data. E.g. SQL Tables, Drop Sequences, etc.
public drop ( ) : boolean
return boolean

export() public method

Exports all data as array
public export ( Condition $condition = null ) : array
$condition Jarves\Configuration\Condition
return array

getBranch() public method

Result should be: array( array(, '_children' => array(), '_childrenCount' => ), array(, '_children' => array(), '_childrenCount' => ), ... )
public getBranch ( array $pk = null, Condition $condition = null, integer $depth = 1, mixed $scope = null, array $options = null ) : array
$pk array
$condition Jarves\Configuration\Condition
$depth integer Started with one. One means, only the first level, no children at all.
$scope mixed
$options array
return array

getBranchChildrenCount() public method

public getBranchChildrenCount ( null $pk = null, Condition $condition = null, null $scope = null ) : array
$pk null
$condition Jarves\Configuration\Condition
$scope null
return array

getCount() abstract public method

abstract public getCount ( Condition $condition = null ) : integer
$condition Jarves\Configuration\Condition
return integer

getDefinition() public method

public getDefinition ( )

getField() public method

Returns a field definition.
public getField ( string $fieldKey ) : array
$fieldKey string
return array

getItem() abstract public method

'fields' Limit the columns selection. Use a array or a comma separated list (like in SQL SELECT) If empty all columns will be selected. 'permissionCheck' Defines whether we check against the ACL or not. true or false. default false
abstract public getItem ( array $pk, array $options = null ) : array
$pk array
$options array
return array

getItems() abstract public method

'fields' Limit the columns selection. Use a array or a comma separated list (like in SQL SELECT) If empty all columns will be selected. 'offset' Offset of the result set (in SQL OFFSET) 'limit' Limits the result set (in SQL LIMIT) 'order' The column to order. Example: array( array('category' => 'asc'), array(title' => 'asc') ) 'permissionCheck' Defines whether we check against the ACL or not. true or false. default false
abstract public getItems ( array $filter = null, Condition $condition = null, array $options = null )
$filter array simple filter
$condition Jarves\Configuration\Condition complex filter condition
$options array

getNestedSubCondition() public method

Builds a condition for the sub-items check in \Jarves\Permissions::getListingCondition() for nested set objects.
public getNestedSubCondition ( Condition $condition ) : Condition
$condition Jarves\Configuration\Condition
return Jarves\Configuration\Condition

getObjectKey() public method

Returns the object key.
public getObjectKey ( ) : string
return string

getParent() public method

Returns the parent if exists otherwise false.
public getParent ( array $pk, array $options = null ) : mixed
$pk array
$options array
return mixed

getParentId() public method

Returns parent's pk, if exists, otherwise null.
public getParentId ( array $pk ) : array
$pk array
return array

getParents() public method

Root object first. Each entry has to have also '_objectKey' as value.
public getParents ( array $pk ) : array
$pk array
return array

getPrimaryKeys() public method

Returns the primary keys as array.
public getPrimaryKeys ( ) : array
return array [key1, key2, key3]

getRoots() public method

public getRoots ( Condition $condition = null, array $options = null )
$condition Jarves\Configuration\Condition
$options array

move() public method

Moves a item to a new position.
public move ( array $pk, array $targetPk, string $position = 'first', $targetObjectKey = null ) : boolean
$pk array Full PK as array
$targetPk array Full PK as array
$position string `first` (child), `last` (last child), `prev` (sibling), `next` (sibling)
$targetObjectKey
return boolean

normalizePrimaryKey() public method

Possible input: array('bla'), 'peter', 123, Output array('id' => 'bla'), array('id' => 'peter'), array('id' => 123) if the only primary key is named id.
public normalizePrimaryKey ( mixed $pk ) : array
$pk mixed
return array A single primary key as array. Example: array('id' => 1).

patch() abstract public method

Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will not be overwritten.
abstract public patch ( array $pk, array $values )
$pk array
$values array

primaryStringToArray() public method

This builds the array for the $pk for all of these methods inside this class. The primaryKey comes primarily from the REST API. admin/object/news/1 admin/objects?uri=news/1/2 where admin/object/news/ admin/objects?uri=news/ is this ID. 1/2/3 => array( array(id =>1),array(id =>2),array(id =>3) ) 1 => array(array(id => 1)) idFooBar => array( id => "idFooBar") idFoo/Bar => array(array(id => idFoo), array(id2 => "Bar")) 1,45/2,45 => array(array(id => 1, pid = 45), array(id => 2, pid=>45))
public primaryStringToArray ( string $pk ) : array
$pk string
return array Always a array with primary keys as arrays too. So $return[0] is the first primary key array. Example array(array('id' => 4))

remove() abstract public method

abstract public remove ( array $pk )
$pk array

setDefinition() public method

public setDefinition ( $definition )

setPrimaryKeys() public method

public setPrimaryKeys ( $pks )

update() abstract public method

Updates an object entry. This means, all fields which are not defined will be saved as NULL.
abstract public update ( array $pk, array $values )
$pk array
$values array

Property Details

$definition public_oe property

Cached the object definition.
public Object,Jarves\Configuration $definition
return Jarves\Configuration\Object

$objectKey public_oe property

The current object key.
public string $objectKey
return string

$primaryKeys public_oe property

Only keys.
public array $primaryKeys
return array