From bfda678cf1bbd2c9b0063f5712427d5acc04f8eb Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Wed, 22 Jun 2016 15:10:06 +0200 Subject: [PATCH 01/12] support zend-mvc >3 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d2ab6c9..6d5e645 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ }, "require-dev": { "phpunit/phpunit": "^3.7", - "zendframework/zend-mvc": "^2.6", + "zendframework/zend-mvc": "^2.6 || ^3.0", "zendframework/zend-console": "^2.6" }, "suggest": { From 26129e5a5f9cd4145ad65d0dbb6fb8e119ecb9aa Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Wed, 22 Jun 2016 16:12:11 +0200 Subject: [PATCH 02/12] updated AsseticBundleInitializer signature --- .../Initializer/AsseticBundleInitializer.php | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/AsseticBundle/Initializer/AsseticBundleInitializer.php b/src/AsseticBundle/Initializer/AsseticBundleInitializer.php index d96f535..7ef8ae0 100644 --- a/src/AsseticBundle/Initializer/AsseticBundleInitializer.php +++ b/src/AsseticBundle/Initializer/AsseticBundleInitializer.php @@ -2,6 +2,7 @@ namespace AsseticBundle\Initializer; use AsseticBundle\AsseticBundleServiceAwareInterface; +use Interop\Container\ContainerInterface; use Zend\ServiceManager\InitializerInterface; use Zend\ServiceManager\ServiceLocatorAwareInterface; use Zend\ServiceManager\ServiceLocatorInterface; @@ -9,19 +10,29 @@ class AsseticBundleInitializer implements InitializerInterface { /** - * Initialize + * invoke * + * @param ContainerInterface $container * @param $instance - * @param ServiceLocatorInterface $serviceLocator - * @return mixed */ - public function initialize($instance, ServiceLocatorInterface $serviceLocator) + public function __invoke(ContainerInterface $container, $instance) { if ($instance instanceof AsseticBundleServiceAwareInterface) { - if ($serviceLocator instanceof ServiceLocatorAwareInterface) { - $serviceLocator = $serviceLocator->getServiceLocator(); + if ($container instanceof ServiceLocatorAwareInterface) { + $container = $container->getServiceLocator(); } - $instance->setAsseticBundleService($serviceLocator->get('AsseticService')); + $instance->setAsseticBundleService($container->get('AsseticService')); } } -} \ No newline at end of file + + /** + * Initialize + * + * @param $instance + * @param ServiceLocatorInterface $serviceLocator + */ + public function initialize($instance, ServiceLocatorInterface $serviceLocator) + { + $this($serviceLocator, $instance); + } +} From 1b973017bdcf320e6e838a8dc90ef3889505a300 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Thu, 23 Jun 2016 11:51:01 +0200 Subject: [PATCH 03/12] added __invoke function with proxy to createService --- src/AsseticBundle/FilterManagerFactory.php | 17 +++++++++++++++-- src/AsseticBundle/ServiceFactory.php | 17 +++++++++++++++-- src/AsseticBundle/WriterFactory.php | 19 ++++++++++++++++--- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/AsseticBundle/FilterManagerFactory.php b/src/AsseticBundle/FilterManagerFactory.php index be20f48..da70173 100644 --- a/src/AsseticBundle/FilterManagerFactory.php +++ b/src/AsseticBundle/FilterManagerFactory.php @@ -3,19 +3,32 @@ use AsseticBundle\FilterManager; +use Interop\Container\ContainerInterface; + use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class FilterManagerFactory implements FactoryInterface { /** - * @param ServiceLocatorInterface $locator + * @param ContainerInterface $locator + * @param String $requestedName + * @param Array $options, optional * @return \AsseticBundle\FilterManager */ - public function createService(ServiceLocatorInterface $locator) + public function __invoke(ContainerInterface $locator, $requestedName, array $options = null) { $filterManager = new FilterManager($locator); return $filterManager; } + + /** + * @param ServiceLocatorInterface $locator + * @return \AsseticBundle\FilterManager + */ + public function createService(ServiceLocatorInterface $locator) + { + return $this($locator, 'FilterManager'); + } } diff --git a/src/AsseticBundle/ServiceFactory.php b/src/AsseticBundle/ServiceFactory.php index f21576a..2825bb5 100644 --- a/src/AsseticBundle/ServiceFactory.php +++ b/src/AsseticBundle/ServiceFactory.php @@ -1,16 +1,20 @@ get('AsseticConfiguration'); if ($asseticConfig->detectBaseUrl()) { @@ -33,4 +37,13 @@ public function createService(ServiceLocatorInterface $locator) return $asseticService; } + + /** + * @param ServiceLocatorInterface $locator + * @return \AsseticBundle\Service + */ + public function createService(ServiceLocatorInterface $locator) + { + return $this($locator, 'AsseticService'); + } } diff --git a/src/AsseticBundle/WriterFactory.php b/src/AsseticBundle/WriterFactory.php index b15ed25..3649f83 100644 --- a/src/AsseticBundle/WriterFactory.php +++ b/src/AsseticBundle/WriterFactory.php @@ -3,20 +3,33 @@ use Assetic\AssetWriter; +use Interop\Container\ContainerInterface; + use Zend\ServiceManager\FactoryInterface; use Zend\ServiceManager\ServiceLocatorInterface; class WriterFactory implements FactoryInterface { /** - * @param ServiceLocatorInterface $locator - * @return \Assetic\AssetWriter; + * @param ContainerInterface $locator + * @param String $requestedName + * @param Array $options, optional + * @return \AsseticBundle\FilterManager */ - public function createService(ServiceLocatorInterface $locator) + public function __invoke(ContainerInterface $locator, $requestedName, array $options = null) { $asseticConfig = $locator->get('AsseticConfiguration'); $asseticWriter = new AssetWriter($asseticConfig->getWebPath()); return $asseticWriter; } + + /** + * @param ServiceLocatorInterface $locator + * @return \Assetic\AssetWriter; + */ + public function createService(ServiceLocatorInterface $locator) + { + return $this($locator, 'AssetWriter'); + } } From 83993221d2aec4896724d879504cc8be064a33d1 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Thu, 23 Jun 2016 11:51:50 +0200 Subject: [PATCH 04/12] updated attach signature, added $priority --- src/AsseticBundle/Listener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/AsseticBundle/Listener.php b/src/AsseticBundle/Listener.php index 9ebb417..29184e6 100644 --- a/src/AsseticBundle/Listener.php +++ b/src/AsseticBundle/Listener.php @@ -21,8 +21,9 @@ class Listener implements ListenerAggregateInterface * implementation will pass this to the aggregate. * * @param EventManagerInterface $events + * @param Integer $priority */ - public function attach(EventManagerInterface $events) + public function attach(EventManagerInterface $events, $priority = 1) { $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH, array($this, 'renderAssets'), 32); $this->listeners[] = $events->attach(MvcEvent::EVENT_DISPATCH_ERROR, array($this, 'renderAssets'), 32); @@ -78,4 +79,4 @@ public function renderAssets(MvcEvent $e) // Init assets for modules $asseticService->setupRenderer($sm->get('ViewRenderer')); } -} \ No newline at end of file +} From 84db54a354a86539db7a4c514575434e636b0dca Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Thu, 23 Jun 2016 14:05:40 +0200 Subject: [PATCH 05/12] only support mvc 3 since its not compatible with version 2.* --- composer.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 6d5e645..f2e2ad1 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,14 @@ } ], "require": { - "php": ">=5.4", + "php": "^5.6 || ^7.0", "kriswallsmith/assetic": "^1.2", "widmogrod/php-functional": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^3.7", - "zendframework/zend-mvc": "^2.6 || ^3.0", + "phpunit/phpunit": "^5.4", + "zendframework/zend-mvc": "^3.0", + "zendframework/zend-mvc-console": "^1.0", "zendframework/zend-console": "^2.6" }, "suggest": { From cda1f74fe81420a07d5625ceee63aed1fcc3dd97 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Fri, 24 Jun 2016 12:28:50 +0200 Subject: [PATCH 06/12] change way how ListenerAggregate is attached to eventmanager --- Module.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Module.php b/Module.php index b65d4d2..928b95e 100755 --- a/Module.php +++ b/Module.php @@ -35,7 +35,7 @@ public function onBootstrap(EventInterface $e) // Listener have only sense when request is via http. if (!Console::isConsole()) { - $em->attach($sm->get('AsseticBundle\Listener')); + $sm->get('AsseticBundle\Listener')->attach($em); } } @@ -114,4 +114,4 @@ public function getConsoleUsage(AdapterInterface $console) 'assetic build' => 'Build all assets', ); } -} \ No newline at end of file +} From bcb0c602f1229c6ad1a8b3f1ddc56d760c9e5239 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Fri, 24 Jun 2016 12:32:16 +0200 Subject: [PATCH 07/12] removed invokables and initializers for controller factory --- configs/module.config.php | 15 +++----- .../AsseticBundleServiceAwareInterface.php | 7 ---- .../Controller/ConsoleController.php | 3 +- .../Controller/ConsoleControllerFactory.php | 17 +++++++++ .../Initializer/AsseticBundleInitializer.php | 38 ------------------- 5 files changed, 23 insertions(+), 57 deletions(-) delete mode 100644 src/AsseticBundle/AsseticBundleServiceAwareInterface.php create mode 100644 src/AsseticBundle/Controller/ConsoleControllerFactory.php delete mode 100644 src/AsseticBundle/Initializer/AsseticBundleInitializer.php diff --git a/configs/module.config.php b/configs/module.config.php index aeff955..492480d 100644 --- a/configs/module.config.php +++ b/configs/module.config.php @@ -3,11 +3,11 @@ return array( 'controllers' => array( - 'invokables' => array( + 'aliases' => array( 'AsseticBundle\Controller\Console' => 'AsseticBundle\Controller\ConsoleController', ), - 'initializers' => array( - 'AsseticBundleInitializer' => 'AsseticBundle\Initializer\AsseticBundleInitializer', + 'factories' => array( + 'AsseticBundle\Controller\ConsoleController' => 'AsseticBundle\Controller\ConsoleControllerFactory' ), ), @@ -21,13 +21,8 @@ 'AsseticBundle\Service' => 'AsseticBundle\ServiceFactory', 'Assetic\AssetWriter' => 'AsseticBundle\WriterFactory', 'AsseticBundle\FilterManager' => 'AsseticBundle\FilterManagerFactory', - ), - 'invokables' => array( - 'Assetic\AssetManager' => 'Assetic\AssetManager', - 'AsseticBundle\Listener' => 'AsseticBundle\Listener', - ), - 'initializers' => array( - 'AsseticBundleInitializer' => 'AsseticBundle\Initializer\AsseticBundleInitializer', + 'Assetic\AssetManager' => 'Zend\ServiceManager\Factory\InvokableFactory', + 'AsseticBundle\Listener' => 'Zend\ServiceManager\Factory\InvokableFactory', ), ), diff --git a/src/AsseticBundle/AsseticBundleServiceAwareInterface.php b/src/AsseticBundle/AsseticBundleServiceAwareInterface.php deleted file mode 100644 index eeea5c8..0000000 --- a/src/AsseticBundle/AsseticBundleServiceAwareInterface.php +++ /dev/null @@ -1,7 +0,0 @@ -assetic = $service; } -} \ No newline at end of file +} diff --git a/src/AsseticBundle/Controller/ConsoleControllerFactory.php b/src/AsseticBundle/Controller/ConsoleControllerFactory.php new file mode 100644 index 0000000..e27c117 --- /dev/null +++ b/src/AsseticBundle/Controller/ConsoleControllerFactory.php @@ -0,0 +1,17 @@ +setAsseticBundleService($container->get('AsseticService')); + + return $instance; + } +} diff --git a/src/AsseticBundle/Initializer/AsseticBundleInitializer.php b/src/AsseticBundle/Initializer/AsseticBundleInitializer.php deleted file mode 100644 index 7ef8ae0..0000000 --- a/src/AsseticBundle/Initializer/AsseticBundleInitializer.php +++ /dev/null @@ -1,38 +0,0 @@ -getServiceLocator(); - } - $instance->setAsseticBundleService($container->get('AsseticService')); - } - } - - /** - * Initialize - * - * @param $instance - * @param ServiceLocatorInterface $serviceLocator - */ - public function initialize($instance, ServiceLocatorInterface $serviceLocator) - { - $this($serviceLocator, $instance); - } -} From 35d7aff51f2935f8676dfd9d3c784d0afb3bdf47 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Fri, 24 Jun 2016 12:32:41 +0200 Subject: [PATCH 08/12] service names are not so much normalized anymore --- src/AsseticBundle/ServiceFactory.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/AsseticBundle/ServiceFactory.php b/src/AsseticBundle/ServiceFactory.php index 2825bb5..1114ec0 100644 --- a/src/AsseticBundle/ServiceFactory.php +++ b/src/AsseticBundle/ServiceFactory.php @@ -26,9 +26,9 @@ public function __invoke(ContainerInterface $locator, $requestedName, array $opt } $asseticService = new Service($asseticConfig); - $asseticService->setAssetManager($locator->get('AsseticAssetManager')); - $asseticService->setAssetWriter($locator->get('AsseticAssetWriter')); - $asseticService->setFilterManager($locator->get('AsseticFilterManager')); + $asseticService->setAssetManager($locator->get('Assetic\AssetManager')); + $asseticService->setAssetWriter($locator->get('Assetic\AssetWriter')); + $asseticService->setFilterManager($locator->get('Assetic\FilterManager')); // Cache buster is not mandatory if ($locator->has('AsseticCacheBuster')){ From 606c7cf22483f82053ac22fb8aac6ae92049dbf1 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Fri, 24 Jun 2016 13:27:37 +0200 Subject: [PATCH 09/12] removed AsseticBundleServiceAwareInterface --- src/AsseticBundle/Controller/ConsoleController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/AsseticBundle/Controller/ConsoleController.php b/src/AsseticBundle/Controller/ConsoleController.php index cd42e0c..3d04f42 100644 --- a/src/AsseticBundle/Controller/ConsoleController.php +++ b/src/AsseticBundle/Controller/ConsoleController.php @@ -4,7 +4,7 @@ use AsseticBundle\Service; use Zend\Mvc\Controller\AbstractActionController; -class ConsoleController extends AbstractActionController implements AsseticBundleServiceAwareInterface +class ConsoleController extends AbstractActionController { /** * @var Service From 3af834b9024d533e4ce9b6e6903192ac1e1c4172 Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Thu, 30 Jun 2016 13:34:38 +0200 Subject: [PATCH 10/12] moved zend packages to require, because one can't expect everything to be there --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 1146450..42c0027 100644 --- a/composer.json +++ b/composer.json @@ -23,15 +23,15 @@ "require": { "php": "^5.6 || ^7.0", "kriswallsmith/assetic": "^1.2", - "widmogrod/php-functional": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^5.4", - "zendframework/zend-mvc": "^3.0", + "widmogrod/php-functional": "^1.0", + "zendframework/zend-mvc": "^3.0", "zendframework/zend-mvc-console": "^1.0", "zendframework/zend-console": "^2.6", "zendframework/zend-version": "@stable" }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, "suggest": { "leafo/lessphp": "Assetic provides the integration with the lessphp LESS compiler", "leafo/scssphp": "Assetic provides the integration with the scssphp SCSS compiler" From 534ee2ac67513f261486115d19fbd2da63e6bcef Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Mon, 4 Jul 2016 10:33:40 +0200 Subject: [PATCH 11/12] removed zend-version as usage is not required if it only runs on mvc > 3 --- Module.php | 7 +------ composer.json | 5 ++--- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/Module.php b/Module.php index 50f7cd6..f80ae02 100755 --- a/Module.php +++ b/Module.php @@ -11,7 +11,6 @@ use Zend\ModuleManager\Feature\ConfigProviderInterface; use Zend\ModuleManager\Feature\ServiceProviderInterface; use Zend\ModuleManager\Feature\BootstrapListenerInterface; -use Zend\Version\Version; class Module implements AutoloaderProviderInterface, @@ -35,11 +34,7 @@ public function onBootstrap(EventInterface $e) // Listener have only sense when request is via http. if (!Console::isConsole()) { - if (Version::compareVersion('3.0.0') == -1) { - $em->attach($sm->get('AsseticBundle\Listener')); - } else { - $sm->get('AsseticBundle\Listener')->attach($em); - } + $sm->get('AsseticBundle\Listener')->attach($em); } } diff --git a/composer.json b/composer.json index 42c0027..af63ebf 100644 --- a/composer.json +++ b/composer.json @@ -24,10 +24,9 @@ "php": "^5.6 || ^7.0", "kriswallsmith/assetic": "^1.2", "widmogrod/php-functional": "^1.0", - "zendframework/zend-mvc": "^3.0", + "zendframework/zend-mvc": "^3.0", "zendframework/zend-mvc-console": "^1.0", - "zendframework/zend-console": "^2.6", - "zendframework/zend-version": "@stable" + "zendframework/zend-console": "^2.6" }, "require-dev": { "phpunit/phpunit": "^5.4" From 80fc836f1b90f57aaa6f685aac50a5d30fc5e7ec Mon Sep 17 00:00:00 2001 From: Matthias Tylkowski Date: Tue, 5 Jul 2016 09:44:15 +0200 Subject: [PATCH 12/12] removed php 5.5 from travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0fef15b..19baa18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,6 @@ language: php php: - - 5.5 - 5.6 - 7.0 - hhvm