webCOMAND

cObject::get_attributes()

Returns attributes associated with this object; that is, a collection of objects that reference this object via forward references.

Prototype

collection get_attributes(mixed $content_type = NULL, mixed $field = NULL, boolean $polymorphic = TRUE)

Parameters

  • content_type - Optional content type of the objects to return.  It may be provided as an Identifier, ID, OID, DOID, UUID or Content Type.  If not specified, objects of any content type that reference this object will be included in the collection.
  • field - Optional field that refers to the content type's forward reference field.  It may be provided as an Identifier, ID, OID, DOID, UUID or Content Type Field.  If not specified, objects that reference this object via any forward reference field will be included in the collection.
  • polymorphic - If TRUE (default), attributes that are sub-types of the given content type will be returned, otherwise only objects of the given content type will be returned (strict).

Return

Returns a collection of objects that reference this object via forward references that meet the criteria provided in the parameters.

Example

$repo = \comand::repo();
$contact = $repo->get_first('FROM Contact');

// get all contacts this contact is an Emergency Contact for
$attributes = $contact->get_attributes('Contact', 'EmergencyContact');
foreach($attributes as $attribute) {
    echo("$contact is an emergency contact for $attribute\n");
}