diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 5e09be8b58..4b647fb0f7 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -8,6 +8,7 @@ use Drupal\Core\Block\BlockManagerInterface; use Drupal\Core\Entity\EntityDisplayRepositoryInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Routing\UrlGeneratorInterface; @@ -76,6 +77,13 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter protected $entityDisplayRepository; /** + * The language manager. + * + * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager + */ + protected $languageManager; + + /** * Constructs a new BlockContentBlock. * * @param array $configuration @@ -97,7 +105,7 @@ class BlockContentBlock extends BlockBase implements ContainerFactoryPluginInter * @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository * The entity display repository. */ - public function __construct(array $configuration, $plugin_id, $plugin_definition, BlockManagerInterface $block_manager, EntityTypeManagerInterface $entity_type_manager, AccountInterface $account, UrlGeneratorInterface $url_generator, BlockContentUuidLookup $uuid_lookup, EntityDisplayRepositoryInterface $entity_display_repository) { + public function __construct(array $configuration, $plugin_id, $plugin_definition, BlockManagerInterface $block_manager, EntityTypeManagerInterface $entity_type_manager, AccountInterface $account, UrlGeneratorInterface $url_generator, BlockContentUuidLookup $uuid_lookup, EntityDisplayRepositoryInterface $entity_display_repository, LanguageManagerInterface $language_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); $this->blockManager = $block_manager; @@ -106,6 +114,7 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition $this->urlGenerator = $url_generator; $this->uuidLookup = $uuid_lookup; $this->entityDisplayRepository = $entity_display_repository; + $this->languageManager = $language_manager; } /** @@ -121,7 +130,8 @@ public static function create(ContainerInterface $container, array $configuratio $container->get('current_user'), $container->get('url_generator'), $container->get('block_content.uuid_lookup'), - $container->get('entity_display.repository') + $container->get('entity_display.repository'), + $container->get('language_manager') ); } @@ -184,7 +194,7 @@ protected function blockAccess(AccountInterface $account) { */ public function build() { if ($block = $this->getEntity()) { - return $this->entityTypeManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode']); + return $this->entityTypeManager->getViewBuilder($block->getEntityTypeId())->view($block, $this->configuration['view_mode'], $this->languageManager->getCurrentLanguage()->getId()); } else { return [