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 28 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()

__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 55 of file ObjectId.php.

Member Function Documentation

◆ NULL_OID()

static NULL_OID ( )
static

Get the NULL instance.

Returns
String

Definition at line 78 of file ObjectId.php.

◆ getPrefix()

getPrefix ( )

Get the prefix.

Returns
String

Definition at line 89 of file ObjectId.php.

◆ getType()

getType ( )

Get the type (including namespace)

Returns
String

Definition at line 97 of file ObjectId.php.

◆ getId()

getId ( )

Get the id.

Returns
Array

Definition at line 105 of file ObjectId.php.

◆ getFirstId()

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 113 of file ObjectId.php.

◆ isValid()

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 123 of file ObjectId.php.

◆ parse()

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 135 of file ObjectId.php.

◆ __toString()

__toString ( )

Get a string representation of the object id.

Returns
String

Definition at line 215 of file ObjectId.php.

◆ getDummyId()

static getDummyId ( )
static

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

Returns
String

Definition at line 230 of file ObjectId.php.

◆ isDummyId()

static isDummyId (   $id)
static

Check if a given id is a dummy id.

Parameters
$idThe id to check
Returns
Boolean

Definition at line 239 of file ObjectId.php.

◆ containsDummyIds()

containsDummyIds ( )

Check if this object id contains a dummy id.

Returns
Boolean

Definition at line 247 of file ObjectId.php.

◆ serialize()

serialize ( )

Definition at line 281 of file ObjectId.php.

◆ unserialize()

unserialize (   $data)

Definition at line 285 of file ObjectId.php.

◆ jsonSerialize()

jsonSerialize ( )

Definition at line 293 of file ObjectId.php.

Member Data Documentation

◆ DELIMITER

const DELIMITER = ':'

Definition at line 30 of file ObjectId.php.