|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @link https://github.com/nnx-framework/doctrine |
|
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
|
5
|
|
|
*/ |
|
6
|
|
|
namespace Nnx\Doctrine\Controller; |
|
7
|
|
|
|
|
8
|
|
|
use Zend\Mvc\Controller\AbstractConsoleController; |
|
9
|
|
|
use Zend\Console\Request; |
|
10
|
|
|
use Interop\Container\ContainerInterface; |
|
11
|
|
|
use Zend\View\Model\ConsoleModel; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Class EntityMapBuilderController |
|
15
|
|
|
* |
|
16
|
|
|
* @package Nnx\Doctrine\Controller |
|
17
|
|
|
*/ |
|
18
|
|
|
class EntityMapBuilderController extends AbstractConsoleController |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Менеджер для получения ObjectManager Doctrine2 |
|
22
|
|
|
* |
|
23
|
|
|
* @var ContainerInterface |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $doctrineObjectManager; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* EntityMapBuilderController constructor. |
|
29
|
|
|
* |
|
30
|
|
|
* @param ContainerInterface $doctrineObjectManager |
|
31
|
|
|
*/ |
|
32
|
|
|
public function __construct(ContainerInterface $doctrineObjectManager) |
|
33
|
|
|
{ |
|
34
|
|
|
$this->setDoctrineObjectManager($doctrineObjectManager); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Генерация карты сущностей и сохранение ее в кеше |
|
40
|
|
|
* |
|
41
|
|
|
*/ |
|
42
|
|
|
public function buildAction() |
|
43
|
|
|
{ |
|
44
|
|
|
/** @var Request $request */ |
|
45
|
|
|
$request = $this->getRequest(); |
|
46
|
|
|
$managerName = $request->getParam('objectManager'); |
|
47
|
|
|
|
|
48
|
|
|
if (!$this->getDoctrineObjectManager()->has($managerName)) { |
|
49
|
|
|
return [ |
|
50
|
|
|
ConsoleModel::RESULT => sprintf('Doctrine ObjectManager %s not found', $managerName) |
|
51
|
|
|
]; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
$result = ''; |
|
55
|
|
|
|
|
56
|
|
|
|
|
57
|
|
|
return [ |
|
58
|
|
|
ConsoleModel::RESULT => $result |
|
59
|
|
|
]; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Возвращает менеджер для получения ObjectManager Doctrine2 |
|
64
|
|
|
* |
|
65
|
|
|
* @return ContainerInterface |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getDoctrineObjectManager() |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->doctrineObjectManager; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Устанавливает менеджер для получения ObjectManager Doctrine2 |
|
74
|
|
|
* |
|
75
|
|
|
* @param ContainerInterface $doctrineObjectManager |
|
76
|
|
|
* |
|
77
|
|
|
* @return $this |
|
78
|
|
|
*/ |
|
79
|
|
|
public function setDoctrineObjectManager(ContainerInterface $doctrineObjectManager) |
|
80
|
|
|
{ |
|
81
|
|
|
$this->doctrineObjectManager = $doctrineObjectManager; |
|
82
|
|
|
|
|
83
|
|
|
return $this; |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|