fa2ddf8c7922e2a3ddfecf4e9a9f62ac3306ad4f
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityManager.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 use Drupal\Core\Field\FieldDefinitionInterface;
6 use Drupal\Core\Field\FieldStorageDefinitionInterface;
7 use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8 use Symfony\Component\DependencyInjection\ContainerAwareTrait;
9
10 /**
11  * Provides a wrapper around many other services relating to entities.
12  *
13  * Deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0. We cannot
14  * use the deprecated PHPDoc tag because this service class is still used in
15  * legacy code paths. Symfony would fail test cases with deprecation warnings.
16  *
17  * @todo Enforce the deprecation of each method once
18  *   https://www.drupal.org/node/2578361 is in.
19  */
20 class EntityManager implements EntityManagerInterface, ContainerAwareInterface {
21
22   use ContainerAwareTrait;
23
24   /**
25    * {@inheritdoc}
26    *
27    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
28    */
29   public function clearCachedDefinitions() {
30     $this->container->get('entity_type.manager')->clearCachedDefinitions();
31
32     // @todo None of these are plugin managers, and they should not co-opt
33     //   this method for managing its caches. Remove in
34     //   https://www.drupal.org/node/2549143.
35     $this->container->get('entity_type.bundle.info')->clearCachedBundles();
36     $this->container->get('entity_field.manager')->clearCachedFieldDefinitions();
37     $this->container->get('entity_type.repository')->clearCachedDefinitions();
38   }
39
40   /**
41    * {@inheritdoc}
42    *
43    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
44    */
45   public function getDefinition($entity_type_id, $exception_on_invalid = TRUE) {
46     return $this->container->get('entity_type.manager')->getDefinition($entity_type_id, $exception_on_invalid);
47   }
48
49   /**
50    * {@inheritdoc}
51    *
52    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
53    */
54   public function hasHandler($entity_type, $handler_type) {
55     return $this->container->get('entity_type.manager')->hasHandler($entity_type, $handler_type);
56   }
57
58   /**
59    * {@inheritdoc}
60    *
61    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
62    */
63   public function getStorage($entity_type) {
64     return $this->container->get('entity_type.manager')->getStorage($entity_type);
65   }
66
67   /**
68    * {@inheritdoc}
69    *
70    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
71    */
72   public function getListBuilder($entity_type) {
73     return $this->container->get('entity_type.manager')->getListBuilder($entity_type);
74   }
75
76   /**
77    * {@inheritdoc}
78    *
79    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
80    */
81   public function getFormObject($entity_type, $operation) {
82     return $this->container->get('entity_type.manager')->getFormObject($entity_type, $operation);
83   }
84
85   /**
86    * {@inheritdoc}
87    *
88    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
89    */
90   public function getRouteProviders($entity_type) {
91     return $this->container->get('entity_type.manager')->getRouteProviders($entity_type);
92   }
93
94   /**
95    * {@inheritdoc}
96    *
97    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
98    */
99   public function getViewBuilder($entity_type) {
100     return $this->container->get('entity_type.manager')->getViewBuilder($entity_type);
101   }
102
103   /**
104    * {@inheritdoc}
105    *
106    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
107    */
108   public function getAccessControlHandler($entity_type) {
109     return $this->container->get('entity_type.manager')->getAccessControlHandler($entity_type);
110   }
111
112   /**
113    * {@inheritdoc}
114    *
115    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
116    */
117   public function getHandler($entity_type, $handler_type) {
118     return $this->container->get('entity_type.manager')->getHandler($entity_type, $handler_type);
119   }
120
121   /**
122    * {@inheritdoc}
123    *
124    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
125    */
126   public function createHandlerInstance($class, EntityTypeInterface $definition = NULL) {
127     return $this->container->get('entity_type.manager')->createHandlerInstance($class, $definition);
128   }
129
130   /**
131    * {@inheritdoc}
132    *
133    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
134    */
135   public function getBaseFieldDefinitions($entity_type_id) {
136     return $this->container->get('entity_field.manager')->getBaseFieldDefinitions($entity_type_id);
137   }
138
139   /**
140    * {@inheritdoc}
141    *
142    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
143    */
144   public function getFieldDefinitions($entity_type_id, $bundle) {
145     return $this->container->get('entity_field.manager')->getFieldDefinitions($entity_type_id, $bundle);
146   }
147
148   /**
149    * {@inheritdoc}
150    *
151    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
152    */
153   public function getFieldStorageDefinitions($entity_type_id) {
154     return $this->container->get('entity_field.manager')->getFieldStorageDefinitions($entity_type_id);
155   }
156
157   /**
158    * {@inheritdoc}
159    *
160    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
161    */
162   public function setFieldMap(array $field_map) {
163     return $this->container->get('entity_field.manager')->setFieldMap($field_map);
164   }
165
166   /**
167    * {@inheritdoc}
168    *
169    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
170    */
171   public function getFieldMap() {
172     return $this->container->get('entity_field.manager')->getFieldMap();
173   }
174
175   /**
176    * {@inheritdoc}
177    *
178    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
179    */
180   public function getFieldMapByFieldType($field_type) {
181     return $this->container->get('entity_field.manager')->getFieldMapByFieldType($field_type);
182   }
183
184   /**
185    * {@inheritdoc}
186    *
187    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
188    */
189   public function onFieldDefinitionCreate(FieldDefinitionInterface $field_definition) {
190     $this->container->get('field_definition.listener')->onFieldDefinitionCreate($field_definition);
191   }
192
193   /**
194    * {@inheritdoc}
195    *
196    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
197    */
198   public function onFieldDefinitionUpdate(FieldDefinitionInterface $field_definition, FieldDefinitionInterface $original) {
199     $this->container->get('field_definition.listener')->onFieldDefinitionUpdate($field_definition, $original);
200   }
201
202   /**
203    * {@inheritdoc}
204    *
205    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
206    */
207   public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition) {
208     $this->container->get('field_definition.listener')->onFieldDefinitionDelete($field_definition);
209   }
210
211   /**
212    * {@inheritdoc}
213    *
214    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
215    */
216   public function clearCachedFieldDefinitions() {
217     $this->container->get('entity_field.manager')->clearCachedFieldDefinitions();
218   }
219
220   /**
221    * {@inheritdoc}
222    *
223    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
224    */
225   public function clearCachedBundles() {
226     $this->container->get('entity_type.bundle.info')->clearCachedBundles();
227   }
228
229   /**
230    * {@inheritdoc}
231    *
232    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
233    */
234   public function getBundleInfo($entity_type) {
235     return $this->container->get('entity_type.bundle.info')->getBundleInfo($entity_type);
236   }
237
238   /**
239    * {@inheritdoc}
240    *
241    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
242    */
243   public function getAllBundleInfo() {
244     return $this->container->get('entity_type.bundle.info')->getAllBundleInfo();
245   }
246
247   /**
248    * {@inheritdoc}
249    */
250   public function getExtraFields($entity_type_id, $bundle) {
251     return $this->container->get('entity_field.manager')->getExtraFields($entity_type_id, $bundle);
252   }
253
254   /**
255    * {@inheritdoc}
256    *
257    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
258    */
259   public function getEntityTypeLabels($group = FALSE) {
260     return $this->container->get('entity_type.repository')->getEntityTypeLabels($group);
261   }
262
263   /**
264    * {@inheritdoc}
265    *
266    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
267    */
268   public function getTranslationFromContext(EntityInterface $entity, $langcode = NULL, $context = []) {
269     return $this->container->get('entity.repository')->getTranslationFromContext($entity, $langcode, $context);
270   }
271
272   /**
273    * {@inheritdoc}
274    *
275    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
276    */
277   public function getAllViewModes() {
278     return $this->container->get('entity_display.repository')->getAllViewModes();
279   }
280
281   /**
282    * {@inheritdoc}
283    *
284    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
285    */
286   public function getViewModes($entity_type_id) {
287     return $this->container->get('entity_display.repository')->getViewModes($entity_type_id);
288   }
289
290   /**
291    * {@inheritdoc}
292    *
293    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
294    */
295   public function getAllFormModes() {
296     return $this->container->get('entity_display.repository')->getAllFormModes();
297   }
298
299   /**
300    * {@inheritdoc}
301    *
302    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
303    */
304   public function getFormModes($entity_type_id) {
305     return $this->container->get('entity_display.repository')->getFormModes($entity_type_id);
306   }
307
308   /**
309    * {@inheritdoc}
310    *
311    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
312    */
313   public function getViewModeOptions($entity_type_id) {
314     return $this->container->get('entity_display.repository')->getViewModeOptions($entity_type_id);
315   }
316
317   /**
318    * {@inheritdoc}
319    *
320    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
321    */
322   public function getFormModeOptions($entity_type_id) {
323     return $this->container->get('entity_display.repository')->getFormModeOptions($entity_type_id);
324   }
325
326   /**
327    * {@inheritdoc}
328    *
329    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
330    */
331   public function getViewModeOptionsByBundle($entity_type_id, $bundle) {
332     return $this->container->get('entity_display.repository')->getViewModeOptionsByBundle($entity_type_id, $bundle);
333   }
334
335   /**
336    * {@inheritdoc}
337    *
338    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
339    */
340   public function getFormModeOptionsByBundle($entity_type_id, $bundle) {
341     return $this->container->get('entity_display.repository')->getFormModeOptionsByBundle($entity_type_id, $bundle);
342   }
343
344   /**
345    * {@inheritdoc}
346    *
347    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
348    */
349   public function clearDisplayModeInfo() {
350     $this->container->get('entity_display.repository')->clearDisplayModeInfo();
351   }
352
353   /**
354    * {@inheritdoc}
355    *
356    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
357    */
358   public function loadEntityByUuid($entity_type_id, $uuid) {
359     return $this->container->get('entity.repository')->loadEntityByUuid($entity_type_id, $uuid);
360   }
361
362   /**
363    * {@inheritdoc}
364    *
365    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
366    */
367   public function loadEntityByConfigTarget($entity_type_id, $target) {
368     return $this->container->get('entity.repository')->loadEntityByConfigTarget($entity_type_id, $target);
369   }
370
371   /**
372    * {@inheritdoc}
373    *
374    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
375    */
376   public function getEntityTypeFromClass($class_name) {
377     return $this->container->get('entity_type.repository')->getEntityTypeFromClass($class_name);
378   }
379
380   /**
381    * {@inheritdoc}
382    */
383   public function onEntityTypeCreate(EntityTypeInterface $entity_type) {
384     $this->container->get('entity_type.listener')->onEntityTypeCreate($entity_type);
385   }
386
387   /**
388    * {@inheritdoc}
389    *
390    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
391    */
392   public function onEntityTypeUpdate(EntityTypeInterface $entity_type, EntityTypeInterface $original) {
393     $this->container->get('entity_type.listener')->onEntityTypeUpdate($entity_type, $original);
394   }
395
396   /**
397    * {@inheritdoc}
398    *
399    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
400    */
401   public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
402     $this->container->get('entity_type.listener')->onEntityTypeDelete($entity_type);
403   }
404
405   /**
406    * {@inheritdoc}
407    *
408    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
409    */
410   public function onFieldStorageDefinitionCreate(FieldStorageDefinitionInterface $storage_definition) {
411     $this->container->get('field_storage_definition.listener')->onFieldStorageDefinitionCreate($storage_definition);
412   }
413
414   /**
415    * {@inheritdoc}
416    *
417    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
418    */
419   public function onFieldStorageDefinitionUpdate(FieldStorageDefinitionInterface $storage_definition, FieldStorageDefinitionInterface $original) {
420     $this->container->get('field_storage_definition.listener')->onFieldStorageDefinitionUpdate($storage_definition, $original);
421   }
422
423   /**
424    * {@inheritdoc}
425    *
426    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
427    */
428   public function onFieldStorageDefinitionDelete(FieldStorageDefinitionInterface $storage_definition) {
429     $this->container->get('field_storage_definition.listener')->onFieldStorageDefinitionDelete($storage_definition);
430   }
431
432   /**
433    * {@inheritdoc}
434    *
435    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
436    */
437   public function onBundleCreate($bundle, $entity_type_id) {
438     $this->container->get('entity_bundle.listener')->onBundleCreate($bundle, $entity_type_id);
439   }
440
441   /**
442    * {@inheritdoc}
443    *
444    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
445    */
446   public function onBundleDelete($bundle, $entity_type_id) {
447     $this->container->get('entity_bundle.listener')->onBundleDelete($bundle, $entity_type_id);
448   }
449
450   /**
451    * {@inheritdoc}
452    *
453    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
454    */
455   public function getLastInstalledDefinition($entity_type_id) {
456     return $this->container->get('entity.last_installed_schema.repository')->getLastInstalledDefinition($entity_type_id);
457   }
458
459   /**
460    * {@inheritdoc}
461    */
462   public function useCaches($use_caches = FALSE) {
463     $this->container->get('entity_type.manager')->useCaches($use_caches);
464
465     // @todo EntityFieldManager is not a plugin manager, and should not co-opt
466     //   this method for managing its caches.
467     $this->container->get('entity_field.manager')->useCaches($use_caches);
468   }
469
470   /**
471    * {@inheritdoc}
472    *
473    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
474    */
475   public function getLastInstalledFieldStorageDefinitions($entity_type_id) {
476     return $this->container->get('entity.last_installed_schema.repository')->getLastInstalledFieldStorageDefinitions($entity_type_id);
477   }
478
479   /**
480    * {@inheritdoc}
481    *
482    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
483    */
484   public function getDefinitions() {
485     return $this->container->get('entity_type.manager')->getDefinitions();
486   }
487
488   /**
489    * {@inheritdoc}
490    *
491    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
492    */
493   public function hasDefinition($plugin_id) {
494     return $this->container->get('entity_type.manager')->hasDefinition($plugin_id);
495   }
496
497   /**
498    * {@inheritdoc}
499    *
500    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
501    */
502   public function createInstance($plugin_id, array $configuration = []) {
503     return $this->container->get('entity_type.manager')->createInstance($plugin_id, $configuration);
504   }
505
506   /**
507    * {@inheritdoc}
508    *
509    * @deprecated in Drupal 8.0.0, will be removed before Drupal 9.0.0.
510    */
511   public function getInstance(array $options) {
512     return $this->container->get('entity_type.manager')->getInstance($options);
513   }
514
515 }