Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / entity.module
1 <?php
2
3 /**
4  * @file
5  * Provides expanded entity APIs.
6  */
7
8 use Drupal\Core\Entity\EntityTypeInterface;
9 use Drupal\entity\BundlePlugin\BundlePluginHandler;
10
11 /**
12  * Gets the entity types which use bundle plugins.
13  *
14  * @return \Drupal\Core\Entity\EntityTypeInterface[]
15  *   The entity types.
16  */
17 function entity_get_bundle_plugin_entity_types() {
18   $entity_types = \Drupal::entityTypeManager()->getDefinitions();
19   $entity_types = array_filter($entity_types, function (EntityTypeInterface $entity_type) {
20     return $entity_type->hasHandlerClass('bundle_plugin');
21   });
22
23   return $entity_types;
24 }
25
26 /**
27  * Implements hook_entity_type_build().
28  */
29 function entity_entity_type_build(array &$entity_types) {
30   foreach ($entity_types as $entity_type) {
31     if ($entity_type->get('bundle_plugin_type')) {
32       $entity_type->setHandlerClass('bundle_plugin', BundlePluginHandler::class);
33     }
34   }
35 }
36
37 /**
38  * Implements hook_entity_bundle_info().
39  */
40 function entity_entity_bundle_info() {
41   $bundles = [];
42   foreach (entity_get_bundle_plugin_entity_types() as $entity_type) {
43     /** @var \Drupal\entity\BundlePlugin\BundlePluginHandler $bundle_handler */
44     $bundle_handler = \Drupal::entityTypeManager()->getHandler($entity_type->id(), 'bundle_plugin');
45     $bundles[$entity_type->id()] = $bundle_handler->getBundleInfo();
46   }
47   return $bundles;
48 }
49
50 /**
51  * Implements hook_entity_field_storage_info().
52  */
53 function entity_entity_field_storage_info(EntityTypeInterface $entity_type) {
54   if ($entity_type->hasHandlerClass('bundle_plugin')) {
55     /** @var \Drupal\entity\BundlePlugin\BundlePluginHandler $bundle_handler */
56     $bundle_handler = \Drupal::entityTypeManager()->getHandler($entity_type->id(), 'bundle_plugin');
57     return $bundle_handler->getFieldStorageDefinitions();
58   }
59 }
60
61 /**
62  * Implements hook_entity_bundle_field_info().
63  */
64 function entity_entity_bundle_field_info(EntityTypeInterface $entity_type, $bundle) {
65   if ($entity_type->hasHandlerClass('bundle_plugin')) {
66     /** @var \Drupal\entity\BundlePlugin\BundlePluginHandler $bundle_handler */
67     $bundle_handler = \Drupal::entityTypeManager()->getHandler($entity_type->id(), 'bundle_plugin');
68     return $bundle_handler->getFieldDefinitions($bundle);
69   }
70 }
71
72 /**
73  * Implements hook_modules_installed().
74  */
75 function entity_modules_installed($modules) {
76   foreach (entity_get_bundle_plugin_entity_types() as $entity_type) {
77     \Drupal::service('entity.bundle_plugin_installer')->installBundles($entity_type, $modules);
78   }
79 }
80
81 /**
82  * Implements hook_module_preuninstall().
83  */
84 function entity_module_preuninstall($module) {
85   foreach (entity_get_bundle_plugin_entity_types() as $entity_type) {
86     \Drupal::service('entity.bundle_plugin_installer')->uninstallBundles($entity_type, [$module]);
87   }
88 }