Drupal 8  8.0.2
BlockViewBuilder Class Reference
Inheritance diagram for BlockViewBuilder:

Public Member Functions

 __construct (EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, ModuleHandlerInterface $module_handler)
 
 buildComponents (array &$build, array $entities, array $displays, $view_mode)
 
 view (EntityInterface $entity, $view_mode= 'full', $langcode=NULL)
 
- Public Member Functions inherited from EntityViewBuilder
 __construct (EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager)
 
 view (EntityInterface $entity, $view_mode= 'full', $langcode=NULL)
 
 viewMultiple (array $entities=array(), $view_mode= 'full', $langcode=NULL)
 
 build (array $build)
 
 buildMultiple (array $build_list)
 
 buildComponents (array &$build, array $entities, array $displays, $view_mode)
 
 getCacheTags ()
 
 resetCache (array $entities=NULL)
 
 viewField (FieldItemListInterface $items, $display_options=array())
 
 viewFieldItem (FieldItemInterface $item, $display=array())
 
- Public Member Functions inherited from EntityHandlerBase
 setModuleHandler (ModuleHandlerInterface $module_handler)
 

Static Public Member Functions

static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 
static lazyBuilder ($entity_id, $view_mode)
 
static preRender ($build)
 
- Static Public Member Functions inherited from EntityViewBuilder
static createInstance (ContainerInterface $container, EntityTypeInterface $entity_type)
 

Static Protected Member Functions

static buildPreRenderableBlock ($entity, ModuleHandlerInterface $module_handler)
 

Protected Attributes

 $moduleHandler
 
- Protected Attributes inherited from EntityViewBuilder
 $entityTypeId
 
 $entityType
 
 $entityManager
 
 $cacheBin = 'render'
 
 $languageManager
 
 $singleFieldDisplays
 
- Protected Attributes inherited from EntityHandlerBase
 $moduleHandler
 

Additional Inherited Members

- Protected Member Functions inherited from EntityViewBuilder
 getBuildDefaults (EntityInterface $entity, $view_mode)
 
 alterBuild (array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
 
 isViewModeCacheable ($view_mode)
 
 getSingleFieldDisplay ($entity, $field_name, $display_options)
 
- Protected Member Functions inherited from EntityHandlerBase
 moduleHandler ()
 

Detailed Description

Provides a Block view builder.

Constructor & Destructor Documentation

__construct ( EntityTypeInterface  $entity_type,
EntityManagerInterface  $entity_manager,
LanguageManagerInterface  $language_manager,
ModuleHandlerInterface  $module_handler 
)

Constructs a new BlockViewBuilder.

Parameters
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
\Drupal\Core\Entity\EntityManagerInterface$entity_managerThe entity manager service.
\Drupal\Core\Language\LanguageManagerInterface$language_managerThe language manager.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler.

References EntityHandlerBase\moduleHandler().

Here is the call graph for this function:

Member Function Documentation

buildComponents ( array &  $build,
array  $entities,
array  $displays,
  $view_mode 
)

{Builds the component fields and properties of a set of entities.

Parameters
&$buildThe renderable array representing the entity content.
\Drupal\Core\Entity\EntityInterface[]$entities The entities whose content is being built.
\Drupal\Core\Entity\Display\EntityViewDisplayInterface[]$displays The array of entity view displays holding the display options configured for the entity components, keyed by bundle name.
string$view_modeThe view mode in which the entity is being viewed.
}

Implements EntityViewBuilderInterface.

static buildPreRenderableBlock (   $entity,
ModuleHandlerInterface  $module_handler 
)
staticprotected

Builds a #pre_render-able block render array.

Parameters
\Drupal\block\BlockInterface$entityA block config entity.
\Drupal\Core\Extension\ModuleHandlerInterface$module_handlerThe module handler service.
Returns
array A render array with a #pre_render callback to render the block.

References ModuleHandlerInterface\alter(), and Drupal\service().

Here is the call graph for this function:

static createInstance ( ContainerInterface  $container,
EntityTypeInterface  $entity_type 
)
static

{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.

Parameters
\Symfony\Component\DependencyInjection\ContainerInterface$containerThe service container this object should use.
\Drupal\Core\Entity\EntityTypeInterface$entity_typeThe entity type definition.
Returns
static A new instance of the entity handler.
}

Implements EntityHandlerInterface.

References EntityTypeInterface\get().

Here is the call graph for this function:

static lazyBuilder (   $entity_id,
  $view_mode 
)
static

#lazy_builder callback; builds a #pre_render-able block.

Parameters
$entity_idA block config entity ID.
$view_modeThe view mode the block is being viewed in.
Returns
array A render array with a #pre_render callback to render the block.

References Drupal\service().

Here is the call graph for this function:

static preRender (   $build)
static

#pre_render callback for building a block.

Renders the content using the provided block plugin, and then:

  • if there is no content, aborts rendering, and makes sure the block won't be rendered.
  • if there is content, moves the contextual links from the block content to the block itself.

References CacheableMetadata\createFromRenderArray(), and Element\isEmpty().

Here is the call graph for this function:

view ( EntityInterface  $entity,
  $view_mode = 'full',
  $langcode = NULL 
)

{Builds the render array for the provided entity.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to render.
string$view_mode(optional) The view mode that should be used to render the entity.
string$langcode(optional) For which language the entity should be rendered, defaults to the current content language.
Returns
array A render array for the entity.
Exceptions
\InvalidArgumentExceptionCan be thrown when the set of parameters is inconsistent, like when trying to view a Comment and passing a Node which is not the one the comment belongs to, or not passing one, and having the comment node not be available for loading.
}

Implements EntityViewBuilderInterface.

References EntityViewBuilder\viewMultiple().

Here is the call graph for this function:


The documentation for this class was generated from the following file: