function EntityTestHooks::entityBundleInfo

Implements hook_entity_bundle_info().

Attributes

#[Hook('entity_bundle_info')]

See also

\Drupal\entity_test\EntityTestHelper::createBundle()

\Drupal\entity_test\EntityTestHelper::deleteBundle()

File

core/modules/system/tests/modules/entity_test/src/Hook/EntityTestHooks.php, line 133

Class

EntityTestHooks
Hook implementations for entity_test.

Namespace

Drupal\entity_test\Hook

Code

public function entityBundleInfo() : array {
  $bundles = [];
  $entity_types = \Drupal::entityTypeManager()->getDefinitions();
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type->getProvider() == 'entity_test' && !in_array($entity_type_id, [
      'entity_test_with_bundle',
      'entity_test_mul_with_bundle',
    ], TRUE)) {
      $bundles[$entity_type_id] = \Drupal::state()->get($entity_type_id . '.bundles', [
        $entity_type_id => [
          'label' => 'Entity Test Bundle',
        ],
      ]);
    }
  }
  return $bundles;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.