Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bestreply
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
bestreply
Commits
2c1feffa
Commit
2c1feffa
authored
1 year ago
by
nico.b
Committed by
Kevin Robinson
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3326524
: Content of drupalSettings.bestreply not up-to-date
parent
a30ca46d
No related branches found
No related tags found
1 merge request
!3
Issue #3326524: Content of drupalSettings.bestreply not up-to-date
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bestreply.module
+6
-0
6 additions, 0 deletions
bestreply.module
src/Controller/BestReplyController.php
+5
-0
5 additions, 0 deletions
src/Controller/BestReplyController.php
with
11 additions
and
0 deletions
bestreply.module
+
6
−
0
View file @
2c1feffa
...
...
@@ -52,6 +52,12 @@ function bestreply_node_view(array &$build, EntityInterface $entity, EntityViewD
$build
[
'#attached'
][
'drupalSettings'
][
'bestreply'
][
'name'
]
=
$br_name
;
$build
[
'#attached'
][
'drupalSettings'
][
'bestreply'
][
'ismarked'
]
=
$br_id
;
// Add cache tags that can be invalidated if best reply is marked or cleared such that
// drupalSettings are always up-to-date.
$build
[
'#cache'
]
=
[
'tags'
=>
[
'bestreply:node:'
.
$entity
->
id
()]
];
if
(
$if_comments_available
&&
$br_id
&&
\Drupal
::
currentUser
()
->
hasPermission
(
'view bestreply'
))
{
$bestreply_comment_link
=
t
(
'View @bestreply.'
,
[
'@bestreply'
=>
$br_name
]);
$links
[
'bestreply-view'
]
=
[
...
...
This diff is collapsed.
Click to expand it.
src/Controller/BestReplyController.php
+
5
−
0
View file @
2c1feffa
...
...
@@ -3,6 +3,7 @@
namespace
Drupal\bestreply\Controller
;
use
Drupal\Core\Access\AccessResult
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Config\ConfigFactory
;
use
Drupal\Core\Controller\ControllerBase
;
use
Drupal\comment\CommentInterface
;
...
...
@@ -141,6 +142,9 @@ class BestReplyController extends ControllerBase implements ContainerInjectionIn
'dt'
=>
$dt
,
]);
}
Cache
::
invalidateTags
([
'bestreply:node:'
.
$comment
->
getCommentedEntityId
()]);
if
(
$js
)
{
$status
=
(
$rt
)
?
TRUE
:
FALSE
;
print
Json
::
encode
([
...
...
@@ -159,6 +163,7 @@ class BestReplyController extends ControllerBase implements ContainerInjectionIn
public
function
clear
(
CommentInterface
$comment
,
$js
=
NULL
)
{
if
(
bestreply_ismarked
(
$comment
->
getCommentedEntityId
()))
{
$rt
=
$this
->
connection
->
query
(
"DELETE FROM
{
bestreply
}
WHERE nid = :nid"
,
[
'nid'
=>
$comment
->
getCommentedEntityId
()]);
Cache
::
invalidateTags
([
'bestreply:node:'
.
$comment
->
getCommentedEntityId
()]);
}
if
(
$js
)
{
$status
=
(
$rt
)
?
TRUE
:
FALSE
;
...
...
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