Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
1004a87f
Commit
1004a87f
authored
Sep 02, 2013
by
webchick
Browse files
Issue
#2073507
by grasmash: Fixed Parameters passed and documented incorrectly in Views hooks.
parent
542212bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
core/modules/views/lib/Drupal/views/ViewExecutable.php
View file @
1004a87f
...
...
@@ -1357,7 +1357,7 @@ public function render($display_id = NULL) {
}
// Let modules modify the view output after it is rendered.
$module_handler
->
invokeAll
(
'views_post_render'
,
array
(
$this
,
$this
->
display_handler
->
output
,
$cache
));
$module_handler
->
invokeAll
(
'views_post_render'
,
array
(
$this
,
&
$this
->
display_handler
->
output
,
$cache
));
// Let the themes play too, because post render is a very themey thing.
foreach
(
$GLOBALS
[
'base_theme_info'
]
as
$base
)
{
...
...
@@ -1441,7 +1441,7 @@ public function preExecute($args = array()) {
}
// Let modules modify the view just prior to executing it.
\
Drupal
::
moduleHandler
()
->
invokeAll
(
'views_pre_view'
,
array
(
$this
,
$display_id
,
$this
->
args
));
\
Drupal
::
moduleHandler
()
->
invokeAll
(
'views_pre_view'
,
array
(
$this
,
$display_id
,
&
$this
->
args
));
// Allow hook_views_pre_view() to set the dom_id, then ensure it is set.
$this
->
dom_id
=
!
empty
(
$this
->
dom_id
)
?
$this
->
dom_id
:
hash
(
'sha256'
,
$this
->
storage
->
id
()
.
REQUEST_TIME
.
mt_rand
());
...
...
core/modules/views/views.api.php
View file @
1004a87f
...
...
@@ -371,13 +371,11 @@ function hook_views_form_substitutions() {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_pre_view
(
ViewExecutable
&
$view
,
&
$display_id
,
array
&
$args
)
{
// Change the display if the acting user has 'administer site configuration'
// permission, to display something radically different.
// @todo Note that this is not necessarily the best way to solve that task.
// Add a better example.
if
(
$view
->
name
==
'my_special_view'
&&
user_access
(
'administer site configuration'
)
&&
$display_id
==
'public_display'
)
{
$display_id
=
'private_display'
;
function
hook_views_pre_view
(
ViewExecutable
$view
,
$display_id
,
array
&
$args
)
{
// Modify contextual filters for my_special_view if user has 'my special permission'.
if
(
$view
->
name
==
'my_special_view'
&&
user_access
(
'my special permission'
))
{
$args
[
0
]
=
'custom value'
;
}
}
...
...
@@ -392,7 +390,7 @@ function hook_views_pre_view(ViewExecutable &$view, &$display_id, array &$args)
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_pre_build
(
ViewExecutable
&
$view
)
{
function
hook_views_pre_build
(
ViewExecutable
$view
)
{
// Because of some unexplicable business logic, we should remove all
// attachments from all views on Mondays.
// (This alter could be done later in the execution process as well.)
...
...
@@ -413,7 +411,7 @@ function hook_views_pre_build(ViewExecutable &$view) {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_post_build
(
ViewExecutable
&
$view
)
{
function
hook_views_post_build
(
ViewExecutable
$view
)
{
// If the exposed field 'type' is set, hide the column containing the content
// type. (Note that this is a solution for a particular view, and makes
// assumptions about both exposed filter settings and the fields in the view.
...
...
@@ -438,7 +436,7 @@ function hook_views_post_build(ViewExecutable &$view) {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_pre_execute
(
ViewExecutable
&
$view
)
{
function
hook_views_pre_execute
(
ViewExecutable
$view
)
{
// Whenever a view queries more than two tables, show a message that notifies
// view administrators that the query might be heavy.
// (This action could be performed later in the execution process, but not
...
...
@@ -462,7 +460,7 @@ function hook_views_pre_execute(ViewExecutable &$view) {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_post_execute
(
ViewExecutable
&
$view
)
{
function
hook_views_post_execute
(
ViewExecutable
$view
)
{
// If there are more than 100 results, show a message that encourages the user
// to change the filter settings.
// (This action could be performed later in the execution process, but not
...
...
@@ -487,7 +485,7 @@ function hook_views_post_execute(ViewExecutable &$view) {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_pre_render
(
ViewExecutable
&
$view
)
{
function
hook_views_pre_render
(
ViewExecutable
$view
)
{
// Scramble the order of the rows shown on this result page.
// Note that this could be done earlier, but not later in the view execution
// process.
...
...
@@ -524,7 +522,7 @@ function hook_views_pre_render(ViewExecutable &$view) {
*
* @see \Drupal\views\ViewExecutable
*/
function
hook_views_post_render
(
ViewExecutable
&
$view
,
&
$output
,
CacheBackendInterface
&
$cache
)
{
function
hook_views_post_render
(
ViewExecutable
$view
,
&
$output
,
CacheBackendInterface
$cache
)
{
// When using full pager, disable any time-based caching if there are fewer
// than 10 results.
if
(
$view
->
pager
instanceof
Drupal\views\Plugin\views\pager\Full
&&
$cache
instanceof
Drupal\views\Plugin\views\cache\Time
&&
count
(
$view
->
result
)
<
10
)
{
...
...
@@ -544,7 +542,7 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt
* @see hook_views_query_substitutions()
* @see \Drupal\views\Plugin\views\query\Sql
*/
function
hook_views_query_alter
(
ViewExecutable
&
$view
,
QueryPluginBase
&
$query
)
{
function
hook_views_query_alter
(
ViewExecutable
$view
,
QueryPluginBase
$query
)
{
// (Example assuming a view with an exposed filter on node title.)
// If the input for the title filter is a positive integer, filter against
// node ID instead of node title.
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment