Permalink
Browse files

Removing registration of abstract service factories within the DiFact…

…ory since it will only cause problems with cyclic dependencies
  • Loading branch information...
1 parent c082164 commit cc2dadaa6d9517aba481a3b1e4dd58cac77e4ea4 @Ocramius Ocramius committed Aug 16, 2012
@@ -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;
@@ -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
@@ -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;
@@ -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.