Turba_Driver::_filterTags PHP Метод

_filterTags() защищенный Метод

Returns a Turba_List object containing $objects filtered by $tags.
protected _filterTags ( array $objects, array $tags, Array $sort_order = null ) : Turba_List
$objects array A hash of objects, as returned by self::_search.
$tags array An array of tags to filter by.
$sort_order Array The sort order to pass to Turba_List::sort.
Результат Turba_List The filtered Turba_List object.
    protected function _filterTags($objects, $tags, $sort_order = null)
    {
        global $injector;
        if (empty($tags)) {
            return $this->_toTurbaObjects($objects, $sort_order);
        }
        $tag_results = $injector->getInstance('Turba_Tagger')->search($tags, array('list' => $this->_name));
        // Short circuit if we know we have no tag hits.
        if (!$tag_results) {
            return new Turba_List();
        }
        $list = $this->_toTurbaObjects($objects, $sort_order);
        return $list->filter('__uid', $tag_results);
    }

Usage Example

Пример #1
0
 /**
  * Returns a Turba_List object containing $objects filtered by $tags.
  *
  * @param  array $objects  A hash of objects, as returned by self::_search.
  * @param  array $tags     An array of tags to filter by.
  *
  * @return Turba_List  The filtered Turba_List object.
  */
 protected function _filterTags($objects, $tags)
 {
     global $injector;
     // Overridden in this class so we can grab the internally stored
     // tag criteria.
     if (isset($this->searchCriteria['tags'])) {
         $tags = array_merge($injector->getInstance('Turba_Tagger')->split($this->searchCriteria['tags']), $tags);
     }
     return parent::_filterTags($objects, $tags);
 }