public function DomainSource::getItems in Domain Access 8
Gets an array of items for the field.
Parameters
\Drupal\views\ResultRow $values: The result row object containing the values.
Return value
array An array of items for the field.
Overrides EntityField::getItems
File
- domain_source/src/ Plugin/ views/ field/ DomainSource.php, line 18 
Class
- DomainSource
- Field handler to present the link an entity on a domain.
Namespace
Drupal\domain_source\Plugin\views\fieldCode
public function getItems(ResultRow $values) {
  $items = parent::getItems($values);
  // Override the default link generator, which wants to send us to the entity
  // page, not the entity we are looking at.
  if (!empty($this->options['settings']['link'])) {
    foreach ($items as &$item) {
      $object = $item['raw'];
      $entity = $object
        ->getEntity();
      $url = $entity
        ->toUrl()
        ->toString();
      $domain = $item['rendered']['#options']['entity'];
      $item['rendered']['#type'] = 'markup';
      $item['rendered']['#markup'] = '<a href="' . $domain
        ->buildUrl($url) . '">' . $domain
        ->label() . '</a>';
    }
    uasort($items, [
      $this,
      'sort',
    ]);
  }
  return $items;
}