webCOMAND

cObject::get_parent()

Retrieves the parent object if this object is an embedded object. If it is NOT an embedded object, returns NULL.

Prototype

cObject get_parent(boolean $bTop = FALSE, boolean $bSelf = FALSE, boolean $instanceof = NULL)

Parameters

  • bTop - Whether to recurse to first object that is NOT an embedded object - i.e. the primary top-level object.
  • bSelf - Whether to return this object instance if it is not embedded in any other.
  • instanceof - Optional Content Type of parent.  If provided, multiple parents will be traversed until a parent of the specified type is found.

Return

Returns the parent object if this object is an embedded object.  Otherwise, returns NULL.

Example

$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact');
$parent = $contact->get_parent();
if($parent) {
    echo("Parent=$parent");
} else {
    echo("Object is not embedded.");
}