Perforce Chronicle 2012.2/486814
API Documentation
|
Extends P4Cms_Model class and provides in-memory storage of a record adapter and records default adapter. More...
Public Member Functions | |
__construct ($values=null, P4Cms_Record_Adapter $adapter=null) | |
Create a new model instance and (optionally) set the field values. | |
__sleep () | |
We need a custom sleep to exclude the adapter property. | |
clearAdapter () | |
Clear this record's storage adapter. | |
getAdapter () | |
Get the storage adapter used by this instance when accessing records. | |
hasAdapter () | |
Determine if a record adapter has been set. | |
setAdapter (P4Cms_Record_Adapter $adapter) | |
Set the storage adapter to use when accessing records. | |
Static Public Member Functions | |
static | clearDefaultAdapter () |
Clear the default record storage adapter. | |
static | getDefaultAdapter () |
Get the default storage adapter to use when accessing records. | |
static | hasDefaultAdapter () |
Determine if a default storage adapter has been set. | |
static | setDefaultAdapter (P4Cms_Record_Adapter $adapter) |
Set the default storage adapter to use when accessing records. | |
Protected Attributes | |
$_adapter = null | |
Static Protected Attributes | |
static | $_defaultAdapter = null |
Extends P4Cms_Model class and provides in-memory storage of a record adapter and records default adapter.
It only provides methods to retrieve, store, check-for and clear a record adapter and/or records default adapter; it doesn't provide any functionality for permanent storage of P4Cms_Model objects.
Constructor will set an adapter for the new instance if the caller provides one or there is a default record adapter available.
P4Cms_Record_Connected::__construct | ( | $ | values = null , |
P4Cms_Record_Adapter $ | adapter = null |
||
) |
Create a new model instance and (optionally) set the field values.
Extends parent to set the default adapter in the instance.
array | $values | array of key/values to load into the model. |
P4Cms_Record_Adapter | $adapter | optional - storage adapter to use. |
{ // if no adapter given, use the default adapter. if (!$adapter && static::hasDefaultAdapter()) { $adapter = static::getDefaultAdapter(); } // set the adapter if we have one. if ($adapter) { $this->setAdapter($adapter); } parent::__construct($values); }
P4Cms_Record_Connected::__sleep | ( | ) |
We need a custom sleep to exclude the adapter property.
Adapter connection objects cannot be serialized.
{ return array_diff( array_keys(get_object_vars($this)), array('_adapter') ); }
P4Cms_Record_Connected::clearAdapter | ( | ) |
Clear this record's storage adapter.
This is primarily for testing purposes.
{ $this->_adapter = null; }
static P4Cms_Record_Connected::clearDefaultAdapter | ( | ) | [static] |
Clear the default record storage adapter.
This is primarily for testing purposes.
{ static::$_defaultAdapter = null; }
P4Cms_Record_Connected::getAdapter | ( | ) |
Get the storage adapter used by this instance when accessing records.
P4Cms_Record_Exception | if the adapter was not set. |
{ if ($this->_adapter instanceof P4Cms_Record_Adapter) { return $this->_adapter; } throw new P4Cms_Record_Exception( "Cannot get storage adapter. Adapter has not been set." ); }
static P4Cms_Record_Connected::getDefaultAdapter | ( | ) | [static] |
Get the default storage adapter to use when accessing records.
{ if (static::$_defaultAdapter instanceof P4Cms_Record_Adapter) { return static::$_defaultAdapter; } throw new P4Cms_Record_Exception( "Cannot get default storage adapter. Adapter has not been set." ); }
P4Cms_Record_Connected::hasAdapter | ( | ) |
Determine if a record adapter has been set.
{ try { $this->getAdapter(); return true; } catch (P4Cms_Record_Exception $e) { return false; } }
static P4Cms_Record_Connected::hasDefaultAdapter | ( | ) | [static] |
Determine if a default storage adapter has been set.
{ try { static::getDefaultAdapter(); return true; } catch (P4Cms_Record_Exception $e) { return false; } }
P4Cms_Record_Connected::setAdapter | ( | P4Cms_Record_Adapter $ | adapter | ) |
Set the storage adapter to use when accessing records.
P4Cms_Record_Adapter | $adapter | the adapter to use for this instance. |
Reimplemented in P4Cms_Record, and P4Cms_User.
{
$this->_adapter = $adapter;
return $this;
}
static P4Cms_Record_Connected::setDefaultAdapter | ( | P4Cms_Record_Adapter $ | adapter | ) | [static] |
Set the default storage adapter to use when accessing records.
P4Cms_Record_Adapter | $adapter | the adapter to use by default. |
{ static::$_defaultAdapter = $adapter; }
P4Cms_Record_Connected::$_adapter = null [protected] |
P4Cms_Record_Connected::$_defaultAdapter = null [static, protected] |