From e874f6aa56dc269822e721c69d3920f12c738357 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Mon, 30 Nov 2015 17:10:54 -0600 Subject: [PATCH 1/4] Prepare for RouteResultObserver updates As of zendframework/zend-expressive#200, a new interface, `Zend\Expressive\Router\RouteResultObserverInterface` exists to allow notifying instances of the calculated `RouteResult`; this is particularly of interest to URI generators. With zendframework/zend-expressive-zendviewrenderer#9, the zend-view integration provides an observer via the `UrlHelper` it ships, and allows you to attach it to the application via a delegator factory. This patch defines the delegator factory in the template configuration for zend-view, and also details how you would accomplish similar functionality with Pimple. --- composer.json | 2 +- .../Resources/config/templates-zend-view.php | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 48ebeb3..e911e47 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "roave/security-advisories": "dev-master", - "zendframework/zend-expressive": "1.0.0rc2", + "zendframework/zend-expressive": "~1.0.0dev@dev", "zendframework/zend-stdlib": "~2.7" }, "require-dev": { diff --git a/src/Composer/Resources/config/templates-zend-view.php b/src/Composer/Resources/config/templates-zend-view.php index 5752b23..272cac3 100644 --- a/src/Composer/Resources/config/templates-zend-view.php +++ b/src/Composer/Resources/config/templates-zend-view.php @@ -2,10 +2,28 @@ return [ 'dependencies' => [ + /* + * Note: delegator_factories only work with zend-servicemanager. + * + * To get equivalent functionality with Pimple, add the following to your + * config/container.php file: + * + * $container->extend(Zend\Expressive\Application::class, function ($app, $container) { + * $app->attachRouteResultObserver($container->get(Zend\Expressive\ZendView\UrlHelper::class)); + * return $app; + * }); + */ + 'delegator_factories' => [ + Zend\Expressive\Application::class => [ + Zend\Expressive\ZendView\ApplicationUrlDelegatorFactory::class, + ], + ], 'factories' => [ 'Zend\Expressive\FinalHandler' => Zend\Expressive\Container\TemplatedErrorHandlerFactory::class, + Zend\Expressive\ZendView\UrlHelper::class => Zend\Expressive\ZendView\UrlHelperFactory::class, + Zend\Expressive\Template\TemplateRendererInterface::class => Zend\Expressive\ZendView\ZendViewRendererFactory::class, ], From 3473ae0c59044515b80c9129da0f0785ab82a494 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 1 Dec 2015 08:19:27 -0600 Subject: [PATCH 2/4] Updated dependency constraints - Added PHP at `^5.5 || ^7.0` - Modified expressive to `~1.0.0-dev@dev` --- composer.json | 3 ++- src/Composer/config.php | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index e911e47..f7502f9 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,9 @@ } ], "require": { + "php": "^5.5 || ^7.0", "roave/security-advisories": "dev-master", - "zendframework/zend-expressive": "~1.0.0dev@dev", + "zendframework/zend-expressive": "~1.0.0-dev@dev", "zendframework/zend-stdlib": "~2.7" }, "require-dev": { diff --git a/src/Composer/config.php b/src/Composer/config.php index b514cba..17507b9 100644 --- a/src/Composer/config.php +++ b/src/Composer/config.php @@ -11,7 +11,7 @@ 'zendframework/zend-expressive-platesrenderer' => '^0.2', 'zendframework/zend-expressive-twigrenderer' => '^0.2', 'zendframework/zend-expressive-zendrouter' => '^0.2', - 'zendframework/zend-expressive-zendviewrenderer' => '^0.2', + 'zendframework/zend-expressive-zendviewrenderer' => 'dev-master', 'zendframework/zend-servicemanager' => '^2.5', ], From b47fcfc8fa7f382a4b9eda8d96b8ecec13067836 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 3 Dec 2015 11:36:19 -0600 Subject: [PATCH 3/4] Updated version constraints for all implementation packages Most to `^0.3`, but used `^0.3.1` for zendviewrenderer, as that has a fix specific to the latest changes on expressive. --- src/Composer/config.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Composer/config.php b/src/Composer/config.php index 17507b9..89d2dec 100644 --- a/src/Composer/config.php +++ b/src/Composer/config.php @@ -6,12 +6,12 @@ 'filp/whoops' => '^1.1', 'mouf/pimple-interop' => '^1.0', 'ocramius/proxy-manager' => '^1.0', - 'zendframework/zend-expressive-aurarouter' => '^0.2', - 'zendframework/zend-expressive-fastroute' => '^0.2', - 'zendframework/zend-expressive-platesrenderer' => '^0.2', - 'zendframework/zend-expressive-twigrenderer' => '^0.2', - 'zendframework/zend-expressive-zendrouter' => '^0.2', - 'zendframework/zend-expressive-zendviewrenderer' => 'dev-master', + 'zendframework/zend-expressive-aurarouter' => '^0.3', + 'zendframework/zend-expressive-fastroute' => '^0.3', + 'zendframework/zend-expressive-platesrenderer' => '^0.3', + 'zendframework/zend-expressive-twigrenderer' => '^0.3', + 'zendframework/zend-expressive-zendrouter' => '^0.3', + 'zendframework/zend-expressive-zendviewrenderer' => '^0.3.1', 'zendframework/zend-servicemanager' => '^2.5', ], From d1f3e312bbe744f94bb54cfe2980979f99845f85 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Thu, 3 Dec 2015 12:32:10 -0600 Subject: [PATCH 4/4] Use ^0.3.1 for twigrenderer - ensures a usable version --- src/Composer/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Composer/config.php b/src/Composer/config.php index 89d2dec..0c830a8 100644 --- a/src/Composer/config.php +++ b/src/Composer/config.php @@ -9,7 +9,7 @@ 'zendframework/zend-expressive-aurarouter' => '^0.3', 'zendframework/zend-expressive-fastroute' => '^0.3', 'zendframework/zend-expressive-platesrenderer' => '^0.3', - 'zendframework/zend-expressive-twigrenderer' => '^0.3', + 'zendframework/zend-expressive-twigrenderer' => '^0.3.1', 'zendframework/zend-expressive-zendrouter' => '^0.3', 'zendframework/zend-expressive-zendviewrenderer' => '^0.3.1', 'zendframework/zend-servicemanager' => '^2.5',