Esempio n. 1
0
 public static function protect(Controller $controller)
 {
     $controller->before[] = function () {
         if (CsrfProtector::isMethodProtected(Uri::getRequestType())) {
             CsrfProtector::validate();
         }
         return true;
     };
     $controller->after[] = function () use($controller) {
         $controller->setCookie(array('name' => 'csrftoken', 'value' => CsrfProtector::getCsrfToken(), 'expire' => 0, 'path' => '/'));
         return true;
     };
 }
Esempio n. 2
0
 private function renderOutput()
 {
     ob_start();
     $this->currentControllerObject->display();
     $page = ob_get_contents();
     ob_end_clean();
     $this->outputDisplayer->display($page);
 }
Esempio n. 3
0
 /**
  * @test
  */
 public function shouldNotStoreEmptyUrlForNotices()
 {
     //given
     Config::overridePropertyArray(array('global', 'prefix_system'), 'prefix');
     $_SESSION = array();
     $controller = Controller::createInstance(new RouteRule('', '', '', '', false));
     //when
     $controller->notice('hello');
     //then
     Assert::thatArray(Session::get('messages'))->containsOnly(new Notice('hello', null));
     Config::revertPropertyArray(array('global', 'prefix_system'));
 }