collect() public method

public collect ( Request $request, Response $response, Exception $exception = null )
$request Symfony\Component\HttpFoundation\Request
$response Symfony\Component\HttpFoundation\Response
$exception Exception
Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = NULL)
 {
     parent::collect($request, $response, $exception);
     $controller = $this->controllerResolver->getController($request);
     $this->data['controller'] = $this->getMethodData($controller[0], $controller[1]);
     $this->data['access_check'] = $this->accessCheck;
 }
Ejemplo n.º 2
0
 public function testCollect()
 {
     $c = new RequestDataCollector();
     $c->collect($request = $this->createRequest(), $this->createResponse());
     $cloner = new VarCloner();
     $attributes = $c->getRequestAttributes();
     $this->assertSame('request', $c->getName());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getRequestHeaders());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestServer());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestCookies());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $attributes);
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestRequest());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestQuery());
     $this->assertSame('html', $c->getFormat());
     $this->assertEquals('foobar', $c->getRoute());
     $this->assertEquals($cloner->cloneVar(array('name' => 'foo')), $c->getRouteParams());
     $this->assertSame(array(), $c->getSessionAttributes());
     $this->assertSame('en', $c->getLocale());
     $this->assertEquals($cloner->cloneVar($request->attributes->get('resource')), $attributes->get('resource'));
     $this->assertEquals($cloner->cloneVar($request->attributes->get('object')), $attributes->get('object'));
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getResponseHeaders());
     $this->assertSame('OK', $c->getStatusText());
     $this->assertSame(200, $c->getStatusCode());
     $this->assertSame('application/json', $c->getContentType());
 }
Ejemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     if ($parentRequestAttributes = $request->attributes->get('_forwarded')) {
         if ($parentRequestAttributes instanceof ParameterBag) {
             $parentRequestAttributes->set('_forward_token', $response->headers->get('x-debug-token'));
         }
     }
     if ($request->attributes->has('_forward_controller')) {
         $this->data['forward'] = array('token' => $request->attributes->get('_forward_token'), 'controller' => $this->parseController($request->attributes->get('_forward_controller')));
     }
 }
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     $controller = explode('::', $request->get('_controller'));
     if (count($controller) !== 2) {
         return;
     }
     $class = new \ReflectionClass($controller[0]);
     $reflectionMethod = $class->getMethod($controller[1]);
     $annotation = $this->annotationReader->getMethodAnnotation($reflectionMethod, '\\Rezzza\\SecurityBundle\\Controller\\Annotations\\ObfuscateRequest');
     if ($annotation) {
         $this->data = $this->obfuscator->obfuscate($this->data, $annotation->getObfuscatedPatterns());
     }
 }
Ejemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     $this->data['controller'] = 'n/a';
     if (isset($this->controllers[$request])) {
         $controller = $this->controllers[$request];
         if (is_array($controller)) {
             $r = new \ReflectionMethod($controller[0], $controller[1]);
             $this->data['controller'] = array('class' => get_class($controller[0]), 'method' => $controller[1], 'file' => $r->getFilename(), 'line' => $r->getStartLine());
         } elseif ($controller instanceof \Closure) {
             $this->data['controller'] = 'Closure';
         } else {
             $this->data['controller'] = (string) $controller ?: 'n/a';
         }
         unset($this->controllers[$request]);
     }
 }
Ejemplo n.º 6
0
 /**
  * @dataProvider provider
  */
 public function testCollect(Request $request, Response $response)
 {
     $c = new RequestDataCollector();
     $c->collect($request, $response);
     $this->assertSame('request', $c->getName());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getRequestHeaders());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestServer());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestCookies());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestAttributes());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestRequest());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\ParameterBag', $c->getRequestQuery());
     $this->assertEquals('html', $c->getFormat());
     $this->assertEquals(array(), $c->getSessionAttributes());
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\HeaderBag', $c->getResponseHeaders());
     $this->assertEquals(200, $c->getStatusCode());
     $this->assertEquals('application/json', $c->getContentType());
 }
Ejemplo n.º 7
0
    public function testItIgnoresInvalidCallables()
    {
        $request = $this->createRequestWithSession();
        $response = new RedirectResponse('/');

        $c = new RequestDataCollector();
        $c->collect($request, $response);

        $this->assertSame('n/a', $c->getController());
    }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function collect(Request $request, Response $response, \Exception $exception = null)
 {
     parent::collect($request, $response, $exception);
     $this->data['route'] = $request->attributes->get('_route');
 }