Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::getRequestAttributes PHP Method

getRequestAttributes() public method

    public function getRequestAttributes()
    {
        return new ParameterBag($this->data['request_attributes']);
    }

Usage Example

コード例 #1
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());
 }
All Usage Examples Of Symfony\Component\HttpKernel\DataCollector\RequestDataCollector::getRequestAttributes