1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace DoctrineModule; |
4
|
|
|
|
5
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
6
|
|
|
use Zend\ModuleManager\Feature\InitProviderInterface; |
7
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
8
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
9
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
10
|
|
|
use Zend\EventManager\EventInterface; |
11
|
|
|
use Zend\Console\Adapter\AdapterInterface as Console; |
12
|
|
|
|
13
|
|
|
use Symfony\Component\Console\Input\StringInput; |
14
|
|
|
use DoctrineModule\Component\Console\Output\PropertyOutput; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Base module for integration of Doctrine projects with ZF2 applications |
18
|
|
|
* |
19
|
|
|
* @license MIT |
20
|
|
|
* @link http://www.doctrine-project.org/ |
21
|
|
|
* @since 0.1.0 |
22
|
|
|
* @author Kyle Spraggs <[email protected]> |
23
|
|
|
* @author Marco Pivetta <[email protected]> |
24
|
|
|
*/ |
25
|
|
|
class Module implements ConfigProviderInterface, InitProviderInterface, BootstrapListenerInterface |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var \Zend\ServiceManager\ServiceLocatorInterface |
29
|
|
|
*/ |
30
|
|
|
private $serviceManager; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* {@inheritDoc} |
34
|
|
|
*/ |
35
|
30 |
|
public function init(ModuleManagerInterface $moduleManager) |
36
|
|
|
{ |
37
|
30 |
|
AnnotationRegistry::registerLoader( |
|
|
|
|
38
|
30 |
|
function ($className) { |
39
|
|
|
return class_exists($className); |
40
|
30 |
|
} |
41
|
|
|
); |
42
|
30 |
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritDoc} |
46
|
|
|
*/ |
47
|
1 |
|
public function onBootstrap(EventInterface $event) |
48
|
|
|
{ |
49
|
1 |
|
$this->serviceManager = $event->getTarget()->getServiceManager(); |
50
|
1 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
|
|
*/ |
55
|
31 |
|
public function getConfig() |
56
|
|
|
{ |
57
|
31 |
|
$provider = new ConfigProvider(); |
58
|
|
|
return [ |
59
|
31 |
|
'doctrine' => $provider->getDoctrineConfig(), |
60
|
31 |
|
'doctrine_factories' => $provider->getDoctrineFactoryConfig(), |
61
|
31 |
|
'service_manager' => $provider->getDependencyConfig(), |
62
|
31 |
|
'controllers' => $provider->getControllerConfig(), |
63
|
31 |
|
'route_manager' => $provider->getRouteManagerConfig(), |
64
|
31 |
|
'console' => $provider->getConsoleConfig(), |
65
|
31 |
|
'validators' => $provider->getValidatorConfig(), |
66
|
|
|
]; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* {@inheritDoc} |
71
|
|
|
*/ |
72
|
1 |
|
public function getConsoleUsage(Console $console) |
|
|
|
|
73
|
|
|
{ |
74
|
|
|
/* @var $cli \Symfony\Component\Console\Application */ |
75
|
1 |
|
$cli = $this->serviceManager->get('doctrine.cli'); |
76
|
1 |
|
$output = new PropertyOutput(); |
77
|
|
|
|
78
|
1 |
|
$cli->run(new StringInput('list'), $output); |
79
|
|
|
|
80
|
1 |
|
return $output->getMessage(); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.