Commit fd76691c authored by alexpott's avatar alexpott
Browse files

Issue #2059479 by damiankloip: Typehint Drupal\views\ResultRow in field handler render methods.

parent 30f23047
......@@ -77,7 +77,7 @@ protected function renderLink($data, ResultRow $values) {
/**
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -58,7 +58,7 @@ public function buildOptionsForm(&$form, &$form_state) {
/**
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -80,7 +80,10 @@ protected function renderLink($data, ResultRow $values) {
return $data;
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Field handler to display the depth of a comment.
......@@ -20,9 +21,10 @@
class Depth extends FieldPluginBase {
/**
* Work out the depth of this comment
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
// Work out the depth of this comment.
$comment_thread = $this->getValue($values);
return count(explode('.', $comment_thread)) - 1;
}
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\Date;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -30,7 +31,10 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o
$this->additional_fields['comment_count'] = 'comment_count';
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$comment_count = $this->getValue($values, 'comment_count');
if (empty($this->options['empty_zero']) || $comment_count) {
return parent::render($values);
......
......@@ -43,7 +43,10 @@ public function buildOptionsForm(&$form, &$form_state) {
public function query() {}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$comment = $this->getEntity($values);
return $this->renderLink($comment, $values);
}
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to present the name of the last comment poster.
......@@ -56,7 +57,10 @@ protected function defineOptions() {
return $options;
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
if (!empty($this->options['link_to_user'])) {
$account = entity_create('user', array());
$account->name = $this->getValue($values);
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Display node comment status.
......@@ -19,7 +20,10 @@
*/
class NodeComment extends FieldPluginBase {
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
switch ($value) {
case COMMENT_NODE_HIDDEN:
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Handler for showing comment module's node link.
......@@ -38,7 +39,10 @@ public function buildOptionsForm(&$form, &$form_state) {
public function query() {}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$node = $this->getEntity($values);
comment_node_view($node, $this->options['teaser'] ? 'teaser' : 'full');
......
......@@ -143,7 +143,10 @@ protected function renderLink($data, ResultRow $values) {
return $data;
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
if (!empty($value)) {
return $this->renderLink(parent::render($values), $values);
......
......@@ -66,7 +66,10 @@ protected function renderLink($data, ResultRow $values) {
}
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -43,9 +43,9 @@ public function buildOptionsForm(&$form, &$form_state) {
}
/**
* Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
return $this->renderLink($this->getEntity($values), $values);
}
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Provides a handler that adds contextual links.
......@@ -63,12 +64,14 @@ public function preRender(&$values) {
}
/**
* Render the contextual fields.
* Overrides \Drupal\views\Plugin\views\field\FieldPluginBase::render().
*
* Renders the contextual fields.
*
* @see contextual_preprocess()
* @see contextual_contextual_links_view_alter()
*/
public function render($values) {
public function render(ResultRow $values) {
$links = array();
foreach ($this->options['fields'] as $field) {
$rendered_field = $this->view->style_plugin->getField($this->view->row_index, $field);
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Returns a pure file extension of the file, for example 'module'.
......@@ -41,7 +42,10 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
if (!$this->options['extension_detect_tar']) {
if (preg_match('/\.([^\.]+)$/', $value, $match)) {
......
......@@ -66,7 +66,10 @@ protected function renderLink($data, ResultRow $values) {
return $data;
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to add rendering MIME type images as an option on the filemime field.
......@@ -33,7 +34,10 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') {
$file_icon = array(
......
......@@ -9,6 +9,7 @@
use Drupal\Component\Annotation\PluginID;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
/**
* Field handler to translate a node type into its readable form.
......@@ -19,7 +20,10 @@
*/
class Status extends FieldPluginBase {
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return _views_file_status($value);
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\file\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to add rendering file paths as file URLs instead of as internal file URIs.
......@@ -32,7 +33,10 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
$data = file_create_url($data);
......
......@@ -7,6 +7,7 @@
namespace Drupal\history\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;
......@@ -68,7 +69,10 @@ public function query() {
parent::query();
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
// Let's default to 'read' state.
// This code shadows node_mark, but it reads from the db directly and
// we already have that info.
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Defines a field handler to translate a language into its readable form.
......@@ -36,7 +37,10 @@ public function buildOptionsForm(&$form, &$form_state) {
);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value = $this->getValue($values);
......
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