Commit fd76691c authored by alexpott's avatar alexpott

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);
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\Node;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* 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);
......
......@@ -46,7 +46,10 @@ public function query() {
$this->addAdditionalFields();
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
if ($entity = $this->getEntity($values)) {
return $this->renderLink($entity, $values);
}
......
......@@ -87,7 +87,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\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -53,7 +54,10 @@ public function query() {
$this->addAdditionalFields();
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$nid = $this->getValue($values, 'nid');
return url("node/$nid", array('absolute' => $this->options['absolute']));
}
......
......@@ -9,6 +9,7 @@
use Drupal\node\Plugin\views\field\Node;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to translate a node type into its readable form.
......@@ -51,7 +52,10 @@ function render_name($data, $values) {
return $this->sanitizeValue($data);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->render_name($value, $values), $values);
}
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\Numeric;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to provide simple renderer that allows linking to a node.
......@@ -80,7 +81,10 @@ public function query() {
}
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
// Only render if we exist.
if (isset($this->tableAlias)) {
return parent::render($values);
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityManager;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\style\Table;
use Drupal\views\ResultRow;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -50,9 +51,9 @@ public static function create(ContainerInterface $container, array $configuratio
}
/**
* Overrides \Drupal\views\Plugin\views\Plugin\field\FieldPluginBase::render().
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
return '<!--form-item-' . $this->options['id'] . '--' . $this->view->row_index . '-->';
}
......
......@@ -8,6 +8,7 @@
namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\Component\Annotation\PluginID;
use Drupal\views\ResultRow;
/**
* Field handler to show the language of a taxonomy term.
......@@ -17,9 +18,9 @@
class Language extends Taxonomy {
/**
* Overrides Drupal\taxonomy\Plugin\views\field\Taxonomy::render().
* {@inheritdoc}
*/
public function render($values) {
public function render(ResultRow $values) {
$value = $this->getValue($values);
$language = language_load($value);
$value = $language ? $language->name : '';
......
......@@ -9,6 +9,7 @@
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\Component\Annotation\PluginID;
......@@ -53,7 +54,10 @@ public function query() {
$this->addAdditionalFields();
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
// Check there is an actual value, as on a relationship there may not be.
if ($tid = $this->getValue($values, 'tid')) {
// Mock a term object for taxonomy_term_access(). Use machine name and
......
......@@ -7,6 +7,7 @@
namespace Drupal\taxonomy\Plugin\views\field;
use Drupal\views\Plugin\views\area\Result;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
......@@ -88,7 +89,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);
}
......
......@@ -39,7 +39,10 @@ protected function renderLink($data, ResultRow $values) {
return $this->sanitizeValue($lang->name);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
return $this->renderLink($this->sanitizeValue($value), $values);
}
......
......@@ -58,9 +58,9 @@ public function query() {
}
/**
* 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);
}
......
......@@ -61,7 +61,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\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\user\UserDataInterface;
use Drupal\Component\Annotation\PluginID;
......@@ -75,9 +76,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) {
$uid = $this->getValue($values);
$data = $this->userData->get($this->options['data_module'], $uid, $this->options['data_name']);
......
......@@ -7,6 +7,7 @@
namespace Drupal\views\Plugin\views\field;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\Component\Annotation\PluginID;
......@@ -100,7 +101,10 @@ public function buildOptionsForm(&$form, &$form_state) {
parent::buildOptionsForm($form, $form_state);
}
public function render($values) {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$value = $this->getValue($values);
if (!empty($this->options['not'])) {
$value = !$value;
......