|
@@ -33,23 +33,38 @@ class SamplesDefaultFormatter extends FormatterBase {
|
|
|
|
|
|
$term = Term::load($item->target_id);
|
|
$term = Term::load($item->target_id);
|
|
|
|
|
|
- if(!$term) return;
|
|
|
|
-
|
|
|
|
- // translate the term
|
|
|
|
- $term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
|
|
|
|
-
|
|
|
|
- $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' => $term->getName(),
|
|
|
|
- '@location' => $item->location
|
|
|
|
- ]
|
|
|
|
- ),
|
|
|
|
- ];
|
|
|
|
|
|
+ if($term){
|
|
|
|
+ // translate the term
|
|
|
|
+ $term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
|
|
|
|
+
|
|
|
|
+ $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' => $term->getName(),
|
|
|
|
+ '@location' => $item->location
|
|
|
|
+ ]
|
|
|
|
+ ),
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ } 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
|
|
|
|
+ ]
|
|
|
|
+ ),
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|