コード例 #1
0
 /**
  * Override to add the "requestedResponseGroups" variable for every REST requests
  *
  * @see lib/ezc/MvcTools/src/interfaces/ezcMvcController::createResult()
  */
 public function createResult()
 {
     $debug = ezpRestDebug::getInstance();
     $debug->startTimer('GeneratingRestResult', 'RestController');
     if (!self::$isCacheCreated) {
         ezcCacheManager::createCache(self::CACHE_ID, $this->getCacheLocation(), 'ezpRestCacheStorageClusterObject', array('ttl' => $this->getActionTTL()));
         self::$isCacheCreated = true;
     }
     $cache = ezcCacheManager::getCache(self::CACHE_ID);
     $controllerCacheId = $this->generateCacheId();
     $isCacheEnabled = $this->isCacheEnabled();
     // Try to restore application cache.
     // If expired or not yet available, generate it and store it
     $cache->isCacheEnabled = $isCacheEnabled;
     if (($res = $cache->restore($controllerCacheId)) === false) {
         try {
             $debug->log('Generating cache', ezcLog::DEBUG);
             $debug->switchTimer('GeneratingCache', 'GeneratingRestResult');
             $res = parent::createResult();
             $resGroups = $this->getResponseGroups();
             if (!empty($resGroups)) {
                 $res->variables['requestedResponseGroups'] = $resGroups;
             }
             if ($res instanceof ezpRestMvcResult) {
                 $res->responseGroups = $resGroups;
             }
             if ($isCacheEnabled) {
                 $cache->store($controllerCacheId, $res);
             }
             $debug->stopTimer('GeneratingCache');
         } catch (Exception $e) {
             $debug->log('Exception caught, aborting cache generation', ezcLog::DEBUG);
             if ($isCacheEnabled) {
                 $cache->abortCacheGeneration();
             }
             throw $e;
         }
     }
     // Add debug infos to output if debug is enabled
     $debug->stopTimer('GeneratingRestResult');
     if (ezpRestDebug::isDebugEnabled()) {
         $res->variables['debug'] = $debug->getReport();
     }
     return $res;
 }
コード例 #2
0
ファイル: admin.php プロジェクト: jpic/ezc-framework-apps
 public function __get($name)
 {
     switch ($name) {
         case 'poDef':
             if (is_null($this->_poDef)) {
                 $pos = ezcPersistentSessionInstance::get();
                 $this->_poDef = $pos->definitionManager->fetchDefinition($this->poClass);
             }
             return $this->_poDef;
         case 'schema':
             if (is_null($this->_schema)) {
                 $this->_schema = ezcDbSchema::createFromDb(ezcDbInstance::get());
             }
             return $this->_schema;
     }
     return parent::__get($name);
 }