Problem

  1. The documentation for hook_views_post_render() says that the $cache parameter is an instance of CacheBackendInterface, but in reality$cache gets a \Drupal\views\Plugin\views\cache\CachePluginBase.
  2. Many class names in views.api.php don't use fully qualified names per docs standards.

I noticed this when I started porting Draggable Views to D8.

Proposed change

  1. Correct the class type hint for $cache in hook_views_post_render.
  2. Use fully qualified names in @param tags and function signatures.

API changes

None.

To do

Use fully qualified names for classes, etc in @parma tags and function signature.

CommentFileSizeAuthor
#1 2319361-1.patch1.58 KBandrewmacpherson
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andrewmacpherson’s picture

FileSize
1.58 KB

This patch updates the documentation for hook_views_post_render() in views.api.php

  • Documents the $cache param as \Drupal\views\Plugin\views\cache\CachePluginBase,
  • Uses fully-qualified class names in the function signature,
  • Corrects a couple of mispelled doc tags ('@encode' should be '@endcode').
andrewmacpherson’s picture

Status: Active » Needs review
dawehner’s picture

Component: views.module » documentation

Thank you for your patch. Moving this to documentation so that jhodgon will see it, once it is RTBC
I wonder whether we can fix the other problems in the file as well, for example hook_views_query_substitutions,hook_views_pre_view,hook_views_post_build etc. also has the non-full namespace,

+++ b/core/modules/views/views.api.php
@@ -727,12 +727,12 @@ function hook_views_pre_render(ViewExecutable $view) {
- * @encode
+ * @endcode
...
- * @encode
+ * @endcode

haha!

dawehner’s picture

Status: Needs review » Needs work

So sorry :(

andrewmacpherson’s picture

Title: Incorrect type hint in signature of hook_views_post_render() » Improve Views API hook documentation
Assigned: Unassigned » andrewmacpherson
Issue summary: View changes
Status: Needs work » Active

Sure, I'll update the other views hook docs to use fully-qualified names.
Updating main issue description.

jhodgdon’s picture

So... Normally we want to use an Interface and not a Base class in parameter documentation. Why are you making this switch to the Base class? Even if it usually is a base class, it's coding standards to use an interface if possible.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

andrewmacpherson’s picture

Assigned: andrewmacpherson » Unassigned
Status: Active » Closed (outdated)

Re: #6

My thinking was the most relevant methods of $cache parameter come from \Drupal\views\Plugin\views\cache\CachePluginBase. It implements several general purpose interfaces, but none of them relate to caching. There isn't a ViewsCacheInterface for instance.

#2544922: hook_views_post_render causes "A stray drupal_render() invocation" for anonymous users made this change already.

Also, the "@encode" typo was fixed in #2729083: @encode becomes @endcode

Closing as outdated, because everything that patch #1 addressed has been fixed elsewhere.