示例#1
0
 /**
  * The RebuildFrameworkCache event handler deletes the events and routes
  * cache and executes the activation method on all modules.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\CliRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, CliRequest $request, Response $response)
 {
     $framework->getRuntimeManager()->clearCache(false);
     $framework->getRouteManager()->clearCache(false);
     $framework->getModuleManager()->reactivateModules();
     $response->setOutputPart('cacheCleared', 'The cache was successfully cleared and rebuilt!');
 }
 /**
  * If the request is a WebRequest, the user will be redirected to the login page.
  * Otherwise the event handler will display an information message.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\RequestAbstract $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, RequestAbstract $request, Response $response)
 {
     if ($request instanceof WebRequest) {
         $response->redirectTo('/login/', 307, true);
         return;
     }
     $response->setOutputPart('sessionNeeded', 'You need a session to execute this command!');
 }
示例#3
0
 /**
  * This event handler lists all activated modules with the description
  * of each module.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\CliRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, CliRequest $request, Response $response)
 {
     $output = 'Activated modules:' . PHP_EOL;
     $output .= '==================' . PHP_EOL . PHP_EOL;
     $moduleManager = $framework->getModuleManager();
     foreach ($moduleManager->getModules() as $namespace => $module) {
         $properties = $moduleManager->getModuleProperties($module->getDirectory());
         $info = $properties->module;
         $output .= '- ' . $info->name . ' ' . $info->version . ' (' . $namespace . '):' . PHP_EOL;
         $output .= '  ' . $info->description . PHP_EOL . PHP_EOL;
     }
     $response->setOutputPart('modules', $output);
 }
示例#4
0
 /**
  * This event handler clears the assets cache.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\CliRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, CliRequest $request, Response $response)
 {
     // Clean the asset cache
     $this->assetCacheManager->clearAssetCache();
     $response->setOutputPart('cacheCleared', 'The asset cache was successfully cleared!');
 }
示例#5
0
 /**
  * The DefaultRouteNotFound event handler will generate a 
  * route not found error message.
  * 
  * @access public
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\RequestAbstract $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, RequestAbstract $request, Response $response)
 {
     $response->setOutputPart('404', 'The requested route is not available. We can\'t execute the request. Route: "' . $request->getRoute() . '"');
 }
 /**
  * Displays a message if the session has no access to the requested command.
  * 
  * @param \Zepi\Turbo\Framework $framework
  * @param \Zepi\Turbo\Request\CliRequest $request
  * @param \Zepi\Turbo\Response\Response $response
  */
 public function execute(Framework $framework, CliRequest $request, Response $response)
 {
     $response->setOutputPart('noAccess', 'You have no access to the requested command!');
 }