wCMF  3.6
 All Classes Namespaces Files Functions Variables Groups Pages
PersistenceFacadeImpl Class Reference
+ Inheritance diagram for PersistenceFacadeImpl:

Public Member Functions

 __sleep ()
 
load ($oid, $buildDepth, $buildAttribs=null, $buildTypes=null)
 
create ($type, $buildDepth, $buildAttribs=null)
 
 save (&$object)
 
 delete ($oid, $recursive=true)
 
 getCreatedOIDs ($type)
 
 getLastCreatedOID ($type)
 
 getOIDs ($type, $criteria=null, $orderby=null, &$pagingInfo)
 
 getOIDsEx ($type, $where=null, $orderby=null, &$pagingInfo)
 
 getFirstOID ($type, $criteria=null, $orderby=null, &$pagingInfo)
 
 getFirstOIDEx ($type, $where=null, $orderby=null, &$pagingInfo)
 
 loadObjects ($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
 
loadFirstObject ($type, $buildDepth, $criteria=null, $orderby=null, &$pagingInfo, $buildAttribs=null, $buildTypes=null)
 
 startTransaction ()
 
 commitTransaction ()
 
 rollbackTransaction ()
 
getMapper ($type)
 
 getClassFile ($parser, $className)
 
 setMapper ($type, &$mapper)
 
 storeConnection ($initParams, &$connection)
 
 setReadOnly ($isReadOnly)
 
 enableLogging ($logStrategy)
 
 disableLogging ()
 
 isLogging ()
 
 setCaching ($isCaching)
 
 clearCache ()
 
 getCacheKey ($oid, $buildDepth, $buildAttribs, $buildTypes)
 
 getId ()
 
 valueChanged (&$object, $name, $type, $oldValue, $newValue)
 
 propertyChanged (&$object, $name, $oldValue, $newValue)
 
 stateChanged (&$object, $oldValue, $newValue)
 
- Public Member Functions inherited from ChangeListener
 getId ()
 
 valueChanged (&$object, $name, $type, $oldValue, $newValue)
 
 propertyChanged (&$object, $name, $oldValue, $newValue)
 
 stateChanged (&$object, $oldValue, $newValue)
 

Public Attributes

 $_mapperObjects = array()
 
 $_createdOIDs = array()
 
 $_dbConnections = array()
 
 $_cache = array()
 
 $_logging = false
 
 $_logStrategy = null
 
 $_isReadOnly = false
 
 $_isCaching = false
 
 $_inTransaction = false
 

Detailed Description

PersistenceFacadeImpl delegates persistence operations to the type-specific PersistenceMappers.

wCMF - wemove Content Management Framework Copyright (C) 2005-2014 wemove digital solutions GmbH

Licensed under the terms of any of the following licenses at your choice:

See the license.txt file distributed with this work for additional information.

Id:
class.PersistenceFacade.php 1079 2009-09-08 15:21:33Z iherwig
Note
The OID parameter must provide enough information to select the appropriate mapper. This may be achived by different strategies, e.g. coding the object type into the OID or having a global registry which maps OIDs to objects. wCMF uses the first method. The OID is a string in order to make it easier to serialize it in HTML forms. The following notation is used: type:id1:id2:... where type is the object type and id1, id2, .. are the values of the primary key columns (in case of simple keys only one). PersistenceFacade provides methods to handle OIDs (composeOID(), decomposeOID(), ...)
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 45 of file class.PersistenceFacadeImpl.php.

Member Function Documentation

PersistenceFacadeImpl::__sleep ( )

Prevent anything to be stored in the session

Definition at line 60 of file class.PersistenceFacadeImpl.php.

& PersistenceFacadeImpl::load (   $oid,
  $buildDepth,
  $buildAttribs = null,
  $buildTypes = null 
)

Load an object from the database.

Parameters
oidOID of the object to construct
buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
buildAttribsAn assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypesAn array listing the (sub-)types to include
Returns
A reference to the object, null if oid does not exist or a given condition prevents loading.

Definition at line 71 of file class.PersistenceFacadeImpl.php.

References BUILDDEPTH_INFINITE, BUILDDEPTH_SINGLE, PersistenceFacade\decomposeOID(), getCacheKey(), getMapper(), and WCMFException\throwEx().

+ Here is the call graph for this function:

& PersistenceFacadeImpl::create (   $type,
  $buildDepth,
  $buildAttribs = null 
)

Construct the template of an Object of a given type.

Parameters
typeThe type of object to build
buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build
buildAttribsAn assoziative array listing the attributes to create (default: null creates all attributes) (keys: the types, values: an array of attributes of the type to create) Use this to create only a subset of attributes
Returns
A reference to the object.

Definition at line 121 of file class.PersistenceFacadeImpl.php.

References BUILDDEPTH_INFINITE, BUILDDEPTH_REQUIRED, BUILDDEPTH_SINGLE, getMapper(), and WCMFException\throwEx().

+ Here is the call graph for this function:

PersistenceFacadeImpl::save ( $object)

Save an object to the database (inserted if it is new).

Parameters
objectA reference to the object to save
Returns
True/False depending on success of operation

Definition at line 143 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::delete (   $oid,
  $recursive = true 
)

Delete an object from the database (together with all of its children).

Parameters
oidThe object id of the object to delete
recursiveTrue/False whether to physically delete it's children too [default: true]
Returns
True/False depending on success of operation

Definition at line 160 of file class.PersistenceFacadeImpl.php.

References PersistenceFacade\decomposeOID(), and getMapper().

+ Here is the call graph for this function:

PersistenceFacadeImpl::getCreatedOIDs (   $type)

Get the object ids of newly created objects of a given type.

Parameters
typeThe type of the object
Returns
An array containing the objects ids

Definition at line 177 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::getLastCreatedOID (   $type)

Get the object id of the last created object of a given type.

Parameters
typeThe type of the object
Returns
The object id or null

Definition at line 188 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::getOIDs (   $type,
  $criteria = null,
  $orderby = null,
$pagingInfo 
)

Get the object ids of objects matching a given criteria. If a PagingInfo instance is passed it will be used and updated.

Parameters
typeThe type of the object
criteriaAn assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderbyAn array holding names of attributes to order by (maybe null). [default: null]
pagingInfoA reference PagingInfo instance (optional, default null does not work in PHP4).
Returns
An array containing the objects ids

Definition at line 203 of file class.PersistenceFacadeImpl.php.

References getMapper().

Referenced by getFirstOID().

+ Here is the call graph for this function:

PersistenceFacadeImpl::getOIDsEx (   $type,
  $where = null,
  $orderby = null,
$pagingInfo 
)
Deprecated:
use getOIDs() instead

Definition at line 214 of file class.PersistenceFacadeImpl.php.

References Log\error(), and WCMFException\getStackTrace().

+ Here is the call graph for this function:

PersistenceFacadeImpl::getFirstOID (   $type,
  $criteria = null,
  $orderby = null,
$pagingInfo 
)

Get the first object id of objects matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters
typeThe type of the object
criteriaAn assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderbyAn array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfoA reference PagingInfo instance (optional, default null does not work in PHP4).
Returns
An object id or null

Definition at line 227 of file class.PersistenceFacadeImpl.php.

References getOIDs().

+ Here is the call graph for this function:

PersistenceFacadeImpl::getFirstOIDEx (   $type,
  $where = null,
  $orderby = null,
$pagingInfo 
)
Deprecated:
use getFirstOID() instead

Definition at line 238 of file class.PersistenceFacadeImpl.php.

References Log\error(), and WCMFException\getStackTrace().

+ Here is the call graph for this function:

PersistenceFacadeImpl::loadObjects (   $type,
  $buildDepth,
  $criteria = null,
  $orderby = null,
$pagingInfo,
  $buildAttribs = null,
  $buildTypes = null 
)

Load the objects matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters
typeThe type of the object
buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
criteriaAn assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderbyAn array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfoA reference PagingInfo instance (optional, default null does not work in PHP4).
buildAttribsAn assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypesAn array listing the (sub-)types to include
Returns
An array containing the objects

Definition at line 256 of file class.PersistenceFacadeImpl.php.

References getMapper().

Referenced by loadFirstObject().

+ Here is the call graph for this function:

& PersistenceFacadeImpl::loadFirstObject (   $type,
  $buildDepth,
  $criteria = null,
  $orderby = null,
$pagingInfo,
  $buildAttribs = null,
  $buildTypes = null 
)

Load the first object matching a given condition. If a PagingInfo instance is passed it will be used and updated.

Parameters
typeThe type of the object
buildDepthOne of the BUILDDEPTH constants or a number describing the number of generations to build (except BUILDDEPTH_REQUIRED)
criteriaAn assoziative array holding name value pairs of attributes for selecting objects or a single string representing a (mapper specific) query condition (maybe null). [default: null]
orderbyAn array holding names of attributes to ORDER by (maybe null). [default: null]
pagingInfoA reference PagingInfo instance (optional, default null does not work in PHP4).
buildAttribsAn assoziative array listing the attributes to load (default: null loads all attributes) (keys: the types, values: an array of attributes of the type to load) Use this to load only a subset of attributes
buildTypesAn array listing the (sub-)types to include
Returns
A reference to the object or null

Definition at line 278 of file class.PersistenceFacadeImpl.php.

References loadObjects().

+ Here is the call graph for this function:

PersistenceFacadeImpl::startTransaction ( )

Start a transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the startTransaction() method of every used PersistenceMapper will be called - until commitTransaction() is called.

Note
There is only ONE transaction active at a time. Repeated calls of this method will leave the initial transaction active until commitTransaction() ore rollbackTransaction() is called.

Definition at line 293 of file class.PersistenceFacadeImpl.php.

References Log\debug(), and isLogging().

+ Here is the call graph for this function:

PersistenceFacadeImpl::commitTransaction ( )

Commit the started transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the commitTransaction() method of every used PersistenceMapper will be called.

Note
There is only ONE transaction active at a time. Repeated calls of this method will do nothing until a new transaction was started by calling startTransaction().

Definition at line 315 of file class.PersistenceFacadeImpl.php.

References Log\debug(), and isLogging().

+ Here is the call graph for this function:

PersistenceFacadeImpl::rollbackTransaction ( )

Rollback the started transaction. Used for PersistenceMapper classes that need to explicitely start and commit transactions. If this method is called, the rollbackTransaction() method of every used PersistenceMapper will be called.

Note
There is only ONE transaction active at a time. Repeated calls of this method will do nothing until a new transaction was started by calling startTransaction(). Rollbacks have to be supported by the data storage.

Definition at line 337 of file class.PersistenceFacadeImpl.php.

References Log\debug(), and isLogging().

+ Here is the call graph for this function:

& PersistenceFacadeImpl::getMapper (   $type)

Get the PersistenceMapper for a given type. If no mapper for this type is defined the mapper for type '*' will be returned

Parameters
typeThe type of the object to get the PersistenceMapper for
Returns
A reference to the PersistenceMapper, null on error

Definition at line 357 of file class.PersistenceFacadeImpl.php.

References getClassFile(), InifileParser\getInstance(), and WCMFException\throwEx().

Referenced by create(), delete(), getOIDs(), load(), and loadObjects().

+ Here is the call graph for this function:

PersistenceFacadeImpl::getClassFile (   $parser,
  $className 
)

Get the class file name from the classmapping section of ini file

Parameters
parserThe ini file parser
classNameThe class name
Returns
The class file name

Definition at line 460 of file class.PersistenceFacadeImpl.php.

References WCMFException\throwEx().

Referenced by getMapper().

+ Here is the call graph for this function:

PersistenceFacadeImpl::setMapper (   $type,
$mapper 
)

Explicitly set a PersistentMapper for a type

Parameters
typeThe type to set the mapper for
mapperA reference to the mapper

Definition at line 474 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::storeConnection (   $initParams,
$connection 
)

Store a connection for reuse

Parameters
initParamsThe initParams used to initialize the conenction
connectionA reference to the connection to save

Definition at line 483 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::setReadOnly (   $isReadOnly)

Set state to readonly. If set to true, PersistenceFacade will return only immutable objects and save/delete methods are disabled.

Parameters
isReadOnlyTrue/False whether objects should be readonly or not

Definition at line 496 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::enableLogging (   $logStrategy)

Enable logging using a given OutputStrategy to log insert/update/delete actions to a file.

Parameters
logStrategyThe OutputStrategy to use.

Definition at line 504 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::disableLogging ( )

Disable logging.

Definition at line 516 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::isLogging ( )

Check if the PersistenceMapper is logging.

Returns
True/False whether the PersistenceMapper is logging.

Definition at line 528 of file class.PersistenceFacadeImpl.php.

References $_logging.

Referenced by commitTransaction(), rollbackTransaction(), and startTransaction().

PersistenceFacadeImpl::setCaching (   $isCaching)

Set state to caching. If set to true, PersistenceFacade will cache all loaded objects and returns cached instances when calling the PersistenceFacade::load method.

Parameters
isCachingTrue/False whether objects should be chached or not

Definition at line 537 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::clearCache ( )

Clear the object cache

Definition at line 544 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::getCacheKey (   $oid,
  $buildDepth,
  $buildAttribs,
  $buildTypes 
)

Get cache key from the given parameters

Parameters
oidOID of the object
buildDepthOne of the BUILDDEPTH constants
buildAttribsAn assoziative array (
See Also
PersistenceFacade::load)
Parameters
buildTypesAn array (
See Also
PersistenceFacade::load)
Returns
The cache key string

Definition at line 556 of file class.PersistenceFacadeImpl.php.

Referenced by load().

PersistenceFacadeImpl::getId ( )

ChangeListener interface implementation

See Also
ChangeListener::getId()

Definition at line 572 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::valueChanged ( $object,
  $name,
  $type,
  $oldValue,
  $newValue 
)
PersistenceFacadeImpl::propertyChanged ( $object,
  $name,
  $oldValue,
  $newValue 
)
PersistenceFacadeImpl::stateChanged ( $object,
  $oldValue,
  $newValue 
)
See Also
ChangeListener::stateChanged()

Definition at line 587 of file class.PersistenceFacadeImpl.php.

References STATE_CLEAN, and STATE_NEW.

Member Data Documentation

PersistenceFacadeImpl::$_mapperObjects = array()

Definition at line 47 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_createdOIDs = array()

Definition at line 48 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_dbConnections = array()

Definition at line 49 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_cache = array()

Definition at line 50 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_logging = false

Definition at line 51 of file class.PersistenceFacadeImpl.php.

Referenced by isLogging().

PersistenceFacadeImpl::$_logStrategy = null

Definition at line 52 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_isReadOnly = false

Definition at line 53 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_isCaching = false

Definition at line 54 of file class.PersistenceFacadeImpl.php.

PersistenceFacadeImpl::$_inTransaction = false

Definition at line 55 of file class.PersistenceFacadeImpl.php.


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