Skip to content

Commit

Permalink
Allow to definte the factories in the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Oct 12, 2018
1 parent 5051771 commit c82a003
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

- Use `phpstan` as a dev dependency to detect bugs

### Added

- Added `responseFactory` option to `__construct`

## [1.1.0] - 2018-08-04

### Added
Expand Down
5 changes: 4 additions & 1 deletion src/FastRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

use FastRoute\Dispatcher;
use Middlewares\Utils\Traits\HasResponseFactory;
use Middlewares\Utils\Factory;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\MiddlewareInterface;
Expand All @@ -27,9 +29,10 @@ class FastRoute implements MiddlewareInterface
/**
* Set the Dispatcher instance.
*/
public function __construct(Dispatcher $router)
public function __construct(Dispatcher $router, ResponseFactoryInterface $responseFactory = null)
{
$this->router = $router;
$this->responseFactory = $responseFactory ?: Factory::getResponseFactory();
}

/**
Expand Down

0 comments on commit c82a003

Please sign in to comment.