Elgg\Database\Annotations::getEntities PHP Method

getEntities() public method

Returns entities based upon annotations. Also accepts all options available to elgg_get_entities() and elgg_get_entities_from_metadata().
See also: elgg_get_entities
See also: elgg_get_entities_from_metadata
public getEntities ( array $options = [] ) : mixed
$options array Array in format: annotation_names => null|ARR annotations names annotation_values => null|ARR annotations values annotation_name_value_pairs => null|ARR (name = 'name', value => 'value', 'operator' => '=', 'case_sensitive' => true) entries. Currently if multiple values are sent via an array (value => array('value1', 'value2') the pair's operator will be forced to "IN". annotation_name_value_pairs_operator => null|STR The operator to use for combining (name = value) OPERATOR (name = value); default AND annotation_case_sensitive => BOOL Overall Case sensitive order_by_annotation => null|ARR (array('name' => 'annotation_text1', 'direction' => ASC|DESC, 'as' => text|integer), Also supports array('name' => 'annotation_text1') annotation_owner_guids => null|ARR guids for annotaiton owners
return mixed If count, int. If not count, array. false on errors.
    function getEntities(array $options = array())
    {
        $defaults = array('annotation_names' => ELGG_ENTITIES_ANY_VALUE, 'annotation_values' => ELGG_ENTITIES_ANY_VALUE, 'annotation_name_value_pairs' => ELGG_ENTITIES_ANY_VALUE, 'annotation_name_value_pairs_operator' => 'AND', 'annotation_case_sensitive' => true, 'order_by_annotation' => array(), 'annotation_created_time_lower' => ELGG_ENTITIES_ANY_VALUE, 'annotation_created_time_upper' => ELGG_ENTITIES_ANY_VALUE, 'annotation_owner_guids' => ELGG_ENTITIES_ANY_VALUE);
        $options = array_merge($defaults, $options);
        $singulars = array('annotation_name', 'annotation_value', 'annotation_name_value_pair', 'annotation_owner_guid');
        $options = _elgg_normalize_plural_options_array($options, $singulars);
        $options = _elgg_entities_get_metastrings_options('annotation', $options);
        if (!$options) {
            return false;
        }
        $time_wheres = _elgg_get_entity_time_where_sql('n_table', $options['annotation_created_time_upper'], $options['annotation_created_time_lower']);
        if ($time_wheres) {
            $options['wheres'][] = $time_wheres;
        }
        return elgg_get_entities_from_metadata($options);
    }