Ejemplo n.º 1
0
 /**
  * Get list of developer tokens (access tokens)
  * 
  * @param   string  $rtrn     Data to return
  * @param   array   $filters  Filters to apply
  * @param   boolean $clear    Reset internal cache?
  * @return  mixed
  */
 public function accessTokens($rtrn = 'list', $filters = array(), $clear = false)
 {
     $tbl = new Tables\Api\AccessToken($this->_db);
     switch (strtolower($rtrn)) {
         case 'count':
             if (!isset($this->_cache['accesstokens.count'])) {
                 $this->_cache['accesstokens.count'] = (int) $tbl->count($filters);
             }
             return $this->_cache['accesstokens.count'];
             break;
         case 'list':
         case 'results':
         default:
             if (!$this->_cache['accesstokens.list'] instanceof ItemList) {
                 if ($results = $tbl->find($filters)) {
                     foreach ($results as $key => $result) {
                         $results[$key] = new Api\AccessToken($result);
                     }
                 }
                 $this->_cache['accesstokens.list'] = new ItemList($results);
             }
             return $this->_cache['accesstokens.list'];
             break;
     }
 }
Ejemplo n.º 2
0
 /**
  * Get a list of application access tokens
  * 
  * @param   array   $filters
  * @return  object  List of AccessToken objects
  */
 public function accessTokens($filters = array())
 {
     $tbl = new Tables\Api\AccessToken($this->_db);
     $filters = array_merge($filters, array('application_id' => $this->get('id')));
     if ($results = $tbl->find($filters)) {
         foreach ($results as $key => $result) {
             $results[$key] = new AccessToken($result);
         }
     }
     return new ItemList($results);
 }