Пример #1
0
 /**
  *
  * @param Request $request            
  * @param Response $response            
  * @param unknown $args            
  */
 public function resultsdelete(Request $request, Response $response, $args)
 {
     $id = $args['id'];
     $record = R::load(USER, $id);
     if ($record) {
         R::trash($record);
     }
     return $response->withRedirect($this->router->pathFor('results'));
 }
Пример #2
0
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response)
 {
     $post = $request->getParsedBody();
     $gReCaptcha = empty($post['g-recaptcha-response']) ? null : $post['g-recaptcha-response'];
     $secret = empty($post['secret']) ? null : $post['secret'];
     $author = empty($post['author']) ? 'anonymous' : $post['author'];
     if (empty($post['comment'])) {
         return $response->withStatus(400, 'you have to post something...');
     }
     // validate w/ google
     if (!$this->recaptcha->IsVerified($gReCaptcha)) {
         return $response->withStatus(400, 'You did not pass re-captcha');
     }
     $comment = Comment::factory($author, $post['comment'], $secret);
     $this->entityManager->persist($comment);
     $this->entityManager->flush();
     return $response->withStatus(302, 'comment posted')->withHeader('Location', $this->router->pathFor('home'));
 }
Пример #3
0
 /**
  * @expectedException \RuntimeException
  */
 public function testPathForRouteNotExists()
 {
     $methods = ['GET'];
     $pattern = '/hello/{first}/{last}';
     $callable = function ($request, $response, $args) {
         echo sprintf('Hello %s %s', $args['first'], $args['last']);
     };
     $route = $this->router->map($methods, $pattern, $callable);
     $route->setName('foo');
     $this->router->pathFor('bar', ['first' => 'josh', 'last' => 'lockhart']);
 }
Пример #4
0
 public function results(Request $request, Response $response, $args)
 {
     return $response->withRedirect($this->router->pathFor('results'));
 }