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

Commit

Permalink
Merge pull request #185 from thomasvargiu/fix/zf2-bis
Browse files Browse the repository at this point in the history
Fix zf2
  • Loading branch information
neilime authored Oct 18, 2016
2 parents 5f8fe83 + f5f39d1 commit 2438ad9
Show file tree
Hide file tree
Showing 10 changed files with 131 additions and 69 deletions.
24 changes: 1 addition & 23 deletions Module.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
<?php
namespace TwbBundle;
class Module implements
\Zend\ModuleManager\Feature\ConfigProviderInterface,
\Zend\ModuleManager\Feature\AutoloaderProviderInterface{

/**
* @see \Zend\ModuleManager\Feature\AutoloaderProviderInterface::getAutoloaderConfig()
* @return array
*/
public function getAutoloaderConfig(){
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__.DIRECTORY_SEPARATOR.'autoload_classmap.php'
)
);
}

/**
* @return array
*/
public function getConfig(){
return include __DIR__.DIRECTORY_SEPARATOR.'config/module.config.php';
}
}
require_once __DIR__ . '/src/TwbBundle/Module.php';
9 changes: 4 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
112 changes: 85 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace TwbBundle\Form\View\Helper\Factory;

use Zend\ServiceManager\AbstractPluginManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use TwbBundle\Form\View\Helper\TwbBundleFormElement;
Expand All @@ -17,12 +18,17 @@ class TwbBundleFormElementFactory implements FactoryInterface

public function createService(ServiceLocatorInterface $serviceLocator)
{
return $this($serviceLocator, 'TwbBundle\Form\View\Helper\TwbBundleFormElement');
if ($serviceLocator instanceof AbstractPluginManager) {
$serviceLocator = $serviceLocator->getServiceLocator() ?: $serviceLocator;
}

$options = $serviceLocator->get('TwbBundle\Options\ModuleOptions');
return new TwbBundleFormElement($options);
}

public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$options = $container->get('TwbBundle\Options\ModuleOptions');
return new TwbBundleFormElement($options);
}
}
}
25 changes: 25 additions & 0 deletions src/TwbBundle/Module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
namespace TwbBundle;
class Module implements
\Zend\ModuleManager\Feature\ConfigProviderInterface,
\Zend\ModuleManager\Feature\AutoloaderProviderInterface{

/**
* @see \Zend\ModuleManager\Feature\AutoloaderProviderInterface::getAutoloaderConfig()
* @return array
*/
public function getAutoloaderConfig(){
return array(
'Zend\Loader\ClassMapAutoloader' => array(
realpath(__DIR__.DIRECTORY_SEPARATOR.'/../../autoload_classmap.php')
)
);
}

/**
* @return array
*/
public function getConfig(){
return include __DIR__.DIRECTORY_SEPARATOR.'/../../config/module.config.php';
}
}
6 changes: 4 additions & 2 deletions src/TwbBundle/Options/Factory/ModuleOptionsFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -20,4 +22,4 @@ public function __invoke(ContainerInterface $container, $requestedName, array $o
$options = $config['twbbundle'];
return new ModuleOptions($options);
}
}
}
2 changes: 1 addition & 1 deletion src/TwbBundle/Options/ModuleOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModuleOptions extends AbstractOptions
/**
* Constructor
*
* @param array|Traversable|null $options
* @param array|\Traversable|null $options
*/
public function __construct($options = null)
{
Expand Down
8 changes: 2 additions & 6 deletions tests/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -80,7 +76,7 @@ public static function getConfig() {

/**
* Initialize Autoloader
* @throws RuntimeException
* @throws \RuntimeException
*/
protected static function initAutoloader() {
$sVendorPath = static::findParentPath('vendor');
Expand Down
Loading

0 comments on commit 2438ad9

Please sign in to comment.