Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Updates to Expressive 0.4.0 #3

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
],
"require": {
"roave/security-advisories": "dev-master",
"zendframework/zend-expressive": "^0.3"
"zendframework/zend-expressive": "^0.4"
},
"require-dev": {
"composer/composer": ">=1.0.0-alpha10",
Expand Down
8 changes: 4 additions & 4 deletions src/Action/HomePageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class HomePageAction

private $template;

public function __construct(Router\RouterInterface $router, Template\TemplateInterface $template = null)
public function __construct(Router\RouterInterface $router, Template\TemplateRendererInterface $template = null)
{
$this->router = $router;
$this->template = $template;
Expand All @@ -36,13 +36,13 @@ public function __invoke(ServerRequestInterface $request, ResponseInterface $res
$data['routerDocs'] = 'http://framework.zend.com/manual/current/en/modules/zend.mvc.routing.html';
}

if ($this->template instanceof Template\Plates) {
if ($this->template instanceof Template\PlatesRenderer) {
$data['templateName'] = 'Plates';
$data['templateDocs'] = 'http://platesphp.com/';
} elseif ($this->template instanceof Template\Twig) {
} elseif ($this->template instanceof Template\TwigRenderer) {
$data['templateName'] = 'Twig';
$data['templateDocs'] = 'http://twig.sensiolabs.org/documentation';
} elseif ($this->template instanceof Template\ZendView) {
} elseif ($this->template instanceof Template\ZendViewRenderer) {
$data['templateName'] = 'Zend View';
$data['templateDocs'] = 'http://framework.zend.com/manual/current/en/modules/zend.view.quick-start.html';
}
Expand Down
6 changes: 4 additions & 2 deletions src/Action/HomePageFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@

use Interop\Container\ContainerInterface;
use Zend\Expressive\Router\RouterInterface;
use Zend\Expressive\Template\TemplateInterface;
use Zend\Expressive\Template\TemplateRendererInterface;

class HomePageFactory
{
public function __invoke(ContainerInterface $container)
{
$router = $container->get(RouterInterface::class);
$template = ($container->has(TemplateInterface::class)) ? $container->get(TemplateInterface::class) : null;
$template = ($container->has(TemplateRendererInterface::class))
? $container->get(TemplateRendererInterface::class)
: null;

return new HomePageAction($router, $template);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Resources/config/templates-plates.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
'Zend\Expressive\FinalHandler' =>
Zend\Expressive\Container\TemplatedErrorHandlerFactory::class,

Zend\Expressive\Template\TemplateInterface::class =>
Zend\Expressive\Container\Template\PlatesFactory::class,
Zend\Expressive\Template\TemplateRendererInterface::class =>
Zend\Expressive\Container\Template\PlatesRendererFactory::class,
],
],

Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Resources/config/templates-twig.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
'Zend\Expressive\FinalHandler' =>
Zend\Expressive\Container\TemplatedErrorHandlerFactory::class,

Zend\Expressive\Template\TemplateInterface::class =>
Zend\Expressive\Container\Template\TwigFactory::class,
Zend\Expressive\Template\TemplateRendererInterface::class =>
Zend\Expressive\Container\Template\TwigRendererFactory::class,
],
],

Expand Down
4 changes: 2 additions & 2 deletions src/Composer/Resources/config/templates-zend-view.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
'Zend\Expressive\FinalHandler' =>
Zend\Expressive\Container\TemplatedErrorHandlerFactory::class,

Zend\Expressive\Template\TemplateInterface::class =>
Zend\Expressive\Container\Template\ZendViewFactory::class,
Zend\Expressive\Template\TemplateRendererInterface::class =>
Zend\Expressive\Container\Template\ZendViewRendererFactory::class,
],
],

Expand Down
2 changes: 1 addition & 1 deletion src/Composer/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
'questions' => [
'router' => [
'question' => 'Which router you want to use?',
'default' => 1,
'default' => 2,
// TRUE: Must choose one / FALSE: May choose one or none of the above
'required' => true,
// Enable custom package input
Expand Down
10 changes: 6 additions & 4 deletions test/Action/HomePageFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use App\Action\HomePageFactory;
use Interop\Container\ContainerInterface;
use Zend\Expressive\Router\RouterInterface;
use Zend\Expressive\Template\TemplateInterface;
use Zend\Expressive\Template\TemplateRendererInterface;

class HomePageFactoryTest extends \PHPUnit_Framework_TestCase
{
Expand All @@ -24,7 +24,7 @@ public function setUp()
public function testFactoryWithoutTemplate()
{
$factory = new HomePageFactory();
$this->container->has(TemplateInterface::class)->willReturn(false);
$this->container->has(TemplateRendererInterface::class)->willReturn(false);

$this->assertTrue($factory instanceof HomePageFactory);

Expand All @@ -36,8 +36,10 @@ public function testFactoryWithoutTemplate()
public function testFactoryWithTemplate()
{
$factory = new HomePageFactory();
$this->container->has(TemplateInterface::class)->willReturn(true);
$this->container->get(TemplateInterface::class)->willReturn($this->prophesize(TemplateInterface::class));
$this->container->has(TemplateRendererInterface::class)->willReturn(true);
$this->container
->get(TemplateRendererInterface::class)
->willReturn($this->prophesize(TemplateRendererInterface::class));

$this->assertTrue($factory instanceof HomePageFactory);

Expand Down