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 f37cac3 commit 8a2c385
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/Plugin/Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
use Mvc5\Arg;
use Mvc5\Http\Request;
use Mvc5\Plugin\Call;
use Mvc5\Plugin\Link;
use Mvc5\Service\Service;
use Mvc5\Plugin\Invoke;
use Mvc5\Plugin\Plugin;

class Page
extends Call
Expand All @@ -20,19 +20,18 @@ class Page
*/
function __construct(string $template, array $vars = [])
{
parent::__construct([$this, '__invoke'], [new Link, $template, $vars]);
parent::__construct([$this, '__invoke'], [$template, $vars]);
}

/**
* @param Service $service
* @param string $template
* @param array $vars
* @return \Closure
* @return Invoke
*/
function __invoke(Service $service, string $template, array $vars) : \Closure
function __invoke(string $template, array $vars) : Invoke
{
return function(Request $request) use($service, $template, $vars) {
return $service->plugin(Arg::VIEW_MODEL, [$template, $vars + [Arg::REQUEST => $request]]);
};
return new Invoke(function(Request $request) use($template, $vars) {
return new Plugin(Arg::VIEW_MODEL, [$template, $vars + [Arg::REQUEST => $request]]);
});
}
}

0 comments on commit 8a2c385

Please sign in to comment.