Link.php in Simplenews 8
File
src/Plugin/views/field/Link.php
View source
<?php
namespace Drupal\simplenews\Plugin\views\field;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
class Link extends FieldPluginBase {
public function usesGroupBy() {
return FALSE;
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['text'] = array(
'default' => '',
);
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['text'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Text to display'),
'#default_value' => $this->options['text'],
);
parent::buildOptionsForm($form, $form_state);
$form['alter']['path'] = array(
'#access' => FALSE,
);
$form['alter']['external'] = array(
'#access' => FALSE,
);
}
public function query() {
$this
->addAdditionalFields();
}
public function render(ResultRow $values) {
if ($entity = $this
->getEntity($values)) {
return $this
->renderLink($entity, $values);
}
}
}
Classes
Name |
Description |
Link |
Field handler to present a link to the subscriber. |