Habari\Vocabulary::get_object_terms PHP Method

get_object_terms() public method

Gets the Term objects associated to that type of object with that id in this vocabulary For example, return all terms in this vocabulary that are associated with a particular post
public get_object_terms ( String $object_type, integer $id ) : Array
$object_type String the name of the object type
$id integer The id of the object for which you want the terms
return Array The Term objects requested
    public function get_object_terms($object_type, $id)
    {
        $query = Query::create('{terms}')->select('id', 'term', 'term_display', 'vocabulary_id', 'mptt_left', 'mptt_right');
        $query->join('JOIN {object_terms} ON {terms}.id = {object_terms}.term_id', array(), 'object_terms');
        $query->where()->in('{terms}.vocabulary_id', $this->id);
        $query->where()->in('{object_terms}.object_type_id', self::object_type_id($object_type));
        $query->where()->in('{object_terms}.object_id', $id);
        return new Terms($query->results('Term'));
    }