You are here

public function UUIDController::uuidGet in Entity Type Clone 8

File

src/Controller/UUIDController.php, line 15

Class

UUIDController
Class UUIDController.

Namespace

Drupal\entity_type_clone\Controller

Code

public function uuidGet() {
  $uuid = [];
  $entity_type_definations = \Drupal::entityTypeManager()
    ->getDefinitions();
  foreach ($entity_type_definations as $definition) {
    if ($definition instanceof ContentEntityType) {
      $content_types = \Drupal::service('entity_type.bundle.info')
        ->getBundleInfo($definition
        ->id());
      $entity_type = $definition
        ->getBundleEntityType();
      if ($entity_type && $content_types) {
        foreach ($content_types as $type_id => $type) {
          $uuid[$entity_type][$type_id] = \Drupal::entityTypeManager()
            ->getStorage($entity_type)
            ->load($type_id)
            ->uuid();
        }
      }
    }
  }
  return $uuid;
}