Skip to content

Commit

Permalink
Fixed dispatching
Browse files Browse the repository at this point in the history
  • Loading branch information
kocsismate committed Aug 17, 2015
1 parent 3ebb13f commit 4213ae4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Middleware/JsonApiDispatcherMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use Interop\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\ResponseInterface;
use WoohooLabs\Yin\JsonApi\JsonApi;
use WoohooLabs\Yin\JsonApi\Request\Request;
use WoohooLabs\Yin\JsonApi\Schema\Error;
use WoohooLabs\Yin\JsonApi\Transformer\ErrorDocument;

Expand Down Expand Up @@ -36,11 +38,13 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
$this->getDispatchErrorDocument([$this->getDispatchError()])->getResponse($response);
}

$jsonApi = new JsonApi(new Request($request), $response);

if (is_array($callable) && is_string($callable[0])) {
$object = $this->container->get($callable[0]);
$response = $object->{$callable[1]}($request, $response);
$response = $object->{$callable[1]}($jsonApi);
} else {
$response = call_user_func($callable, $request, $response);
$response = call_user_func($callable, $jsonApi);
}

$next($request, $response);
Expand Down

0 comments on commit 4213ae4

Please sign in to comment.