Ergo\Http\ResponseBuilder::moved PHP Method

moved() public method

Configures response as a '301 Moved Permanently' permanent redirect.
public moved ( string $location )
$location string
    public function moved($location)
    {
        $this->_location = $location;
        return $this->setStatusCode(301);
    }

Usage Example

Example #1
0
 public function testRedirectPermanent()
 {
     $builder = new Http\ResponseBuilder();
     $response = $builder->moved('http://example.org/test')->build();
     $this->assertEquals($response->getStatus()->getCode(), 301);
     $this->assertFalse($response->hasBody());
     $headers = $response->getHeaders()->toArray();
     $this->assertEquals(count($headers), 2, 'should be 2 header: %s');
     $this->assertEquals($headers[0], "Location: http://example.org/test\r\n");
     $this->assertEquals($headers[1], "Content-Length: 0\r\n");
 }