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

Commit

Permalink
Removing registration of abstract service factories within the DiFact…
Browse files Browse the repository at this point in the history
…ory since it will only cause problems with cyclic dependencies
  • Loading branch information
Ocramius committed Aug 16, 2012
1 parent c082164 commit cc2dada
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
1 change: 0 additions & 1 deletion library/Zend/Mvc/Service/AbstractPluginManagerFactory.php
Expand Up @@ -11,7 +11,6 @@
namespace Zend\Mvc\Service;

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

Expand Down
13 changes: 3 additions & 10 deletions library/Zend/Mvc/Service/DiFactory.php
Expand Up @@ -10,12 +10,10 @@

namespace Zend\Mvc\Service;

use Zend\Di\Config as DiConfig;
use Zend\Di\Config;
use Zend\Di\Di;
use Zend\ServiceManager\Di\DiAbstractServiceFactory;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceManager;

/**
* @category Zend
Expand Down Expand Up @@ -43,13 +41,8 @@ public function createService(ServiceLocatorInterface $serviceLocator)
$config = $serviceLocator->get('Config');

if (isset($config['di'])) {
$di->configure(new DiConfig($config['di']));
}

if ($serviceLocator instanceof ServiceManager) {
/* @var $serviceLocator ServiceManager */
//$serviceLocator->addAbstractFactory($serviceLocator->get('DiAbstractServiceFactory'));
//$serviceLocator->addInitializer($serviceLocator->get('DiServiceInitializer'));
$config = new Config($config['di']);
$config->configure($di);
}

return $di;
Expand Down
27 changes: 27 additions & 0 deletions tests/ZendTest/Mvc/Service/DiFactoryTest.php
@@ -0,0 +1,27 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_ServiceManager
*/

namespace ZendTest\Mvc\Service;

use Zend\Mvc\Service\DiFactory;
use Zend\ServiceManager\ServiceManager;

class DiFactoryTest extends \PHPUnit_Framework_TestCase
{
public function testWillInitializeDiAndDiAbstractFactoryAndDiInitializer()
{
$serviceManager = new ServiceManager();
$serviceManager->setService('Config', array('di' => array('')));
$serviceManager->setFactory('Di', new DiFactory());

$di = $serviceManager->get('Di');
$this->assertInstanceOf('Zend\Di\Di', $di);
}
}

0 comments on commit cc2dada

Please sign in to comment.