Skip to content

Commit

Permalink
Merge remote-tracking branch 'SocalNick/hotfix/di-plugin-managers'
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanDotPro committed Jul 5, 2012
2 parents 93798d3 + 1539eb7 commit 4040563
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 15 deletions.
64 changes: 64 additions & 0 deletions library/Zend/Mvc/Service/AbstractPluginManagerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php
/**
* Zend Framework
*
* LICENSE
*
* This source file is subject to the new BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://framework.zend.com/license/new-bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to [email protected] so we can send you a copy immediately.
*
* @category Zend
* @package Zend_Mvc
* @subpackage Service
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Mvc\Service;

use Zend\ServiceManager\Di\DiAbstractServiceFactory;
use Zend\ServiceManager\Di\DiServiceInitializer;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

/**
* @category Zend
* @package Zend_Mvc
* @subpackage Service
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
abstract class AbstractPluginManagerFactory implements FactoryInterface
{
const PLUGIN_MANAGER_CLASS = 'AbstractPluginManager';

/**
* Create and return a plugin manager.
* Classes that extend this should provide a valid class for
* the PLUGIN_MANGER_CLASS constant.
*
* @param ServiceLocatorInterface $serviceLocator
* @return AbstractPluginManager
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
$plugins = new $pluginManagerClass;
$configuration = $serviceLocator->get('Configuration');
if (isset($configuration['di']) && $serviceLocator->has('Di')) {
$di = $serviceLocator->get('Di');
$plugins->addAbstractFactory(
new DiAbstractServiceFactory($di, DiAbstractServiceFactory::USE_SL_BEFORE_DI)
);
$plugins->addInitializer(
new DiServiceInitializer($di, $serviceLocator)
);
}
return $plugins;
}
}
13 changes: 4 additions & 9 deletions library/Zend/Mvc/Service/ControllerPluginManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@

namespace Zend\Mvc\Service;

use Zend\Mvc\Controller\PluginManager as ControllerPluginManager;
use Zend\Mvc\Exception;
use Zend\ServiceManager\ConfigurationInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;
use Zend\ServiceManager\ServiceManagerAwareInterface;

/**
* @category Zend
Expand All @@ -36,8 +30,10 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ControllerPluginManagerFactory implements FactoryInterface
class ControllerPluginManagerFactory extends AbstractPluginManagerFactory
{
const PLUGIN_MANAGER_CLASS = 'Zend\Mvc\Controller\PluginManager';

/**
* Create and return the MVC controller plugin manager
*
Expand All @@ -46,8 +42,7 @@ class ControllerPluginManagerFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$plugins = new ControllerPluginManager();
$plugins->setServiceLocator($serviceLocator);
$plugins = parent::createService($serviceLocator);
return $plugins;
}
}
10 changes: 4 additions & 6 deletions library/Zend/Mvc/Service/ViewHelperManagerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@

use Zend\Mvc\Exception;
use Zend\Mvc\Router\RouteMatch;
use Zend\View\HelperPluginManager as ViewHelperManager;
use Zend\View\Helper as ViewHelper;
use Zend\ServiceManager\ConfigurationInterface;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;

/**
* @category Zend
Expand All @@ -37,8 +34,10 @@
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
class ViewHelperManagerFactory implements FactoryInterface
class ViewHelperManagerFactory extends AbstractPluginManagerFactory
{
const PLUGIN_MANAGER_CLASS = 'Zend\View\HelperPluginManager';

/**
* An array of helper configuration classes to ensure are on the helper_map stack.
*
Expand All @@ -58,8 +57,7 @@ class ViewHelperManagerFactory implements FactoryInterface
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$plugins = new ViewHelperManager();
$plugins->setServiceLocator($serviceLocator);
$plugins = parent::createService($serviceLocator);

foreach ($this->defaultHelperMapClasses as $configClass) {
if (is_string($configClass) && class_exists($configClass)) {
Expand Down

0 comments on commit 4040563

Please sign in to comment.