Skip to content
Snippets Groups Projects
Commit b9343b04 authored by Florent Torregrosa's avatar Florent Torregrosa Committed by Pierre Dureau
Browse files

Issue #3339671: Pass the entity into the build context

parent 3deeb433
No related branches found
No related tags found
1 merge request!3Issue #3339671: Pass the entity into the build context
......@@ -99,7 +99,7 @@ class LinkBlock extends BlockBase implements ContextAwarePluginInterface, Contai
* {@inheritdoc}
*/
public function build() {
$entity = $this->getEntity();
$config = $this->getConfiguration();
$rel = $this->rel;
......@@ -120,7 +120,6 @@ class LinkBlock extends BlockBase implements ContextAwarePluginInterface, Contai
$source = explode(":", $source)[1];
if ($source === 'url') {
$url = '';
$entity = $this->getEntity();
$absolute_url = $config['absolute_url'];
// On layout builder page with content preview, the entities don't have
// id.
......@@ -164,8 +163,9 @@ class LinkBlock extends BlockBase implements ContextAwarePluginInterface, Contai
// Add context.
$build['#context'] = [
'type' => 'entity_link',
'entity_type' => $this->getEntity()->getEntityTypeId(),
'entity_id' => $this->getEntity()->id(),
'entity' => $entity,
'entity_type' => $entity->getEntityTypeId(),
'entity_id' => $entity->id(),
'link' => $rel,
];
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment