Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
Project
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
Gorodkov Denis
Project
Commits
0a4bbdc9
Commit
0a4bbdc9
authored
Jun 20, 2022
by
Gorodkov Denis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor cache context
parent
222d0f94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
0 deletions
+29
-0
cache_context.info.yml
...croot/modules/custom/cache_context/cache_context.info.yml
+7
-0
cache_context.module
...docroot/modules/custom/cache_context/cache_context.module
+22
-0
No files found.
app/docroot/modules/custom/cache_context/cache_context.info.yml
0 → 100644
View file @
0a4bbdc9
name
:
Cache context
description
:
Custom task
package
:
Tasks
type
:
module
core
:
8.x
core_version_requirement
:
^8 || ^9
app/docroot/modules/custom/cache_context/cache_context.module
0 → 100644
View file @
0a4bbdc9
<?php
/**
* Implements hook_node_view().
*/
function
cache_context_node_view
(
array
&
$build
,
$node
)
{
if
(
$node
->
bundle
()
==
'people'
)
{
$build
[
"elements"
][
"#cache"
][
"contexts"
][]
=
'url.query_args'
;
}
}
/**
* Implements hook_preprocess().
*/
function
cache_context_preprocess
(
&
$variables
,
$hook
)
{
if
(
$hook
==
'details'
and
$variables
[
"element"
][
"#bundle"
]
==
'people'
and
$variables
[
"element"
][
"#group_name"
]
==
'group_films'
)
{
$get
=
\Drupal
::
request
()
->
query
->
get
(
'tab'
);
if
(
$get
==
'films'
)
{
$variables
[
"attributes"
][
'open'
]
=
''
;
}
}
}
Write
Preview
Markdown
is supported
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