PHP Class Jarves\Objects

Show file Open project: jarves/jarves Class Usage Examples

Public Properties

Property Type Description
$instances array Array of instances of the object classes

Protected Properties

Property Type Description
$jarves Jarves

Public Methods

Method Description
__construct ( Jarves $jarves, Symfony\Component\DependencyInjection\ContainerInterface $container )
add ( string $objectKey, array $values, mixed $targetPk = null, string $position = 'first', boolean $targetObjectKey = null, array $options = [] ) : mixed Adds a item.
checkField ( string $objectKey, string $field ) : boolean Checks if a field in a object exists.
cleanup ( ) Clears the instances cache.
clear ( string $objectKey ) : boolean Removes all items.
get ( string $objectKey, mixed $pk, array $options = [] ) : array | null Returns the single row of a object.
getBranch ( $objectKey, mixed $pk = null, array $condition = null, integer $depth = 1, mixed $scope = null, array $options = [] ) : mixed
getBranchChildrenCount ( string $objectKey, mixed $pk = null, array $condition = null, mixed $scope = null, array $options = [] ) : array Counts the items of $objectKey filtered by $condition
getBundleName ( $objectKey ) : null | string Cuts of the object name of the object key.
getCount ( string $objectKey, array $condition = null, array $options = [] ) : array Counts the items of $objectKey filtered by $condition
getCountFromUrl ( $internalUrl ) : array Counts the items of $internalUrl
getCroppedObjectId ( string $url ) : string This just cut off object:/// and returns the primary key part as plain text.
getDefinition ( string $objectKey ) : Object | null Get object's definition.
getFromUrl ( $internalUrl ) : array Returns the object for the given url. Same arguments as in jarvesObjects::get() but given by a string.
getList ( string $objectKey, array $filter = null, array $options = [] ) : array | boolean Returns the list of objects.
getName ( string $objectKey ) : string | null Cuts of the namespace/module name of a object key.
getNamespace ( string $objectKey ) : string Returns the namespace of the bundle of the object key.
getObjectKey ( string $url ) : string Returns the object key (not id) from an object url.
getObjectPk ( string $objectKey, array $item ) : string Return only the primary keys of pItem as object.
getObjectUrlId ( string $objectKey, array $pk ) : string Returns the id of an object item for the usage in urls (internal url's) - urlencoded.
getParent ( string $objectKey, mixed $pk, array $options = null ) : mixed Returns the parent item per url. Only if the object is nested.
getParentFromUrl ( string $objectUrl ) : array Returns the parent item. Only if the object is nested.
getParentPk ( string $objectKey, mixed $pk ) : array Returns the parent pk.
getParentPkFromUrl ( string $objectUrl ) : array Returns the parent pk from a url.
getParents ( string $objectKey, mixed $pk, array $options = null ) : mixed Returns all parents, incl. the root object (if root is an object, it returns this object entry as well)
getParentsFromUrl ( string $objectUrl ) : mixed Returns all parents per url, incl. the root object (if root is an object, it returns this object entry as well)
getPrimaries ( $objectId ) : array Returns a hash of all primary fields.
getPrimaryList ( $objectId ) : array Return a list of all primary keys.
getPublicUrl ( string $objectKey, string $pk, array $pluginProperties = null ) : string Returns the public URL.
getRepository ( string $objectKey, array $options = null ) : ObjectCrud Returns the controller to be used to call each update and query at. This controller handles a bit more than the pure storageController. For example: ACL, automatic filtering (per language) and event dispatcher.
getRoot ( string $objectKey, mixed $scope, array $options = [] ) : array Returns a single root item. Only for nested objects.
getRoots ( string $objectKey, array $condition = null, array $options = [] ) : array Returns all roots. Only for nested objects.
getStorageController ( string $objectKey ) : AbstractStorage Returns the storage controller, which directly accesses the actual object.
getTable ( string $objectKey ) : string Returns the table name behind a object.
getUrl ( string $internalUrl ) : string | boolean Translates the internal url to the real path.
isNested ( string $objectKey ) : boolean Returns true of the object is nested.
move ( string $objectKey, array $pk, array $targetPk, string $position = 'first', string $targetObjectKey = null, array $options ) : mixed Moves a item to a new position.
moveFromUrl ( string $sourceObjectUrl, string $targetObjectUrl, string $position = 'first', array $options = null ) : mixed Moves a item around by a url.
normalizeObjectKey ( string $key ) : string
normalizePk ( string $objectKey, mixed $pk ) : array Returns always a array with primary key and value pairs from a single pk.
normalizePkString ( string $objectKey, string $pkString ) : array | null Parses a whole (can be multiple) primary key that is a represented as string and returns the first primary key.
parsePk ( string $objectKey, string $primaryKey ) : array Converts the primary key statement of a url to normalized structure.
parseUrl ( string $internalUrl ) : array Parse the internal object url scheme and return the information as array.
patch ( string $objectKey, mixed $pk, array $values, array $options = [] ) : boolean Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will not be overwritten.
remove ( string $objectKey, mixed $pk, array $options = [] ) : boolean Removes a object item.
removeFromUrl ( string $objectUrl, array $options = [] ) : boolean Removes a object item per url.
toUrl ( string $objectKey, mixed $primaryValues ) : string Converts given object key and the object item to the internal url.
update ( string $objectKey, mixed $pk, array $values, array $options = [] ) : boolean Updates a object entry. This means, all fields which are not defined will be saved as NULL.
updateFromUrl ( string $objectUrl, array $values ) : boolean Updates a item per url.

Method Details

__construct() public method

public __construct ( Jarves $jarves, Symfony\Component\DependencyInjection\ContainerInterface $container )
$jarves Jarves
$container Symfony\Component\DependencyInjection\ContainerInterface

add() public method

Adds a item.
public add ( string $objectKey, array $values, mixed $targetPk = null, string $position = 'first', boolean $targetObjectKey = null, array $options = [] ) : mixed
$objectKey string
$values array
$targetPk mixed Full PK as array or as primary key string (url).
$position string If nested set. `first` (child), `last` (last child), `prev` (sibling), `next` (sibling)
$targetObjectKey boolean If this object key differs from $objectKey then we'll use $pk as `scope`. Also it is then only possible to have position `first` and `last`.
$options array
return mixed

checkField() public method

Checks if a field in a object exists.
public checkField ( string $objectKey, string $field ) : boolean
$objectKey string
$field string
return boolean

cleanup() public method

Clears the instances cache.
public cleanup ( )

clear() public method

Removes all items.
public clear ( string $objectKey ) : boolean
$objectKey string
return boolean

get() public method

$options is a array which can contain following options. All options are optional. '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('field' => 'category', 'direction' => 'asc'), array('field' => 'title', 'direction' => 'asc') ) 'foreignKeys' Define which column should be resolved. If empty all columns will be resolved. Use a array or a comma separated list (like in SQL SELECT) 'permissionCheck' Defines whether we check against the ACL or not. true or false. default false
public get ( string $objectKey, mixed $pk, array $options = [] ) : array | null
$objectKey string
$pk mixed
$options array
return array | null

getBranch() public method

public getBranch ( $objectKey, mixed $pk = null, array $condition = null, integer $depth = 1, mixed $scope = null, array $options = [] ) : mixed
$objectKey
$pk mixed
$condition array
$depth integer
$scope mixed
$options array
return mixed

getBranchChildrenCount() public method

Counts the items of $objectKey filtered by $condition
public getBranchChildrenCount ( string $objectKey, mixed $pk = null, array $condition = null, mixed $scope = null, array $options = [] ) : array
$objectKey string
$pk mixed
$condition array
$scope mixed
$options array
return array

getBundleName() public method

jarves/node => JarvesBundle.
public getBundleName ( $objectKey ) : null | string
$objectKey
return null | string

getCount() public method

Counts the items of $objectKey filtered by $condition
public getCount ( string $objectKey, array $condition = null, array $options = [] ) : array
$objectKey string
$condition array
$options array
return array

getCountFromUrl() public method

Counts the items of $internalUrl
public getCountFromUrl ( $internalUrl ) : array
$internalUrl
return array

getCroppedObjectId() public method

This just cut off object:/// and returns the primary key part as plain text.
public getCroppedObjectId ( string $url ) : string
$url string
return string

getDefinition() public method

Get object's definition.
public getDefinition ( string $objectKey ) : Object | null
$objectKey string `Core\Language` or `Core.Language`.
return Jarves\Configuration\Object | null

getFromUrl() public method

Take a look at the jarvesObjects::parseUrl() method for more information.
public getFromUrl ( $internalUrl ) : array
$internalUrl
return array

getList() public method

$options is a array which can contain following options. All options are optional. '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
public getList ( string $objectKey, array $filter = null, array $options = [] ) : array | boolean
$objectKey string
$filter array
$options array
return array | boolean

getName() public method

jarves/node => Node.
public getName ( string $objectKey ) : string | null
$objectKey string
return string | null

getNamespace() public method

JarvesBundle/node => JarvesBundle. bundleWithNameSpace/myObject => Bundle\With\Namespace.
public getNamespace ( string $objectKey ) : string
$objectKey string
return string

getObjectKey() public method

Returns the object key (not id) from an object url.
public getObjectKey ( string $url ) : string
$url string
return string

getObjectPk() public method

Return only the primary keys of pItem as object.
public getObjectPk ( string $objectKey, array $item ) : string
$objectKey string
$item array
return string

getObjectUrlId() public method

Returns the id of an object item for the usage in urls (internal url's) - urlencoded.
public getObjectUrlId ( string $objectKey, array $pk ) : string
$objectKey string
$pk array
return string

getParent() public method

Returns the parent item per url. Only if the object is nested.
public getParent ( string $objectKey, mixed $pk, array $options = null ) : mixed
$objectKey string
$pk mixed
$options array
return mixed

getParentFromUrl() public method

Returns the parent item. Only if the object is nested.
public getParentFromUrl ( string $objectUrl ) : array
$objectUrl string
return array

getParentPk() public method

Returns the parent pk.
public getParentPk ( string $objectKey, mixed $pk ) : array
$objectKey string
$pk mixed
return array

getParentPkFromUrl() public method

Returns the parent pk from a url.
public getParentPkFromUrl ( string $objectUrl ) : array
$objectUrl string
return array

getParents() public method

Returns all parents, incl. the root object (if root is an object, it returns this object entry as well)
public getParents ( string $objectKey, mixed $pk, array $options = null ) : mixed
$objectKey string
$pk mixed
$options array
return mixed

getParentsFromUrl() public method

Returns all parents per url, incl. the root object (if root is an object, it returns this object entry as well)
public getParentsFromUrl ( string $objectUrl ) : mixed
$objectUrl string
return mixed

getPrimaries() public method

Returns array('' => , '' => , ...)
public getPrimaries ( $objectId ) : array
$objectId
return array

getPrimaryList() public method

Returns array('', '', ...);
public getPrimaryList ( $objectId ) : array
$objectId
return array

getPublicUrl() public method

Returns the public URL.
public getPublicUrl ( string $objectKey, string $pk, array $pluginProperties = null ) : string
$objectKey string
$pk string
$pluginProperties array
return string

getRepository() public method

It needs to extend ObjectCrud.
public getRepository ( string $objectKey, array $options = null ) : ObjectCrud
$objectKey string
$options array
return Jarves\Admin\ObjectCrud

getRoot() public method

Returns a single root item. Only for nested objects.
public getRoot ( string $objectKey, mixed $scope, array $options = [] ) : array
$objectKey string
$scope mixed
$options array
return array

getRoots() public method

Returns all roots. Only for nested objects.
public getRoots ( string $objectKey, array $condition = null, array $options = [] ) : array
$objectKey string
$condition array
$options array
return array

getStorageController() public method

Returns the storage controller, which directly accesses the actual object.
public getStorageController ( string $objectKey ) : AbstractStorage
$objectKey string
return Jarves\Storage\AbstractStorage

getTable() public method

Not all objects has a table. If the object is based on propel's orm, then it has one.
public getTable ( string $objectKey ) : string
$objectKey string
return string

getUrl() public method

Example: getUrl('file://45') => '/myImageFolder/Picture1.png' getUrl('news://4') => '/newspage/detail/my-news-title' getUrl('user://1') => '/userdetail/admini-strator'
public getUrl ( string $internalUrl ) : string | boolean
$internalUrl string
return string | boolean

isNested() public method

Returns true of the object is nested.
public isNested ( string $objectKey ) : boolean
$objectKey string
return boolean

move() public method

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

moveFromUrl() public method

Moves a item around by a url.
public moveFromUrl ( string $sourceObjectUrl, string $targetObjectUrl, string $position = 'first', array $options = null ) : mixed
$sourceObjectUrl string
$targetObjectUrl string
$position string
$options array
return mixed

normalizeObjectKey() public static method

public static normalizeObjectKey ( string $key ) : string
$key string
return string

normalizePk() public method

$pk can be - 24 - array(24) - array('id' => 24) result: array( 'id' => 24 );
public normalizePk ( string $objectKey, mixed $pk ) : array
$objectKey string
$pk mixed
return array A single primary key as array. Example: array('id' => 1).

normalizePkString() public method

Example: 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 normalizePkString ( string $objectKey, string $pkString ) : array | null
$objectKey string
$pkString string
return array | null Example array('id' => 4)

parsePk() public method

Generates a array for the usage of Core\Object:get() 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, id2 => "Bar")) 1-45, 2-45 => array(array(id => 1, pid = 45), array(id => 2, pid=>45))
public parsePk ( string $objectKey, string $primaryKey ) : array
$objectKey string
$primaryKey string
return array

parseUrl() public method

Pattern: object://[/][/][/?] Examples: 1. object://news/1 => returns the object news with primary value equal 1 2. object://news/id=1 => equal as 1. 3. object://news/1/2 => returns a list of the objects with primary value equal 1 or 2 4. object://news/id=1/id=2 => equal as 3. 5. object://object_with_multiple_primary/2,54 => returns the object with the first primary field equal 2 and second primary field equal 54 6. object://object_with_multiple_primary/2,54/34,55 => returns a list of the objects 7. object://object_with_multiple_primary/id=2,parent_id=54/id=34,parent_id=55 => equal as 6 if the first defined primary is 'id' and the second 'parent_id' 8. object://news/1?fields=title => equal as 1. but returns only the field title 9. object://news/1?fields=title,category_id => equal as 1. but returns only the field title and category_id 10. object://news?fields=title => returns all objects from type news 11. object://news?fields=title&limit=5 => returns first 5 objects from type news
public parseUrl ( string $internalUrl ) : array
$internalUrl string
return array [object_key, object_id/s, queryParams]

patch() public method

Patches a object entry. This means, only defined fields will be saved. Fields which are not defined will not be overwritten.
public patch ( string $objectKey, mixed $pk, array $values, array $options = [] ) : boolean
$objectKey string
$pk mixed
$values array
$options array
return boolean

remove() public method

Removes a object item.
public remove ( string $objectKey, mixed $pk, array $options = [] ) : boolean
$objectKey string
$pk mixed
$options array
return boolean

removeFromUrl() public method

Removes a object item per url.
public removeFromUrl ( string $objectUrl, array $options = [] ) : boolean
$objectUrl string
$options array
return boolean

toUrl() public method

Converts given object key and the object item to the internal url.
public toUrl ( string $objectKey, mixed $primaryValues ) : string
$objectKey string
$primaryValues mixed
return string

update() public method

Updates a object entry. This means, all fields which are not defined will be saved as NULL.
public update ( string $objectKey, mixed $pk, array $values, array $options = [] ) : boolean
$objectKey string
$pk mixed
$values array
$options array
return boolean

updateFromUrl() public method

Updates a item per url.
public updateFromUrl ( string $objectUrl, array $values ) : boolean
$objectUrl string
$values array
return boolean

Property Details

$instances public property

Array of instances of the object classes
public array $instances
return array

$jarves protected property

protected Jarves,jarves $jarves
return Jarves