class EntityTypeBundleInfo implements EntityTypeBundleInfoInterface (View source)

Provides discovery and retrieval of entity type bundles.

Traits

Provides methods to use a cache backend while respecting a 'use caches' flag.

Properties

protected CacheBackendInterface $cacheBackend

Cache backend instance.

from  UseCacheBackendTrait
protected bool $useCaches

Flag whether caches should be used or skipped.

from  UseCacheBackendTrait
protected array $bundleInfo

Static cache of bundle information.

protected LanguageManagerInterface $languageManager

The language manager.

protected ModuleHandlerInterface $moduleHandler

The module handler.

protected TypedDataManagerInterface $typedDataManager

The typed data manager.

protected EntityTypeManagerInterface $entityTypeManager

The entity type manager.

Methods

object|false
cacheGet(string $cid)

Fetches from the cache backend, respecting the use caches flag.

cacheSet(string $cid, mixed $data, int $expire = Cache::PERMANENT, array $tags = [])

Stores data in the persistent cache, respecting the use caches flag.

__construct(EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, TypedDataManagerInterface $typed_data_manager, CacheBackendInterface $cache_backend)

Constructs a new EntityTypeBundleInfo.

array
getBundleInfo(string $entity_type_id)

Gets the bundle info of an entity type.

array
getAllBundleInfo()

Get the bundle info of all entity types.

clearCachedBundles()

Clears static and persistent bundles.

Details

protected object|false cacheGet(string $cid)

Fetches from the cache backend, respecting the use caches flag.

Parameters

string $cid

The cache ID of the data to retrieve.

Return Value

object|false

The cache item or FALSE on failure.

See also

CacheBackendInterface::get

protected cacheSet(string $cid, mixed $data, int $expire = Cache::PERMANENT, array $tags = [])

Stores data in the persistent cache, respecting the use caches flag.

Parameters

string $cid

The cache ID of the data to store.

mixed $data

The data to store in the cache. Some storage engines only allow objects up to a maximum of 1MB in size to be stored by default. When caching large arrays or similar, take care to ensure $data does not exceed this size.

int $expire

One of the following values:

  • CacheBackendInterface::CACHE_PERMANENT: Indicates that the item should not be removed unless it is deleted explicitly.
  • A Unix timestamp: Indicates that the item will be considered invalid after this time, i.e. it will not be returned by get() unless $allow_invalid has been set to TRUE. When the item has expired, it may be permanently deleted by the garbage collector at any time.
array $tags

An array of tags to be stored with the cache item. These should normally identify objects used to build the cache item, which should trigger cache invalidation when updated. For example if a cached item represents a node, both the node ID and the author's user ID might be passed in as tags. For example array('node' => array(123), 'user' => array(92)).

See also

CacheBackendInterface::set

__construct(EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler, TypedDataManagerInterface $typed_data_manager, CacheBackendInterface $cache_backend)

Constructs a new EntityTypeBundleInfo.

Parameters

EntityTypeManagerInterface $entity_type_manager

The entity type manager.

LanguageManagerInterface $language_manager

The language manager.

ModuleHandlerInterface $module_handler

The module handler.

TypedDataManagerInterface $typed_data_manager

The typed data manager.

CacheBackendInterface $cache_backend

The cache backend.

array getBundleInfo(string $entity_type_id)

Gets the bundle info of an entity type.

Parameters

string $entity_type_id

The entity type ID.

Return Value

array

An array of 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.

array getAllBundleInfo()

Get the bundle info of all entity types.

Return Value

array

An array of bundle information where the outer array is keyed by entity type. The next level is keyed by the bundle name. The inner arrays are associative arrays of bundle information, such as the label for the bundle.

clearCachedBundles()

Clears static and persistent bundles.