workarround for samples bug: admin materials inaccessible

This commit is contained in:
Bachir Soussi Chiadmi 2021-08-02 19:17:28 +02:00
parent 523ee1dd9d
commit 596d078708
1 changed files with 31 additions and 16 deletions

View File

@ -33,8 +33,7 @@ class SamplesDefaultFormatter extends FormatterBase {
$term = Term::load($item->target_id); $term = Term::load($item->target_id);
if(!$term) return; if($term){
// translate the term // translate the term
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language); $term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
@ -50,6 +49,22 @@ class SamplesDefaultFormatter extends FormatterBase {
] ]
), ),
]; ];
} else {
$elements[$delta] = [
// We create a render array to produce the desired markup,
// "<p style="color: #hexcolor">The color code ... #hexcolor</p>".
// See theme_html_tag().
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => $this->t('@target : @location', [
'@target' => "Bug no term available",
'@location' => $item->location
]
),
];
}
} }