Detailed Description

ObjectId is the unique identifier of an object.

Note
The ObjectId must provide enough information to select the appropriate mapper for the object. This may be achived by different strategies, e.g. coding the object type into the ObjectId or having a global registry which maps ObjectIds to objects. wCMF uses the first method. Serialized ObjectIds have the following notation: prefix: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). Serialization is done using the __toString method (using the ObjectId instance in a string context).
Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 27 of file ObjectId.php.

+ Inheritance diagram for ObjectId:

Public Member Functions

 __construct ($type, $id=[], $prefix=null)
 
 getPrefix ()
 
 getType ()
 
 getId ()
 
 getFirstId ()
 
 __toString ()
 
 containsDummyIds ()
 
 serialize ()
 
 unserialize ($data)
 
 jsonSerialize ()
 

Static Public Member Functions

static NULL_OID ()
 
static isValid ($oid)
 
static parse ($oid)
 
static getDummyId ()
 
static isDummyId ($id)
 

Public Attributes

const DELIMITER = ':'
 

Constructor & Destructor Documentation

__construct (   $type,
  $id = [],
  $prefix = null 
)

Constructor.

Parameters
$typeThe type name of the object (either fully qualified or simple, if not ambiguous)
$idEither a single value or an array of values (for compound primary keys) identifying the object between others of the same type. If not given, a dummy id will be assigned (optional, default: empty array)
$prefixA prefix for identifying a set of objects belonging to one storage in a distributed environment (optional, default: null)
Note
If id is an array, the order of the values must match the order of the primary key names given by PersistenceMapper::getPkNames().

Definition at line 54 of file ObjectId.php.

Member Function Documentation

static NULL_OID ( )
static

Get the NULL instance.

Returns
String

Definition at line 77 of file ObjectId.php.

getPrefix ( )

Get the prefix.

Returns
String

Definition at line 88 of file ObjectId.php.

getType ( )

Get the type (including namespace)

Returns
String

Definition at line 96 of file ObjectId.php.

getId ( )

Get the id.

Returns
Array

Definition at line 104 of file ObjectId.php.

getFirstId ( )

Get the first id.

This is especially useful, when you know that this id only consists of one id.

Returns
String

Definition at line 112 of file ObjectId.php.

static isValid (   $oid)
static

Check if a serialized ObjectId has a valid syntax, the type is known and if the number of primary keys match the type.

Parameters
$oidThe serialized ObjectId.
Returns
Boolean

Definition at line 122 of file ObjectId.php.

static parse (   $oid)
static

Parse a serialized object id string into an ObjectId instance.

Parameters
$oidThe string
Returns
ObjectId or null, if the id cannot be parsed

Definition at line 134 of file ObjectId.php.

__toString ( )

Get a string representation of the object id.

Returns
String

Definition at line 210 of file ObjectId.php.

static getDummyId ( )
static

Get a dummy id ("wcmf" + unique 32 character string).

Returns
String

Definition at line 225 of file ObjectId.php.

static isDummyId (   $id)
static

Check if a given id is a dummy id.

Parameters
$idThe id to check
Returns
Boolean

Definition at line 234 of file ObjectId.php.

containsDummyIds ( )

Check if this object id contains a dummy id.

Returns
Boolean

Definition at line 242 of file ObjectId.php.

serialize ( )

Definition at line 276 of file ObjectId.php.

unserialize (   $data)

Definition at line 280 of file ObjectId.php.

jsonSerialize ( )

Definition at line 288 of file ObjectId.php.

Member Data Documentation

const DELIMITER = ':'

Definition at line 29 of file ObjectId.php.