From 0c8fae0b2678943ab1bbc38d87aaafa5ddbf8e8f Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole <catch@35733.no-reply.drupal.org> Date: Sun, 13 Oct 2013 13:15:46 +0100 Subject: [PATCH] Issue #2034979 by derhasi: Typehint Views field handler methods with ResultRow. --- .../aggregator/Plugin/views/field/Category.php | 8 ++++---- .../Plugin/views/field/TitleLink.php | 8 ++++---- .../comment/Plugin/views/field/Comment.php | 11 +++++++++++ .../Drupal/comment/Plugin/views/field/Link.php | 11 +++++++++++ .../comment/Plugin/views/field/LinkApprove.php | 11 +++++++++++ .../comment/Plugin/views/field/LinkDelete.php | 11 +++++++++++ .../comment/Plugin/views/field/LinkEdit.php | 11 +++++++++++ .../comment/Plugin/views/field/LinkReply.php | 11 +++++++++++ .../Plugin/views/field/NodeNewComments.php | 11 +++++++++++ .../comment/Plugin/views/field/Username.php | 11 +++++++++++ .../Plugin/views/field/TranslationLink.php | 4 ++-- .../Plugin/views/field/ContextualLinks.php | 3 +++ .../Drupal/file/Plugin/views/field/File.php | 10 ++++++++-- .../Drupal/node/Plugin/views/field/Link.php | 11 +++++++++++ .../node/Plugin/views/field/LinkDelete.php | 10 +++++++++- .../node/Plugin/views/field/LinkEdit.php | 10 +++++++++- .../Drupal/node/Plugin/views/field/Node.php | 10 ++++++++-- .../node/Plugin/views/field/Revision.php | 10 ++++++++-- .../node/Plugin/views/field/RevisionLink.php | 11 +++++++++++ .../Plugin/views/field/RevisionLinkDelete.php | 11 +++++++++++ .../Plugin/views/field/RevisionLinkRevert.php | 11 +++++++++++ .../taxonomy/Plugin/views/field/Taxonomy.php | 10 ++++++++-- .../user/Plugin/views/field/Language.php | 3 +++ .../Drupal/user/Plugin/views/field/Link.php | 2 +- .../Drupal/user/Plugin/views/field/Mail.php | 3 +++ .../Drupal/user/Plugin/views/field/Name.php | 3 +++ .../Drupal/user/Plugin/views/field/User.php | 11 +++++++++++ .../views/Plugin/views/field/Counter.php | 3 ++- .../Plugin/views/field/FieldPluginBase.php | 18 ++++++++++++------ 29 files changed, 230 insertions(+), 28 deletions(-) diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/Category.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/Category.php index e42c0cae6ef1..05f77e12a484 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/Category.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/Category.php @@ -59,11 +59,11 @@ public function buildOptionsForm(&$form, &$form_state) { * * @param string $data * The XSS safe string for the link text. - * @param object $values - * The values retrieved from the database. + * @param \Drupal\views\ResultRow $values + * The values retrieved from a single row of a view's query result. * - * @return data - * Returns string for the link text. + * @return string + * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { $cid = $this->getValue($values, 'cid'); diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/TitleLink.php b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/TitleLink.php index b8d8508ac516..27b5aa0e667a 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/TitleLink.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Plugin/views/field/TitleLink.php @@ -68,11 +68,11 @@ public function render(ResultRow $values) { * * @param string $data * The XSS safe string for the link text. - * @param object $values - * The values retrieved from the database. + * @param \Drupal\views\ResultRow $values + * The values retrieved from a single row of a view's query result. * - * @return data - * Returns string for the link text. + * @return string + * Returns a string for the link text. */ protected function renderLink($data, ResultRow $values) { $link = $this->getValue($values, 'link'); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Comment.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Comment.php index a53417507156..1e12304ed1b0 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Comment.php @@ -63,6 +63,17 @@ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); } + /** + * Render whatever the data is as a link to the comment or its node. + * + * @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_comment'])) { $this->options['alter']['make_link'] = TRUE; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php index 4231c3ba1f15..e2a0dd2bf49e 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Link.php @@ -90,6 +90,17 @@ public function render(ResultRow $values) { return $this->renderLink($comment, $values); } + /** + * Prepares the link pointing to the comment or its node. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The comment entity. + * @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) { $text = !empty($this->options['text']) ? $this->options['text'] : t('view'); $comment = $data; diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkApprove.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkApprove.php index e236b828177c..ae619714eba7 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkApprove.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkApprove.php @@ -24,6 +24,17 @@ public function access() { return user_access('administer comments'); } + /** + * Prepares the link pointing for approving the comment. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The comment entity. + * @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) { $status = $this->getValue($values, 'status'); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkDelete.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkDelete.php index 30cd273e3b46..34ba8ae7024d 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkDelete.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkDelete.php @@ -24,6 +24,17 @@ public function access() { return user_access('administer comments'); } + /** + * Prepares the link for deleting the comment. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The comment entity. + * @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) { $text = !empty($this->options['text']) ? $this->options['text'] : t('delete'); $comment = $this->getEntity($values); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkEdit.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkEdit.php index 805274bd47f4..39ce70d8b27e 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkEdit.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkEdit.php @@ -37,6 +37,17 @@ public function buildOptionsForm(&$form, &$form_state) { ); } + /** + * Prepare the link for editing the comment. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The comment entity. + * @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) { parent::renderLink($data, $values); // Ensure user has access to edit this comment. diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkReply.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkReply.php index 6bdc7da51a60..9b1d212f72b0 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkReply.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/LinkReply.php @@ -24,6 +24,17 @@ public function access() { return user_access('post comments'); } + /** + * Prepare the link for replying to the comment. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The comment entity. + * @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) { $text = !empty($this->options['text']) ? $this->options['text'] : t('reply'); $comment = $this->getEntity($values); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php index d3f869f84968..3e36dfff2c23 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/NodeNewComments.php @@ -127,6 +127,17 @@ public function preRender(&$values) { } } + /** + * Prepares the link to the first new comment. + * + * @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_comment']) && $data !== NULL && $data !== '') { $node = entity_create('node', array( diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php index fc8275cabf4f..9d63403a0c90 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/Username.php @@ -49,6 +49,17 @@ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); } + /** + * Prepares link for the comment's author. + * + * @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_user'])) { $account = entity_create('user', array()); diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php index 474e54390084..733d7ab28bbf 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Plugin/views/field/TranslationLink.php @@ -54,11 +54,11 @@ public function render(ResultRow $values) { * * @param \Drupal\Core\Entity\EntityInterface $entity * The entity being rendered. - * @param \stdClass $values + * @param \Drupal\views\ResultRow $values * The current row of the views result. * * @return string - * The acutal rendered text (without the link) of this field. + * The actual rendered text (without the link) of this field. */ protected function renderLink(EntityInterface $entity, ResultRow $values) { if (content_translation_translate_access($entity)) { diff --git a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php index 30de8f975461..ec7a3a6011c8 100644 --- a/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php +++ b/core/modules/contextual/lib/Drupal/contextual/Plugin/views/field/ContextualLinks.php @@ -68,6 +68,9 @@ public function preRender(&$values) { * * Renders the contextual fields. * + * @param \Drupal\views\ResultRow $values + * The values retrieved from a single row of a view's query result. + * * @see contextual_preprocess() * @see contextual_contextual_links_view_alter() */ diff --git a/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php b/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php index df5056f1d5ab..3f28bd84c864 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php +++ b/core/modules/file/lib/Drupal/file/Plugin/views/field/File.php @@ -53,9 +53,15 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Render whatever the data is as a link to the file. + * Prepares link to the file. * - * Data should be made XSS safe prior to calling this function. + * @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_file']) && $data !== NULL && $data !== '') { diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php index a4715a8a6ea6..18a9a9a16e8d 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Link.php @@ -55,6 +55,17 @@ public function render(ResultRow $values) { } } + /** + * Prepares the link to the node. + * + * @param \Drupal\Core\Entity\EntityInterface $node + * The node entity this field belongs to. + * @param ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. + */ protected function renderLink($node, ResultRow $values) { if (node_access('view', $node)) { $this->options['alter']['make_link'] = TRUE; diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php index 4a60a4bc8700..ed04c4fffc54 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkDelete.php @@ -21,7 +21,15 @@ class LinkDelete extends Link { /** - * Renders the link. + * Prepares the link to delete a node. + * + * @param \Drupal\Core\Entity\EntityInterface $node + * The node entity this field belongs to. + * @param \Drupal\views\ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. */ protected function renderLink($node, ResultRow $values) { // Ensure user has access to delete this node. diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php index fdf933e08704..9dbc9ac7aa19 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/LinkEdit.php @@ -21,7 +21,15 @@ class LinkEdit extends Link { /** - * Renders the link. + * Prepares the link to the node. + * + * @param \Drupal\Core\Entity\EntityInterface $node + * The node entity this field belongs to. + * @param ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. */ protected function renderLink($node, ResultRow $values) { // Ensure user has access to edit this node. diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php index a8e479469f31..b2de15a2c64c 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Node.php @@ -57,9 +57,15 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Render whatever the data is as a link to the node. + * Prepares link to the node. * - * Data should be made XSS safe prior to calling this function. + * @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']) && !empty($this->additional_fields['nid'])) { diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/Revision.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/Revision.php index 4a884b4dce0d..f99f6b7356c1 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/Revision.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/Revision.php @@ -53,9 +53,15 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Render whatever the data is as a link to the node. + * Prepares link to the node revision. * - * Data should be made XSS safe prior to calling this function. + * @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 !== '') { diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php index 0bc8d15dd110..f56388bf89c3 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLink.php @@ -35,6 +35,17 @@ public function access() { return user_access('view revisions') || user_access('administer nodes'); } + /** + * Prepares the link to point to a node revision. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The node revision entity this field belongs to. + * @param \Drupal\views\ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. + */ protected function renderLink($data, ResultRow $values) { list($node, $vid) = $this->get_revision_entity($values, 'view'); if (!isset($vid)) { diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php index 306b5ba75dfe..0f8cc641e7b6 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkDelete.php @@ -24,6 +24,17 @@ public function access() { return user_access('delete revisions') || user_access('administer nodes'); } + /** + * Prepares the link to delete a node revision. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The node revision entity this field belongs to. + * @param \Drupal\views\ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. + */ protected function renderLink($data, ResultRow $values) { list($node, $vid) = $this->get_revision_entity($values, 'delete'); if (!isset($vid)) { diff --git a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php index 6318bd43965a..13c10fd4cf46 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php +++ b/core/modules/node/lib/Drupal/node/Plugin/views/field/RevisionLinkRevert.php @@ -24,6 +24,17 @@ public function access() { return user_access('revert revisions') || user_access('administer nodes'); } + /** + * Prepares the link to revert node to a revision. + * + * @param \Drupal\Core\Entity\EntityInterface $data + * The node revision entity this field belongs to. + * @param \Drupal\views\ResultRow $values + * The values retrieved from the view's result set. + * + * @return string + * Returns a string for the link text. + */ protected function renderLink($data, ResultRow $values) { list($node, $vid) = $this->get_revision_entity($values, 'update'); if (!isset($vid)) { diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Taxonomy.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Taxonomy.php index b2ff458c5c43..be01032bc2b4 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Taxonomy.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/field/Taxonomy.php @@ -66,9 +66,15 @@ public function buildOptionsForm(&$form, &$form_state) { } /** - * Render whatever the data is as a link to the taxonomy. + * Prepares a link to the taxonomy. * - * Data should be made XSS safe prior to calling this function. + * @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) { $tid = $this->getValue($values, 'tid'); diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Language.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Language.php index 3ea7d45f68b0..46c758006b4b 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Language.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Language.php @@ -19,6 +19,9 @@ */ class Language extends User { + /** + * {@inheritdoc} + */ protected function renderLink($data, ResultRow $values) { if (!empty($this->options['link_to_user'])) { $uid = $this->getValue($values, 'uid'); diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Link.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Link.php index 390bfc4fabae..eaf785ec44eb 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Link.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Link.php @@ -68,7 +68,7 @@ public function render(ResultRow $values) { * Alters the field to render a link. * * @param \Drupal\Core\Entity\EntityInterface $entity - * @param \stdClass $values + * @param \Drupal\views\ResultRow $values * The current row of the views result. * * @return string diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Mail.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Mail.php index 9fce78433a62..1520359e8772 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Mail.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Mail.php @@ -39,6 +39,9 @@ public function buildOptionsForm(&$form, &$form_state) { ); } + /** + * {@inheritdoc} + */ protected function renderLink($data, ResultRow $values) { parent::renderLink($data, $values); diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php index 50e580ba8079..fb374ba33472 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/Name.php @@ -75,6 +75,9 @@ public function buildOptionsForm(&$form, &$form_state) { ); } + /** + * {@inheritdoc} + */ protected function renderLink($data, ResultRow $values) { $account = entity_create('user', array()); $account->uid = $this->getValue($values, 'uid'); diff --git a/core/modules/user/lib/Drupal/user/Plugin/views/field/User.php b/core/modules/user/lib/Drupal/user/Plugin/views/field/User.php index bb7e861dc480..159b4aa1d855 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/views/field/User.php +++ b/core/modules/user/lib/Drupal/user/Plugin/views/field/User.php @@ -52,6 +52,17 @@ public function buildOptionsForm(&$form, &$form_state) { parent::buildOptionsForm($form, $form_state); } + /** + * Prepares a link to the user. + * + * @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_user']) && user_access('access user profiles') && ($entity = $this->getEntity($values)) && $data !== NULL && $data !== '') { $this->options['alter']['make_link'] = TRUE; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/Counter.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/Counter.php index 15b041c7d055..50e47e2ab3df 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/Counter.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/Counter.php @@ -8,6 +8,7 @@ namespace Drupal\views\Plugin\views\field; use Drupal\Component\Annotation\PluginID; +use Drupal\views\ResultRow; /** * Field handler to show a counter of the current row. @@ -43,7 +44,7 @@ public function query() { /** * {@inheritdoc} */ - public function getValue($values, $field = NULL) { + public function getValue(ResultRow $values, $field = NULL) { // Note: 1 is subtracted from the counter start value below because the // counter value is incremented by 1 at the end of this function. $count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php index 25c28a868feb..1f8264e51983 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/FieldPluginBase.php @@ -384,12 +384,12 @@ public function getEntity(ResultRow $values) { * This api exists so that other modules can easy set the values of the field * without having the need to change the render method as well. * - * @param $values + * @param \Drupal\views\ResultRow $values * An object containing all retrieved values. - * @param $field + * @param string $field * Optional name of the field where the value is stored. */ - public function getValue($values, $field = NULL) { + public function getValue(ResultRow $values, $field = NULL) { $alias = isset($field) ? $this->aliases[$field] : $this->field_alias; if (isset($values->{$alias})) { return $values->{$alias}; @@ -1096,7 +1096,7 @@ public function preRender(&$values) { } * Renders the field. * * @param \Drupal\views\ResultRow $values - * The values retrieved from the database. + * The values retrieved from a single row of a view's query result. */ public function render(ResultRow $values) { $value = $this->getValue($values); @@ -1110,7 +1110,7 @@ public function render(ResultRow $values) { * text-replacement rendering is necessary. * * @param \Drupal\views\ResultRow $values - * The values retrieved from the database. + * The values retrieved from a single row of a view's query result. */ public function advancedRender(ResultRow $values) { if ($this->allowAdvancedRender() && method_exists($this, 'render_item')) { @@ -1591,8 +1591,14 @@ protected function documentSelfTokens(&$tokens) { } /** * Call out to the theme() function, which probably just calls render() but * allows sites to override output fairly easily. + * + * @param \Drupal\views\ResultRow $values + * Holds single row of a view's result set. + * + * @return string|false + * Returns rendered output of the given theme implementation. */ - function theme($values) { + function theme(ResultRow $values) { return theme($this->themeFunctions(), array( 'view' => $this->view, -- GitLab