From f5f39d1c336b27d6eacd556f5955898a6bf9f933 Mon Sep 17 00:00:00 2001 From: Thomas Vargiu Date: Mon, 17 Oct 2016 17:24:54 +0200 Subject: [PATCH] Fix zf2 --- Module.php | 24 +--- composer.json | 9 +- composer.lock | 112 +++++++++++++----- config/module.config.php | 3 - .../Factory/TwbBundleFormElementFactory.php | 10 +- src/TwbBundle/Module.php | 25 ++++ .../Options/Factory/ModuleOptionsFactory.php | 6 +- src/TwbBundle/Options/ModuleOptions.php | 2 +- tests/Bootstrap.php | 8 +- tests/TestConfig.php.dist | 1 + 10 files changed, 131 insertions(+), 69 deletions(-) create mode 100644 src/TwbBundle/Module.php diff --git a/Module.php b/Module.php index 24fe715..ec3eef0 100644 --- a/Module.php +++ b/Module.php @@ -1,25 +1,3 @@ array( - __DIR__.DIRECTORY_SEPARATOR.'autoload_classmap.php' - ) - ); - } - - /** - * @return array - */ - public function getConfig(){ - return include __DIR__.DIRECTORY_SEPARATOR.'config/module.config.php'; - } -} \ No newline at end of file +require_once __DIR__ . '/src/TwbBundle/Module.php'; diff --git a/composer.json b/composer.json index 74ff524..ffc7709 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "keywords": ["Zend Framework 2","Twitter Bootstrap","module"], "homepage": "http://neilime.github.io/zf2-twb-bundle/", "license": "MIT", - "minimum-stability" : "stable", + "minimum-stability": "stable", "authors": [ { "name": "Neilime", @@ -40,10 +40,9 @@ "satooshi/php-coveralls": "^0.7" }, "autoload": { - "psr-0": { - "TwbBundle": "src" - }, - "classmap" : ["Module.php"] + "psr-4": { + "TwbBundle\\": "src/TwbBundle" + } }, "extra": { "branch-alias": { diff --git a/composer.lock b/composer.lock index 4c5df8e..d4951d9 100644 --- a/composer.lock +++ b/composer.lock @@ -36,16 +36,16 @@ }, { "name": "psr/log", - "version": "1.0.1", + "version": "1.0.2", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0" + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0", + "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", "shasum": "" }, "require": { @@ -79,7 +79,7 @@ "psr", "psr-3" ], - "time": "2016-09-19 16:02:08" + "time": "2016-10-10 12:19:37" }, { "name": "zendframework/zend-config", @@ -2486,16 +2486,16 @@ }, { "name": "symfony/config", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/config.git", - "reference": "431d28df9c7bb6e77f8f6289d8670b044fabb9e8" + "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/431d28df9c7bb6e77f8f6289d8670b044fabb9e8", - "reference": "431d28df9c7bb6e77f8f6289d8670b044fabb9e8", + "url": "https://api.github.com/repos/symfony/config/zipball/949e7e846743a7f9e46dc50eb639d5fde1f53341", + "reference": "949e7e846743a7f9e46dc50eb639d5fde1f53341", "shasum": "" }, "require": { @@ -2535,24 +2535,25 @@ ], "description": "Symfony Config Component", "homepage": "https://symfony.com", - "time": "2016-08-27 18:50:07" + "time": "2016-09-25 08:27:07" }, { "name": "symfony/console", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563" + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/8ea494c34f0f772c3954b5fbe00bffc5a435e563", - "reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563", + "url": "https://api.github.com/repos/symfony/console/zipball/6cb0872fb57b38b3b09ff213c21ed693956b9eb0", + "reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0", "shasum": "" }, "require": { "php": ">=5.5.9", + "symfony/debug": "~2.8|~3.0", "symfony/polyfill-mbstring": "~1.0" }, "require-dev": { @@ -2595,11 +2596,68 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2016-08-19 06:48:39" + "time": "2016-09-28 00:11:12" + }, + { + "name": "symfony/debug", + "version": "v3.1.5", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8", + "shasum": "" + }, + "require": { + "php": ">=5.5.9", + "psr/log": "~1.0" + }, + "conflict": { + "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" + }, + "require-dev": { + "symfony/class-loader": "~2.8|~3.0", + "symfony/http-kernel": "~2.8|~3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.1-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Debug\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Debug Component", + "homepage": "https://symfony.com", + "time": "2016-09-06 11:02:40" }, { "name": "symfony/event-dispatcher", - "version": "v2.8.11", + "version": "v2.8.12", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -2659,16 +2717,16 @@ }, { "name": "symfony/filesystem", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "bb29adceb552d202b6416ede373529338136e84f" + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/bb29adceb552d202b6416ede373529338136e84f", - "reference": "bb29adceb552d202b6416ede373529338136e84f", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", + "reference": "682fd8fdb3135fdf05fc496a01579ccf6c85c0e5", "shasum": "" }, "require": { @@ -2704,7 +2762,7 @@ ], "description": "Symfony Filesystem Component", "homepage": "https://symfony.com", - "time": "2016-07-20 05:44:26" + "time": "2016-09-14 00:18:46" }, { "name": "symfony/polyfill-mbstring", @@ -2767,7 +2825,7 @@ }, { "name": "symfony/stopwatch", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/stopwatch.git", @@ -2816,16 +2874,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d" + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", "shasum": "" }, "require": { @@ -2861,7 +2919,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 02:12:52" + "time": "2016-09-25 08:27:07" }, { "name": "webmozart/assert", diff --git a/config/module.config.php b/config/module.config.php index 6607d07..621eb2d 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -18,9 +18,6 @@ 'service_manager' => array ( 'factories' => array ( 'TwbBundle\Options\ModuleOptions' => 'TwbBundle\Options\Factory\ModuleOptionsFactory', - 'RoutePluginManager' => 'Zend\Router\RoutePluginManagerFactory', - 'Router' => 'Zend\Router\RouterFactory', - 'HttpRouter' => 'Zend\Router\Http\HttpRouterFactory', ) ), 'view_helpers' => array ( diff --git a/src/TwbBundle/Form/View/Helper/Factory/TwbBundleFormElementFactory.php b/src/TwbBundle/Form/View/Helper/Factory/TwbBundleFormElementFactory.php index 7f9b0eb..faf0909 100644 --- a/src/TwbBundle/Form/View/Helper/Factory/TwbBundleFormElementFactory.php +++ b/src/TwbBundle/Form/View/Helper/Factory/TwbBundleFormElementFactory.php @@ -1,6 +1,7 @@ getServiceLocator() ?: $serviceLocator; + } + + $options = $serviceLocator->get('TwbBundle\Options\ModuleOptions'); + return new TwbBundleFormElement($options); } public function __invoke(ContainerInterface $container, $requestedName, array $options = null) @@ -25,4 +31,4 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o $options = $container->get('TwbBundle\Options\ModuleOptions'); return new TwbBundleFormElement($options); } -} +} diff --git a/src/TwbBundle/Module.php b/src/TwbBundle/Module.php new file mode 100644 index 0000000..1793899 --- /dev/null +++ b/src/TwbBundle/Module.php @@ -0,0 +1,25 @@ + array( + realpath(__DIR__.DIRECTORY_SEPARATOR.'/../../autoload_classmap.php') + ) + ); + } + + /** + * @return array + */ + public function getConfig(){ + return include __DIR__.DIRECTORY_SEPARATOR.'/../../config/module.config.php'; + } +} \ No newline at end of file diff --git a/src/TwbBundle/Options/Factory/ModuleOptionsFactory.php b/src/TwbBundle/Options/Factory/ModuleOptionsFactory.php index 28d830c..cd444ad 100644 --- a/src/TwbBundle/Options/Factory/ModuleOptionsFactory.php +++ b/src/TwbBundle/Options/Factory/ModuleOptionsFactory.php @@ -11,7 +11,9 @@ class ModuleOptionsFactory implements FactoryInterface public function createService(ServiceLocatorInterface $serviceLocator) { - return $this($serviceLocator, 'TwbBundle\Options\ModuleOptions'); + $config = $serviceLocator->get('config'); + $options = $config['twbbundle']; + return new ModuleOptions($options); } public function __invoke(ContainerInterface $container, $requestedName, array $options = null) @@ -20,4 +22,4 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o $options = $config['twbbundle']; return new ModuleOptions($options); } -} +} diff --git a/src/TwbBundle/Options/ModuleOptions.php b/src/TwbBundle/Options/ModuleOptions.php index e901724..f491551 100644 --- a/src/TwbBundle/Options/ModuleOptions.php +++ b/src/TwbBundle/Options/ModuleOptions.php @@ -18,7 +18,7 @@ class ModuleOptions extends AbstractOptions /** * Constructor * - * @param array|Traversable|null $options + * @param array|\Traversable|null $options */ public function __construct($options = null) { diff --git a/tests/Bootstrap.php b/tests/Bootstrap.php index db3f89f..7948ec7 100644 --- a/tests/Bootstrap.php +++ b/tests/Bootstrap.php @@ -2,11 +2,7 @@ namespace TwbBundleTest; -use Zend\EventManager\EventManagerAwareInterface; -use Zend\EventManager\EventManagerInterface; use Zend\ServiceManager\ServiceManager; -use Zend\Stdlib\RequestInterface; -use Zend\Stdlib\ResponseInterface; use Zend\Mvc\Service; error_reporting(E_ALL | E_STRICT); @@ -51,7 +47,7 @@ public static function init() { $configuration = static::$config; // Prepare the service manager - $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : []; + $smConfig = isset($configuration['service_manager']) ? $configuration['service_manager'] : array(); $smConfig = new Service\ServiceManagerConfig($smConfig); $serviceManager = new ServiceManager(); @@ -80,7 +76,7 @@ public static function getConfig() { /** * Initialize Autoloader - * @throws RuntimeException + * @throws \RuntimeException */ protected static function initAutoloader() { $sVendorPath = static::findParentPath('vendor'); diff --git a/tests/TestConfig.php.dist b/tests/TestConfig.php.dist index ec82cc1..c5c5218 100644 --- a/tests/TestConfig.php.dist +++ b/tests/TestConfig.php.dist @@ -1,6 +1,7 @@ array( + 'Zend\Router', 'TwbBundle' ), 'module_listener_options' => array(