public function query() { // Only add ourselves to the query if logged in. if (\Drupal::currentUser()->isAnonymous()) { return; } parent::query(); }
/** * Prepares link to the node revision. * * @param string $data * The XSS safe string for the link text. * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * * @return string * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { if (!empty($this->options['link_to_node_revision']) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; $nid = $this->getValue($values, 'nid'); $vid = $this->getValue($values, 'vid'); $this->options['alter']['url'] = Url::fromRoute('node.revision_show', ['node' => $nid, 'node_revision' => $vid]); } else { return parent::renderLink($data, $values); } return $data; }
/** * Prepares link to the node revision. * * @param string $data * The XSS safe string for the link text. * @param \Drupal\views\ResultRow $values * The values retrieved from a single row of a view's query result. * * @return string * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { if (!empty($this->options['link_to_node_revision']) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; $nid = $this->getValue($values, 'nid'); $vid = $this->getValue($values, 'vid'); $this->options['alter']['path'] = "node/" . $nid . '/revisions/' . $vid . '/view'; } else { return parent::renderLink($data, $values); } return $data; }
/** * Provide machine_name option for to node type display. */ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); $form['machine_name'] = array('#title' => t('Output machine name'), '#description' => t('Display field as the content type machine name.'), '#type' => 'checkbox', '#default_value' => !empty($this->options['machine_name'])); }
public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); $form['native_language'] = array('#title' => $this->t('Native language'), '#type' => 'checkbox', '#default_value' => $this->options['native_language'], '#description' => $this->t('If enabled, the native name of the language will be displayed')); }