Commit 08aeb871 authored by alexpott's avatar alexpott
Browse files

Issue #2034947 by damiankloip: Change view results to use a classed object.

parent 2f0e07fa
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -64,7 +65,7 @@ public function buildOptionsForm(&$form, &$form_state) {
* @return data
* Returns string for the link text.
*/
protected function render_link($data, $values) {
protected function render_link($data, ResultRow $values) {
$cid = $this->getValue($values, 'cid');
if (!empty($this->options['link_to_category']) && !empty($cid) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -73,7 +74,7 @@ public function render($values) {
* @return data
* Returns string for the link text.
*/
protected function render_link($data, $values) {
protected function render_link($data, ResultRow $values) {
$link = $this->getValue($values, 'link');
if (!empty($this->options['display_as_link'])) {
$this->options['alter']['make_link'] = TRUE;
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
......@@ -61,7 +62,7 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
if (!empty($this->options['link_to_comment'])) {
$this->options['alter']['make_link'] = TRUE;
$nid = $this->getValue($values, 'nid');
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Base field handler to present a link.
......@@ -47,7 +48,7 @@ public function render($values) {
return $this->render_link($comment, $values);
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('view');
$comment = $data;
$nid = $comment->nid;
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\Component\Annotation\PluginID;
/**
......@@ -23,7 +24,7 @@ public function access() {
return user_access('administer comments');
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
$status = $this->getValue($values, 'status');
// Don't show an approve link on published nodes.
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link to delete a comment.
......@@ -23,7 +24,7 @@ public function access() {
return user_access('administer comments');
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('delete');
$cid = $this->getValue($values, 'cid');
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link to edit a comment.
......@@ -36,7 +37,7 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
parent::render_link($data, $values);
// Ensure user has access to edit this comment.
$comment = $this->getValue($values);
......
......@@ -8,6 +8,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link to reply to a comment.
......@@ -23,7 +24,7 @@ public function access() {
return user_access('post comments');
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('reply');
$nid = $this->getValue($values, 'nid');
$cid = $this->getValue($values, 'cid');
......
......@@ -11,6 +11,7 @@
use Drupal\Core\Database\Connection;
use Drupal\views\Plugin\views\field\Numeric;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -127,7 +128,7 @@ public function preRender(&$values) {
}
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
if (!empty($this->options['link_to_comment']) && $data !== NULL && $data !== '') {
$node = entity_create('node', array(
'nid' => $this->getValue($values, 'nid'),
......
......@@ -7,6 +7,7 @@
namespace Drupal\comment\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
......@@ -48,7 +49,7 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
if (!empty($this->options['link_to_user'])) {
$account = entity_create('user', array());
$account->uid = $this->getValue($values, 'uid');
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Component\Annotation\PluginID;
use Drupal\user\Plugin\views\field\Link;
use Drupal\views\ResultRow;
/**
* Defines a field that links to the user contact page, if access is permitted.
......@@ -42,7 +43,7 @@ public function access() {
/**
* {@inheritdoc}
*/
public function render_link(EntityInterface $entity, \stdClass $values) {
public function render_link(EntityInterface $entity, ResultRow $values) {
if (empty($entity)) {
return;
......
......@@ -10,6 +10,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\Core\Entity\EntityInterface;
use Drupal\views\ResultRow;
/**
* Provides a translation link for an entity.
......@@ -59,7 +60,7 @@ public function render($values) {
* @return string
* The acutal rendered text (without the link) of this field.
*/
public function render_link(EntityInterface $entity, \stdClass $values) {
public function render_link(EntityInterface $entity, ResultRow $values) {
if (content_translation_translate_access($entity)) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
......
......@@ -7,6 +7,7 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Component\Annotation\PluginID;
......@@ -56,7 +57,7 @@ public function buildOptionsForm(&$form, &$form_state) {
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = file_create_url($this->getValue($values, 'uri'));
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link to the node.
......@@ -51,7 +52,7 @@ public function render($values) {
}
}
function render_link($node, $values) {
function render_link($node, ResultRow $values) {
if (node_access('view', $node)) {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = 'node/' . $node->id();
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\Link;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link to delete a node.
......@@ -22,7 +23,7 @@ class LinkDelete extends Link {
/**
* Renders the link.
*/
function render_link($node, $values) {
function render_link($node, ResultRow $values) {
// Ensure user has access to delete this node.
if (!node_access('delete', $node)) {
return;
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\Link;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present a link node edit.
......@@ -22,7 +23,7 @@ class LinkEdit extends Link {
/**
* Renders the link.
*/
function render_link($node, $values) {
function render_link($node, ResultRow $values) {
// Ensure user has access to edit this node.
if (!node_access('update', $node)) {
return;
......
......@@ -7,6 +7,7 @@
namespace Drupal\node\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
......@@ -63,7 +64,7 @@ public function buildOptionsForm(&$form, &$form_state) {
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
if (!empty($this->options['link_to_node']) && !empty($this->additional_fields['nid'])) {
if ($data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
......
......@@ -7,6 +7,7 @@
namespace Drupal\node\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\node\Plugin\views\field\Node;
......@@ -59,7 +60,7 @@ public function buildOptionsForm(&$form, &$form_state) {
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
function render_link($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');
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\Link;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -34,7 +35,7 @@ public function access() {
return user_access('view revisions') || user_access('administer nodes');
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
list($node, $vid) = $this->get_revision_entity($values, 'view');
if (!isset($vid)) {
return;
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\RevisionLink;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present link to delete a node revision.
......@@ -23,7 +24,7 @@ public function access() {
return user_access('delete revisions') || user_access('administer nodes');
}
function render_link($data, $values) {
function render_link($data, ResultRow $values) {
list($node, $vid) = $this->get_revision_entity($values, 'delete');
if (!isset($vid)) {
return;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment