|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
4
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
5
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
|
6
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
|
7
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
8
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
9
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
10
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
|
11
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
|
12
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
|
13
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
14
|
|
|
* |
|
15
|
|
|
* This software consists of voluntary contributions made by many individuals |
|
16
|
|
|
* and is licensed under the MIT license. For more information, see |
|
17
|
|
|
* <http://www.doctrine-project.org>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace DoctrineORMModuleTest\Util; |
|
21
|
|
|
|
|
22
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
|
23
|
|
|
use Zend\Mvc\Service\ServiceManagerConfig; |
|
24
|
|
|
use Zend\ServiceManager\ServiceManager; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Utility used to retrieve a freshly bootstrapped application's service manager |
|
28
|
|
|
* |
|
29
|
|
|
* @license MIT |
|
30
|
|
|
* @link http://www.doctrine-project.org/ |
|
31
|
|
|
* @author Marco Pivetta <[email protected]> |
|
32
|
|
|
*/ |
|
33
|
|
|
class ServiceManagerFactory |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @return array |
|
37
|
|
|
*/ |
|
38
|
|
|
protected static function getConfiguration() |
|
39
|
|
|
{ |
|
40
|
|
|
return include __DIR__ . '/../TestConfiguration.php'; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* Builds a new service manager |
|
45
|
|
|
* |
|
46
|
|
|
* @param array $configuration |
|
47
|
|
|
* @return ServiceManager |
|
48
|
|
|
*/ |
|
49
|
|
|
public static function getServiceManager(array $configuration = []) |
|
50
|
|
|
{ |
|
51
|
|
|
$configuration = $configuration ?: static::getConfiguration(); |
|
52
|
|
|
$serviceManager = new ServiceManager(); |
|
53
|
|
|
$serviceManagerConfig = new ServiceManagerConfig( |
|
54
|
|
|
isset($configuration['service_manager']) ? $configuration['service_manager'] : [] |
|
55
|
|
|
); |
|
56
|
|
|
$serviceManagerConfig->configureServiceManager($serviceManager); |
|
57
|
|
|
$serviceManager->setService('ApplicationConfig', $configuration); |
|
58
|
|
|
|
|
59
|
|
|
/** @var $moduleManager ModuleManagerInterface */ |
|
60
|
|
|
$moduleManager = $serviceManager->get('ModuleManager'); |
|
61
|
|
|
$moduleManager->loadModules(); |
|
62
|
|
|
|
|
63
|
|
|
return $serviceManager; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|