Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
1004a87f
Commit
1004a87f
authored
Sep 2, 2013
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2073507
by grasmash: Fixed Parameters passed and documented incorrectly in Views hooks.
parent
542212bc
No related branches found
No related tags found
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/views/lib/Drupal/views/ViewExecutable.php
+2
-2
2 additions, 2 deletions
core/modules/views/lib/Drupal/views/ViewExecutable.php
core/modules/views/views.api.php
+12
-14
12 additions, 14 deletions
core/modules/views/views.api.php
with
14 additions
and
16 deletions
core/modules/views/lib/Drupal/views/ViewExecutable.php
+
2
−
2
View file @
1004a87f
...
@@ -1357,7 +1357,7 @@ public function render($display_id = NULL) {
...
@@ -1357,7 +1357,7 @@ public function render($display_id = NULL) {
}
}
// Let modules modify the view output after it is rendered.
// 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.
// Let the themes play too, because post render is a very themey thing.
foreach
(
$GLOBALS
[
'base_theme_info'
]
as
$base
)
{
foreach
(
$GLOBALS
[
'base_theme_info'
]
as
$base
)
{
...
@@ -1441,7 +1441,7 @@ public function preExecute($args = array()) {
...
@@ -1441,7 +1441,7 @@ public function preExecute($args = array()) {
}
}
// Let modules modify the view just prior to executing it.
// 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.
// 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
());
$this
->
dom_id
=
!
empty
(
$this
->
dom_id
)
?
$this
->
dom_id
:
hash
(
'sha256'
,
$this
->
storage
->
id
()
.
REQUEST_TIME
.
mt_rand
());
...
...
This diff is collapsed.
Click to expand it.
core/modules/views/views.api.php
+
12
−
14
View file @
1004a87f
...
@@ -371,13 +371,11 @@ function hook_views_form_substitutions() {
...
@@ -371,13 +371,11 @@ function hook_views_form_substitutions() {
*
*
* @see \Drupal\views\ViewExecutable
* @see \Drupal\views\ViewExecutable
*/
*/
function
hook_views_pre_view
(
ViewExecutable
&
$view
,
&
$display_id
,
array
&
$args
)
{
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.
// Modify contextual filters for my_special_view if user has 'my special permission'.
// @todo Note that this is not necessarily the best way to solve that task.
if
(
$view
->
name
==
'my_special_view'
&&
user_access
(
'my special permission'
))
{
// Add a better example.
$args
[
0
]
=
'custom value'
;
if
(
$view
->
name
==
'my_special_view'
&&
user_access
(
'administer site configuration'
)
&&
$display_id
==
'public_display'
)
{
$display_id
=
'private_display'
;
}
}
}
}
...
@@ -392,7 +390,7 @@ function hook_views_pre_view(ViewExecutable &$view, &$display_id, array &$args)
...
@@ -392,7 +390,7 @@ function hook_views_pre_view(ViewExecutable &$view, &$display_id, array &$args)
*
*
* @see \Drupal\views\ViewExecutable
* @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
// Because of some unexplicable business logic, we should remove all
// attachments from all views on Mondays.
// attachments from all views on Mondays.
// (This alter could be done later in the execution process as well.)
// (This alter could be done later in the execution process as well.)
...
@@ -413,7 +411,7 @@ function hook_views_pre_build(ViewExecutable &$view) {
...
@@ -413,7 +411,7 @@ function hook_views_pre_build(ViewExecutable &$view) {
*
*
* @see \Drupal\views\ViewExecutable
* @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
// 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
// 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.
// assumptions about both exposed filter settings and the fields in the view.
...
@@ -438,7 +436,7 @@ function hook_views_post_build(ViewExecutable &$view) {
...
@@ -438,7 +436,7 @@ function hook_views_post_build(ViewExecutable &$view) {
*
*
* @see \Drupal\views\ViewExecutable
* @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
// Whenever a view queries more than two tables, show a message that notifies
// view administrators that the query might be heavy.
// view administrators that the query might be heavy.
// (This action could be performed later in the execution process, but not
// (This action could be performed later in the execution process, but not
...
@@ -462,7 +460,7 @@ function hook_views_pre_execute(ViewExecutable &$view) {
...
@@ -462,7 +460,7 @@ function hook_views_pre_execute(ViewExecutable &$view) {
*
*
* @see \Drupal\views\ViewExecutable
* @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
// If there are more than 100 results, show a message that encourages the user
// to change the filter settings.
// to change the filter settings.
// (This action could be performed later in the execution process, but not
// (This action could be performed later in the execution process, but not
...
@@ -487,7 +485,7 @@ function hook_views_post_execute(ViewExecutable &$view) {
...
@@ -487,7 +485,7 @@ function hook_views_post_execute(ViewExecutable &$view) {
*
*
* @see \Drupal\views\ViewExecutable
* @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.
// 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
// Note that this could be done earlier, but not later in the view execution
// process.
// process.
...
@@ -524,7 +522,7 @@ function hook_views_pre_render(ViewExecutable &$view) {
...
@@ -524,7 +522,7 @@ function hook_views_pre_render(ViewExecutable &$view) {
*
*
* @see \Drupal\views\ViewExecutable
* @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
// When using full pager, disable any time-based caching if there are fewer
// than 10 results.
// 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
)
{
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
...
@@ -544,7 +542,7 @@ function hook_views_post_render(ViewExecutable &$view, &$output, CacheBackendInt
* @see hook_views_query_substitutions()
* @see hook_views_query_substitutions()
* @see \Drupal\views\Plugin\views\query\Sql
* @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.)
// (Example assuming a view with an exposed filter on node title.)
// If the input for the title filter is a positive integer, filter against
// If the input for the title filter is a positive integer, filter against
// node ID instead of node title.
// node ID instead of node title.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment