Commit 0c8fae0b authored by catch's avatar catch
Browse files

Issue #2034979 by derhasi: Typehint Views field handler methods with ResultRow.

parent b996ff0c
......@@ -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');
......
......@@ -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');
......
......@@ -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;
......
......@@ -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;
......
......@@ -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');
......
......@@ -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);
......
......@@ -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.
......
......@@ -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);
......
......@@ -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(
......
......@@ -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());
......
......@@ -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)) {
......
......@@ -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()
*/
......
......@@ -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 !== '') {
......
......@@ -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;
......
......@@ -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.
......
......@@ -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.
......
......@@ -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'])) {
......
......@@ -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 !== '') {
......
......@@ -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)) {
......
......@@ -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)) {
......
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