3 namespace Drupal\node\Plugin\views\field;
5 @trigger_error('Drupal\node\Plugin\views\field\Path is deprecated in Drupal 8.5.0 and will be removed before Drupal 9.0.0. Use @ViewsField("entity_link") with \'output_url_as_text\' set.', E_USER_DEPRECATED);
7 use Drupal\Core\Form\FormStateInterface;
8 use Drupal\views\Plugin\views\field\FieldPluginBase;
9 use Drupal\views\Plugin\views\display\DisplayPluginBase;
10 use Drupal\views\ResultRow;
11 use Drupal\views\ViewExecutable;
14 * Field handler to present the path to the node.
16 * @ingroup views_field_handlers
18 * @ViewsField("node_path")
20 * @deprecated in Drupal 8.5.x, will be removed before Drupal 9.0.0.
21 * Use @ViewsField("entity_link") with 'output_url_as_text' set.
23 class Path extends FieldPluginBase {
28 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
29 parent::init($view, $display, $options);
31 $this->additional_fields['nid'] = 'nid';
37 protected function defineOptions() {
38 $options = parent::defineOptions();
39 $options['absolute'] = ['default' => FALSE];
47 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
48 parent::buildOptionsForm($form, $form_state);
50 '#type' => 'checkbox',
51 '#title' => $this->t('Use absolute link (begins with "http://")'),
52 '#default_value' => $this->options['absolute'],
53 '#description' => $this->t('Enable this option to output an absolute link. Required if you want to use the path as a link destination (as in "output this field as a link" above).'),
54 '#fieldset' => 'alter',
61 public function query() {
62 $this->ensureMyTable();
63 $this->addAdditionalFields();
69 public function render(ResultRow $values) {
70 $nid = $this->getValue($values, 'nid');
72 '#markup' => \Drupal::url('entity.node.canonical', ['node' => $nid], ['absolute' => $this->options['absolute']]),