示例#1
0
 /**
  * {@InheritDoc}
  */
 public function init()
 {
     //  Admins only!
     if (!Session::isSystemAdmin()) {
         throw new \CHttpException(HttpResponse::Forbidden, 'Access Denied.');
     }
     parent::init();
     //	We want merged update/create...
     $this->setSingleViewMode(true);
     $this->layout = 'mobile';
     $this->defaultAction = 'index';
     //	Everything is auth-required
     $this->addUserActions(static::Authenticated, array('cache', 'index', 'update', 'error', 'create'));
     //  Set the command map
     static::$_cacheCommandMap = array('flush' => function () {
         return Platform::storeDeleteAll();
     });
 }
示例#2
0
 /**
  * @param string $cache Which cache to flush
  *
  * @return bool
  * @throws DreamFactory\Platform\Exceptions\BadRequestException
  */
 public function actionFlush($cache)
 {
     $this->layout = false;
     switch (strtolower($cache)) {
         case 'platform':
             Platform::storeDeleteAll();
             Pii::flushConfig();
             break;
         case 'swagger':
             SwaggerManager::clearCache();
             break;
         default:
             throw new BadRequestException();
     }
     echo json_encode(array('success' => true, 'cache' => $cache));
     return Pii::end();
 }