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).
Definition at line 28 of file ObjectId.php.
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
-
$type The type name of the object (either fully qualified or simple, if not ambiguous) $id Either 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) $prefix A 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 |
◆ getPrefix()
getPrefix | ( | ) |
◆ getType()
getType | ( | ) |
◆ getId()
getId | ( | ) |
◆ 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 |
Check if a serialized ObjectId has a valid syntax, the type is known and if the number of primary keys match the type.
- Parameters
-
$oid The serialized ObjectId.
- Returns
- Boolean
Definition at line 123 of file ObjectId.php.
◆ parse()
|
static |
Parse a serialized object id string into an ObjectId instance.
- Parameters
-
$oid The 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 |
Get a dummy id ("wcmf" + unique 32 character string).
- Returns
- String
Definition at line 230 of file ObjectId.php.
◆ isDummyId()
|
static |
Check if a given id is a dummy id.
- Parameters
-
$id The 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.