Example #1
0
 /**
  * Get applications
  * 
  * @param   string  $rtrn     Data to return
  * @param   array   $filters  Filters to apply
  * @param   boolean $clear    Reset internal cache?
  * @return  mixed
  */
 public function applications($rtrn = 'list', $filters = array(), $clear = false)
 {
     $tbl = new Tables\Api\Application($this->_db);
     switch (strtolower($rtrn)) {
         case 'count':
             if (!isset($this->_cache['apps.count'])) {
                 $this->_cache['apps.count'] = (int) $tbl->count($filters);
             }
             return $this->_cache['apps.count'];
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['apps.list'] instanceof ItemList) {
                 if ($results = $tbl->find($filters)) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Api\Application($result);
                     }
                 }
                 $this->_cache['apps.list'] = new ItemList($results);
             }
             return $this->_cache['apps.list'];
             break;
     }
 }