public function EntityBlock::__construct in Entity Blocks 8
Same name in this branch
- 8 src/Plugin/Derivative/EntityBlock.php \Drupal\entity_block\Plugin\Derivative\EntityBlock::__construct()
- 8 src/Plugin/Block/EntityBlock.php \Drupal\entity_block\Plugin\Block\EntityBlock::__construct()
Overrides BlockPluginTrait::__construct
File
- src/
Plugin/ Block/ EntityBlock.php, line 55
Class
- EntityBlock
- Provides the block for similar articles.
Namespace
Drupal\entity_block\Plugin\BlockCode
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, EntityDisplayRepositoryInterface $entityDisplayRepository) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
// Determine what entity type we are referring to.
$this->entityTypeName = $this
->getDerivativeId();
// Load various utilities related to our entity type.
$this->entityTypeManager = $entityTypeManager;
$this->entityStorage = $entityTypeManager
->getStorage($this->entityTypeName);
// Panelizer replaces the view_builder handler, but we want to use the
// original which has been moved to fallback_view_builder.
if ($entityTypeManager
->hasHandler($this->entityTypeName, 'fallback_view_builder')) {
$this->entityViewBuilder = $entityTypeManager
->getHandler($this->entityTypeName, 'fallback_view_builder');
}
else {
$this->entityViewBuilder = $entityTypeManager
->getHandler($this->entityTypeName, 'view_builder');
}
$this->view_mode_options = $entityDisplayRepository
->getViewModeOptions($this->entityTypeName);
}