Beispiel #1
0
 public function execute(IRequest $request, IResponse $response)
 {
     $view = new HtmlTemplateView(__APP_PATH . 'views/default.php');
     if ($request->issetParameter('name')) {
         $view->assign('name', $request->getParameter('name'));
     }
     $response->write($view->parse());
 }
 protected function notifyLoadRoute(IRequest $request)
 {
     $event = new Event($this, 'route.load', array('request' => $request));
     $this->emitter->notifyUntil($event);
     if (!$event->isHandled()) {
         throw new NotFoundHttpException("No route found for '{$request->getPathInfo()}' request");
     }
     return $event->getValue();
 }
Beispiel #3
0
 public function createAction(IRequest $req)
 {
     $act = $req->get('action');
     if ($act == null) {
         return null;
     }
     return $this->_actsNs . implode('', array_map(function ($chunk) {
         return ucfirst($chunk);
     }, explode('_', $act))) . 'Action';
 }
 public function getCommand(IRequest $request)
 {
     if ($request->issetParameter('cmd')) {
         $cmdName = $request->getParameter('cmd');
         $command = $this->_loadCommand($cmdName);
         if ($command instanceof ICommand) {
             return $command;
         }
     }
     $command = $this->_loadCommand($this->_defaultCommand);
     return $command;
 }
Beispiel #5
0
 public function execute(IRequest $request, IResponse $response)
 {
     $authData = $request->getAuthData();
     if ($authData === null) {
         $this->sendAuthRequest($response);
     }
     $username = $authData['user'];
     $password = $authData['password'];
     $dispatcher = $this->_registry->get('EventDispatcher');
     if (!isset($this->_authData[$username]) || $this->_authData[$username] !== $password) {
         $dispatcher->triggerEvent('onInvalidLogin', $this, $authData);
         $this->sendAuthRequest($response);
     }
     $event = $dispatcher->triggerEvent('onLogin', $this, $authData);
     if ($event->isCancelled()) {
         $this->sendAuthRequest($response);
     }
 }
Beispiel #6
0
 /**
  * Unset session element
  *
  * @access public
  *
  * @param string $name element name
  *
  * @return void
  */
 public function __unset($name)
 {
     $this->request->unsetSession($name);
 }
Beispiel #7
0
 public function __construct(IScope $scope, IRequest $request)
 {
     parent::__construct($scope, $request->getParameters());
     $this->request = $request;
 }
Beispiel #8
0
 /**
  * Exists cookie
  *
  * @access public
  *
  * @param string $name cookie name
  *
  * @return bool
  */
 public function exists($name)
 {
     return (bool) $this->request->cookie($name);
 }
 public function processRequest(IRepository &$repository, IRequest &$request, IBinaryDataRepository &$binaryRepository)
 {
     $criteria = $request->getCriteria();
     $result = $repository->find($criteria);
     return $result != null && count($result) > 0 ? $result[0] : new Page();
 }
Beispiel #10
0
 /**
  * Send a request 
  * 
  * @param IRequest $request
  * @return IResponse
  */
 public function send(IRequest $request)
 {
     return $request->send();
 }