ElggEntity::annotate PHP Method

annotate() public method

Adds an annotation to an entity.
public annotate ( string $name, mixed $value, integer $access_id = ACCESS_PRIVATE, integer $owner_guid, string $vartype = "" ) : boolean | integer
$name string Annotation name
$value mixed Annotation value
$access_id integer Access ID
$owner_guid integer GUID of the annotation owner
$vartype string The type of annotation value
return boolean | integer Returns int if an annotation is saved
    public function annotate($name, $value, $access_id = ACCESS_PRIVATE, $owner_guid = 0, $vartype = "")
    {
        if ((int) $this->guid > 0) {
            return create_annotation($this->getGUID(), $name, $value, $vartype, $owner_guid, $access_id);
        } else {
            $this->temp_annotations[$name] = $value;
        }
        return true;
    }

Usage Example

Example #1
0
 public function testCanEdit()
 {
     $user = new \ElggUser();
     $user->save();
     $id = $this->entity->annotate('test', 'foo', ACCESS_LOGGED_IN, elgg_get_logged_in_user_guid());
     $a = elgg_get_annotation_from_id($id);
     $this->assertTrue($a->canEdit());
     $this->assertFalse($a->canEdit($user->guid));
     $id = $this->entity->annotate('test', 'foo2', ACCESS_LOGGED_IN, $user->guid);
     $a = elgg_get_annotation_from_id($id);
     $this->assertTrue($a->canEdit());
     $this->assertTrue($a->canEdit($user->guid));
     $user->delete();
 }
All Usage Examples Of ElggEntity::annotate