Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem
- 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.
- 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
- Correct the class type hint for $cache in hook_views_post_render.
- 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.
Comment | File | Size | Author |
---|---|---|---|
#1 | 2319361-1.patch | 1.58 KB | andrewmacpherson |
Comments
Comment #1
andrewmacpherson CreditAttribution: andrewmacpherson commentedThis patch updates the documentation for hook_views_post_render() in views.api.php
Comment #2
andrewmacpherson CreditAttribution: andrewmacpherson commentedComment #3
dawehnerThank 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,
haha!
Comment #4
dawehnerSo sorry :(
Comment #5
andrewmacpherson CreditAttribution: andrewmacpherson commentedSure, I'll update the other views hook docs to use fully-qualified names.
Updating main issue description.
Comment #6
jhodgdonSo... 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.
Comment #12
andrewmacpherson CreditAttribution: andrewmacpherson as a volunteer and at Annertech commentedRe: #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.