ElggEntity::countAnnotations PHP Method

countAnnotations() public method

Count annotations.
public countAnnotations ( string $name = "" ) : integer
$name string The type of annotation.
return integer
    public function countAnnotations($name = "")
    {
        return $this->getAnnotationCalculation($name, 'count');
    }

Usage Example

Example #1
0
/**
 * Count how many people have liked an entity.
 *
 * @param  ElggEntity $entity
 *
 * @return int Number of likes
 */
function likes_count($entity)
{
    $type = $entity->getType();
    $params = array('entity' => $entity);
    $number = elgg_trigger_plugin_hook('likes:count', $type, $params, false);
    if ($number) {
        return $number;
    } else {
        return $entity->countAnnotations('likes');
    }
}
All Usage Examples Of ElggEntity::countAnnotations