Compare commits
2 Commits
6aa311b35d
...
565c0315d3
Author | SHA1 | Date |
---|---|---|
Adrian | 565c0315d3 | |
Adrian | cb3dab1a64 |
|
@ -5,6 +5,7 @@
|
|||
}
|
||||
},
|
||||
"require": {
|
||||
"filp/whoops": "^2.1",
|
||||
"xtreamwayz/pimple-container-interop": "^1.0",
|
||||
"zendframework/zend-expressive": "^1.0",
|
||||
"zendframework/zend-expressive-fastroute": "^1.2",
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use Test\App\HomeAction;
|
||||
use Test\App\HomeFactory;
|
||||
use Test\App\DummyRenderer;
|
||||
use Xtreamwayz\Pimple\Container;
|
||||
use Zend\Expressive\Application;
|
||||
use Zend\Expressive\Container\ApplicationFactory;
|
||||
|
@ -11,6 +12,7 @@ use Zend\Expressive\Helper\UrlHelperMiddleware;
|
|||
use Zend\Expressive\Helper\UrlHelperMiddlewareFactory;
|
||||
use Zend\Expressive\Router\FastRouteRouter;
|
||||
use Zend\Expressive\Router\RouterInterface;
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
$c = new Container;
|
||||
|
||||
|
@ -20,6 +22,12 @@ $c[RouterInterface::class] = function () { return new FastRouteRouter; };
|
|||
$c[UrlHelper::class] = new UrlHelperFactory;
|
||||
$c[UrlHelperMiddleware::class] = new UrlHelperMiddlewareFactory;
|
||||
$c[HomeAction::class] = new HomeFactory;
|
||||
|
||||
$c[TemplateRendererInterface::class] = function () { return new DummyRenderer; };
|
||||
$c['Zend\Expressive\Whoops'] = function () { return new Whoops\Run; };
|
||||
$c['Zend\Expressive\WhoopsPageHandler'] = function () { return new Whoops\Handler\PrettyPageHandler; };
|
||||
$c['Zend\Expressive\FinalHandler'] = new Zend\Expressive\Container\WhoopsErrorHandlerFactory;
|
||||
|
||||
$c[Application::class] = new ApplicationFactory;
|
||||
|
||||
return $c;
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
|
||||
namespace Test\App;
|
||||
|
||||
use Zend\Expressive\Template\TemplateRendererInterface;
|
||||
|
||||
class DummyRenderer
|
||||
implements TemplateRendererInterface
|
||||
{
|
||||
protected $paths = array();
|
||||
|
||||
public function render($name, $params = array())
|
||||
{
|
||||
$params = print_r(['params' => $params, 'paths' => $this->paths], true);
|
||||
$params = str_replace("\n", "<br/>\n", $params);
|
||||
$params = str_replace(" ", " ", $params);
|
||||
return "Render template '$name'<br/>Params: $params";
|
||||
}
|
||||
|
||||
public function addPath($path, $namespace = null)
|
||||
{
|
||||
if ($namespace !== null) $namespace .= '::';
|
||||
$this->paths[] = $namespace . $path;
|
||||
}
|
||||
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->paths;
|
||||
}
|
||||
|
||||
public function addDefaultParam($templateName, $param, $value)
|
||||
{
|
||||
throw new \RuntimeException('Not implemented');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue