You are here

public function BackgroundImageManager::getEnabledEntityTypeBundles in Background Image 8

Same name and namespace in other branches
  1. 2.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getEnabledEntityTypeBundles()
  2. 2.0.x src/BackgroundImageManager.php \Drupal\background_image\BackgroundImageManager::getEnabledEntityTypeBundles()

Retrieves the enabled bundles for an entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entity_type: An EntityTypeInterface object.

Return value

array An array of enabled bundle information where the outer array is keyed by the bundle name, or the entity type name if the entity does not have bundles. The inner arrays are associative arrays of bundle information, such as the label for the bundle.

Overrides BackgroundImageManagerInterface::getEnabledEntityTypeBundles

3 calls to BackgroundImageManager::getEnabledEntityTypeBundles()
BackgroundImageManager::getEnabledEntityTypes in src/BackgroundImageManager.php
Retrieves the enabled entity types.
BackgroundImageManager::getEntityBundleLabel in src/BackgroundImageManager.php
Retrieves the bundle label for a given entity.
BackgroundImageManager::validEntity in src/BackgroundImageManager.php
Checks whether an entity can use background images.

File

src/BackgroundImageManager.php, line 408

Class

BackgroundImageManager

Namespace

Drupal\background_image

Code

public function getEnabledEntityTypeBundles(EntityTypeInterface $entity_type) {
  $enabled = $this
    ->getEntityConfigArray($entity_type, NULL, 'enable');
  $bundles = $this
    ->getEntityTypeBundles($entity_type);
  if (empty($enabled[$entity_type
    ->id()]) || !$bundles) {
    return [];
  }
  return array_intersect_key($bundles, $enabled[$entity_type
    ->id()]);
}