ItemViewBuilder
class ItemViewBuilder extends EntityViewBuilder (View source)
View builder handler for aggregator feed items.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Provides dependency injection friendly methods for serialization.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected array | $_serviceIds | An array of service IDs keyed by property name used for serialization. |
from DependencySerializationTrait |
| protected array | $_entityStorages | An array of entity type IDs keyed by the property name of their storages. |
from DependencySerializationTrait |
| protected ModuleHandlerInterface | $moduleHandler | The module handler to invoke hooks on. |
from EntityHandlerBase |
| protected string | $entityTypeId | The type of entities for which this view builder is instantiated. |
from EntityViewBuilder |
| protected EntityTypeInterface | $entityType | Information about the entity type. |
from EntityViewBuilder |
| protected EntityRepositoryInterface | $entityRepository | The entity repository service. |
from EntityViewBuilder |
| protected EntityDisplayRepositoryInterface | $entityDisplayRepository | The entity display repository. |
from EntityViewBuilder |
| protected string | $cacheBin | The cache bin used to store the render cache. |
from EntityViewBuilder |
| protected LanguageManagerInterface | $languageManager | The language manager. |
from EntityViewBuilder |
| protected Registry | $themeRegistry | The theme registry. |
from EntityViewBuilder |
| protected EntityViewDisplayInterface[] | $singleFieldDisplays | The EntityViewDisplay objects created for individual field rendering. |
from EntityViewBuilder |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Constructs a new EntityViewBuilder.
Instantiates a new instance of this entity handler.
Builds the render array for the provided entity.
Lists the trusted callbacks provided by the implementing class.
Builds the render array for the provided entities.
Provides entity-specific defaults to the build process.
Builds multiple entities' views; augments entity defaults.
Builds the component fields and properties of a set of entities.
Specific per-entity building.
Determines whether the view mode is cacheable.
Builds a renderable array for the value of a single field in an entity.
Builds a renderable array for a single field item.
Gets an EntityViewDisplay for rendering an individual field.
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__sleep()
{@inheritdoc}
__wakeup()
{@inheritdoc}
protected ModuleHandlerInterface
moduleHandler()
Gets the module handler.
$this
setModuleHandler(ModuleHandlerInterface $module_handler)
Sets the module handler for this handler.
__construct(EntityTypeInterface $entity_type, EntityRepositoryInterface $entity_repository, LanguageManagerInterface $language_manager, Registry $theme_registry, EntityDisplayRepositoryInterface $entity_display_repository)
Constructs a new EntityViewBuilder.
static EntityHandlerInterface
createInstance(ContainerInterface $container, EntityTypeInterface $entity_type)
Instantiates a new instance of this entity handler.
This is a factory method that returns a new instance of this object. The factory should pass any needed dependencies into the constructor of this object, but not the container itself. Every call to this method must return a new instance of this object; that is, it may not implement a singleton.
array
view(EntityInterface $entity, string $view_mode = 'full', string $langcode = NULL)
Builds the render array for the provided entity.
static string[]
trustedCallbacks()
Lists the trusted callbacks provided by the implementing class.
Trusted callbacks are public methods on the implementing class and can be invoked via \Drupal\Core\Security\DoTrustedCallbackTrait::doTrustedCallback().
A
viewMultiple(array $entities = [], string $view_mode = 'full', string $langcode = NULL)
Builds the render array for the provided entities.
protected array
getBuildDefaults(EntityInterface $entity, string $view_mode)
Provides entity-specific defaults to the build process.
array
build(array $build)
Builds an entity's view; augments entity defaults.
This function is assigned as a #pre_render callback in ::view().
It transforms the renderable array for a single entity to the same structure as if we were rendering multiple entities, and then calls the default ::buildMultiple() #pre_render callback.
array
buildMultiple(array $build_list)
Builds multiple entities' views; augments entity defaults.
This function is assigned as a #pre_render callback in ::viewMultiple().
By delaying the building of an entity until the #pre_render processing in \Drupal::service('renderer')->render(), the processing cost of assembling an entity's renderable array is saved on cache-hit requests.
buildComponents(array $build, array $entities, array $displays, string $view_mode)
Builds the component fields and properties of a set of entities.
protected
addContextualLinks(array $build, EntityInterface $entity)
Add contextual links.
protected
alterBuild(array $build, EntityInterface $entity, EntityViewDisplayInterface $display, string $view_mode)
Specific per-entity building.
array
getCacheTags()
The cache tag associated with this entity view builder.
An entity view builder is instantiated on a per-entity type basis, so the cache tags are also per-entity type.
resetCache(array $entities = NULL)
Resets the entity render cache.
protected bool
isViewModeCacheable(string $view_mode)
Determines whether the view mode is cacheable.
array
viewField(FieldItemListInterface $items, string|array $display_options = [])
Builds a renderable array for the value of a single field in an entity.
The resulting output is a fully themed field with label and multiple values.
This function can be used by third-party modules that need to output an isolated field.
- Do not use inside node (or any other entity) templates; use render($content[FIELD_NAME]) instead.
- The FieldItemInterface::view() method can be used to output a single formatted field value, without label or wrapping field markup.
The function takes care of invoking the prepare_view steps. It also respects field access permissions.
array
viewFieldItem(FieldItemInterface $item, $display = [])
Builds a renderable array for a single field item.
protected EntityViewDisplayInterface
getSingleFieldDisplay(EntityInterface $entity, string $field_name, string|array $display_options)
Gets an EntityViewDisplay for rendering an individual field.