1 | <?php |
||
27 | class AdminFactory |
||
28 | { |
||
29 | /** |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $admins = []; |
||
33 | |||
34 | /** |
||
35 | * @var bool |
||
36 | */ |
||
37 | protected $isInit = false; |
||
38 | |||
39 | /** |
||
40 | * @var EventDispatcherInterface |
||
41 | */ |
||
42 | protected $eventDispatcher; |
||
43 | |||
44 | /** |
||
45 | * @var EntityManager |
||
46 | */ |
||
47 | protected $entityManager; |
||
48 | |||
49 | /** |
||
50 | * @var ConfigurationFactory |
||
51 | */ |
||
52 | protected $configurationFactory; |
||
53 | |||
54 | /** |
||
55 | * User custom data provider, indexed by service id |
||
56 | * |
||
57 | * @var ParameterBagInterface |
||
58 | */ |
||
59 | protected $dataProviders; |
||
60 | |||
61 | /** |
||
62 | * @var array |
||
63 | */ |
||
64 | protected $adminConfigurations; |
||
65 | |||
66 | /** |
||
67 | * @var ActionFactory |
||
68 | */ |
||
69 | protected $actionFactory; |
||
70 | |||
71 | /** |
||
72 | * @var MessageHandlerInterface |
||
73 | */ |
||
74 | protected $messageHandler; |
||
75 | |||
76 | /** |
||
77 | * AdminFactory constructor. |
||
78 | * |
||
79 | * @param EventDispatcherInterface $eventDispatcher |
||
80 | * @param EntityManager $entityManager |
||
81 | * @param ConfigurationFactory $configurationFactory |
||
82 | * @param array $adminConfigurations |
||
83 | * @param ActionFactory $actionFactory |
||
84 | * @param MessageHandlerInterface $messageHandler |
||
85 | */ |
||
86 | public function __construct( |
||
102 | 6 | ||
103 | /** |
||
104 | * Create admins from configuration and load them into the pool. Dispatch ADMIN_CREATE event. |
||
105 | */ |
||
106 | public function init() |
||
139 | 5 | ||
140 | /** |
||
141 | 5 | * Create an Admin from configuration values. It will be added to AdminFactory admin's list. |
|
142 | * |
||
143 | 5 | * @param string $name |
|
144 | * @param array $configuration |
||
145 | * @return Admin |
||
146 | 5 | * @throws Exception |
|
147 | 5 | */ |
|
148 | 5 | public function create($name, array $configuration) |
|
186 | |||
187 | 1 | /** |
|
188 | * Return an admin from a Symfony request. |
||
189 | * |
||
190 | 1 | * @param Request $request |
|
191 | * @return AdminInterface |
||
192 | * @throws Exception |
||
193 | 1 | */ |
|
194 | public function getAdminFromRequest(Request $request) |
||
211 | 3 | ||
212 | /** |
||
213 | * Return a admin by its name. |
||
214 | 3 | * |
|
215 | * @param $name |
||
216 | * @return Admin |
||
217 | * @throws Exception |
||
218 | */ |
||
219 | public function getAdmin($name) |
||
227 | |||
228 | /** |
||
229 | * Return all admins. |
||
230 | * |
||
231 | * @return Admin[] |
||
232 | */ |
||
233 | 1 | public function getAdmins() |
|
237 | 1 | ||
238 | 1 | /** |
|
239 | * Add user custom repositories (called in the repository compiler pass), to avoid injecting the service container |
||
240 | * |
||
241 | * @param string $name |
||
242 | * @param DataProviderInterface $dataProvider |
||
243 | */ |
||
244 | public function addDataProvider($name, DataProviderInterface $dataProvider) |
||
250 | |||
251 | 5 | /** |
|
252 | * Return a configured data provider or create an new instance of the default one. |
||
253 | * |
||
254 | * @param string $entityClass |
||
255 | * @param string|null $name |
||
256 | * @return DataProvider|mixed |
||
257 | * @throws Exception |
||
258 | */ |
||
259 | protected function getDataProvider($entityClass, $name = null) |
||
288 | } |
||
289 |