class EckEntityTypeBundleInfo in Entity Construction Kit (ECK) 8
Holds bundle info for eck entity types.
Hierarchy
- class \Drupal\Core\Entity\EntityTypeBundleInfo implements EntityTypeBundleInfoInterface uses UseCacheBackendTrait
- class \Drupal\eck\EckEntityTypeBundleInfo
Expanded class hierarchy of EckEntityTypeBundleInfo
2 files declare their use of EckEntityTypeBundleInfo
- EckEntityTypeListBuilder.php in src/
Controller/ EckEntityTypeListBuilder.php - EntityTypeBundleInfoTest.php in tests/
src/ Unit/ EntityTypeBundleInfoTest.php
1 string reference to 'EckEntityTypeBundleInfo'
1 service uses EckEntityTypeBundleInfo
File
- src/
EckEntityTypeBundleInfo.php, line 11
Namespace
Drupal\eckView source
class EckEntityTypeBundleInfo extends EntityTypeBundleInfo {
/**
* {@inheritdoc}
*/
public function getAllBundleInfo() {
if (empty($this->bundleInfo)) {
$langCode = $this->languageManager
->getCurrentLanguage()
->getId();
if ($cache = $this
->cacheGet("eck_entity_bundle_info:{$langCode}")) {
$this->bundleInfo = $cache->data;
}
else {
$this->bundleInfo = $this->moduleHandler
->invokeAll('entity_bundle_info');
foreach ($this->entityTypeManager
->getDefinitions() as $type => $entity_type) {
if ($bundle_entity_type = $entity_type
->getBundleEntityType()) {
foreach ($this->entityTypeManager
->getStorage($bundle_entity_type)
->loadMultiple() as $entity) {
$this->bundleInfo[$type][$entity
->id()]['label'] = $entity
->label();
}
}
}
$this->moduleHandler
->alter('entity_bundle_info', $this->bundleInfo);
$this
->cacheSet("eck_entity_bundle_info:{$langCode}", $this->bundleInfo, Cache::PERMANENT, [
'entity_types',
'entity_bundles',
]);
}
}
return $this->bundleInfo;
}
/**
* Determines if a given entity type has bundles.
*
* @param string $entity_type
* The entity type id.
*
* @return bool
* Does it have bundles?
*/
public function entityTypeHasBundles($entity_type) {
return !empty($this
->getBundleInfo($entity_type));
}
/**
* Retrieves the entity type bundle machine names.
*
* @param string $entity_type
* The entity type id.
*
* @return string[]
* The entity type bundle machine names.
*/
public function getEntityTypeBundleMachineNames($entity_type) {
return array_keys($this
->getBundleInfo($entity_type));
}
/**
* The entity type bundle count.
*
* @param string $entity_type
* The entity type id.
*
* @return int
* The number of bundles for the given entity type.
*/
public function entityTypeBundleCount($entity_type) {
return \count($this
->getBundleInfo($entity_type));
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EckEntityTypeBundleInfo:: |
public | function | The entity type bundle count. | |
EckEntityTypeBundleInfo:: |
public | function | Determines if a given entity type has bundles. | |
EckEntityTypeBundleInfo:: |
public | function |
Get the bundle info of all entity types. Overrides EntityTypeBundleInfo:: |
|
EckEntityTypeBundleInfo:: |
public | function | Retrieves the entity type bundle machine names. | |
EntityTypeBundleInfo:: |
protected | property | Static cache of bundle information. | |
EntityTypeBundleInfo:: |
protected | property | The entity type manager. | |
EntityTypeBundleInfo:: |
protected | property | The language manager. | |
EntityTypeBundleInfo:: |
protected | property | The module handler. | |
EntityTypeBundleInfo:: |
protected | property | The typed data manager. | |
EntityTypeBundleInfo:: |
public | function |
Clears static and persistent bundles. Overrides EntityTypeBundleInfoInterface:: |
|
EntityTypeBundleInfo:: |
public | function |
Gets the bundle info of an entity type. Overrides EntityTypeBundleInfoInterface:: |
|
EntityTypeBundleInfo:: |
public | function | Constructs a new EntityTypeBundleInfo. | |
UseCacheBackendTrait:: |
protected | property | Cache backend instance. | |
UseCacheBackendTrait:: |
protected | property | Flag whether caches should be used or skipped. | |
UseCacheBackendTrait:: |
protected | function | Fetches from the cache backend, respecting the use caches flag. | 1 |
UseCacheBackendTrait:: |
protected | function | Stores data in the persistent cache, respecting the use caches flag. |