Skip to content

Commit

Permalink
resolve invoke plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
devosc committed Jun 13, 2018
1 parent 92cc64e commit f37cac3
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/Plugin/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,33 @@

use Mvc5\Arg;
use Mvc5\Http\Request;
use Mvc5\Http\Response;
use Mvc5\Plugin\Call;
use Mvc5\Plugin\Invoke;
use Mvc5\Plugin\Plugin;

class Redirect
extends Call
{
/**
* @param string $url
* @param int|null $status
* @param int $status
* @param array $headers
*/
function __construct(string $url, int $status = 302, array $headers = [])
{
parent::__construct([$this, '__invoke'], [new Plugin(Arg::RESPONSE_REDIRECT, [$url, $status, $headers])]);
parent::__construct([$this, '__invoke'], [$url, $status, $headers]);
}

/**
* @param Response $response
* @return \Closure
* @param string $url
* @param int $status
* @param array $headers
* @return Invoke
*/
function __invoke(Response $response) : \Closure
function __invoke(string $url, int $status, array $headers) : Invoke
{
return function(Request $request) use($response) {
return $response;
};
return new Invoke(function(Request $request) use($url, $status, $headers) {
return new Plugin(Arg::RESPONSE_REDIRECT, [$url, $status, $headers]);
});
}
}

0 comments on commit f37cac3

Please sign in to comment.