Example #1
0
 /**
  * Returns all tag sets.
  *
  * @param string|null $indexBy
  * @return array
  */
 public function getAllTagSets($indexBy = null)
 {
     if (!$this->_fetchedAllTagSets) {
         $tagSetRecords = TagSetRecord::model()->ordered()->findAll();
         $this->_tagSetsById = TagSetModel::populateModels($tagSetRecords, 'id');
         $this->_fetchedAllTagSets = true;
     }
     if ($indexBy == 'id') {
         return $this->_tagSetsById;
     } else {
         if (!$indexBy) {
             return array_values($this->_tagSetsById);
         } else {
             $tagSets = array();
             foreach ($this->_tagSetsById as $set) {
                 $tagSets[$set->{$indexBy}] = $set;
             }
             return $tagSets;
         }
     }
 }