/**
  * {@inheritdoc}
  */
 public function viewElements(FieldItemListInterface $items, $langcode)
 {
     $elements = [];
     \Drupal::logger('tec_formatters')->notice('HOOLA');
     foreach ($items as $delta => $item) {
         $url = Url::fromUri('mailto:' . $this->viewValue($item), array('absolute' => TRUE));
         $link = new Link('Send email', $url);
         $elements[$delta] = $link->toRenderable();
     }
     return $elements;
 }
예제 #2
0
 /**
  * Builds a renderable array of a result.
  *
  * @param \Drupal\facets\Result\ResultInterface $child
  *   A result item.
  *
  * @return array
  *   A renderable array of the result.
  */
 protected function buildChildren(ResultInterface $child)
 {
     $text = $this->extractText($child);
     if (!is_null($child->getUrl())) {
         $link = new Link($text, $child->getUrl());
         $item = $link->toRenderable();
     } else {
         $item = ['#markup' => $text];
     }
     $item['#wrapper_attributes'] = ['class' => ['leaf']];
     return $item;
 }