You are here

function profile_entity_bundle_info_alter in Profile 8

Implements hook_entity_bundle_info_alter().

File

./profile.module, line 45
Support for configurable user profiles.

Code

function profile_entity_bundle_info_alter(&$bundles) {
  if (empty($bundles['profile'])) {
    return;
  }
  $profile_type_ids = array_keys($bundles['profile']);

  /** @var \Drupal\profile\Entity\ProfileTypeInterface[] $profile_types */
  $profile_types = ProfileType::loadMultiple($profile_type_ids);
  foreach ($bundles['profile'] as $bundle => $info) {
    if (isset($profile_types[$bundle])) {
      $profile_type = $profile_types[$bundle];

      // Bundle info is loaded on most requests. Store the flags inside, so
      // that modules can use them without needing to load the profile type.
      if ($profile_type
        ->allowsMultiple()) {
        $bundles['profile'][$bundle]['multiple'] = TRUE;
      }
      if ($profile_type
        ->showRevisionUi()) {
        $bundles['profile'][$bundle]['revision_ui'] = TRUE;
      }
    }
  }
}