Zend\Diactoros\ServerRequest::withAttribute PHP Méthode

withAttribute() public méthode

public withAttribute ( $attribute, $value )
    public function withAttribute($attribute, $value)
    {
        $new = clone $this;
        $new->attributes[$attribute] = $value;
        return $new;
    }

Usage Example

 /**
  * @param $resourceName
  * @param $primaryKey
  * @dataProvider testResourceResolverWhirRoutDataProvider
  */
 public function testResourceResolver__invokeWithRouting($resourceName, $primaryKey)
 {
     $this->request = new ServerRequest([], []);
     $this->request = $this->request->withAttribute("resourceName", $resourceName);
     $this->request = $this->request->withAttribute("id", $primaryKey);
     $this->next = function ($req, $resp) {
         return $req;
     };
     $responseResolver = $this->object->__invoke($this->request, $this->response, $this->next);
     $this->assertEquals($responseResolver->getAttribute('Resource-Name'), $resourceName);
     $this->assertEquals($responseResolver->getAttribute('Primary-Key-Value'), $primaryKey);
 }
All Usage Examples Of Zend\Diactoros\ServerRequest::withAttribute