Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
context
Commits
438c2a0c
Commit
438c2a0c
authored
Apr 15, 2020
by
git
Committed by
boshtian
Apr 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2979259
by George Bills, nace_fric, strozx: Saving a block doesn't clear it's cache tags
parent
5e1d693e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
src/Plugin/ContextReaction/Blocks.php
src/Plugin/ContextReaction/Blocks.php
+17
-3
No files found.
src/Plugin/ContextReaction/Blocks.php
View file @
438c2a0c
...
...
@@ -5,6 +5,7 @@ namespace Drupal\context\Plugin\ContextReaction;
use
Drupal\Core\Plugin\PluginDependencyTrait
;
use
Drupal\Core\Session\AccountInterface
;
use
Drupal\Core\Url
;
use
Drupal\Core\Cache\Cache
;
use
Drupal\Core\Form\FormState
;
use
Drupal\Core\Render\Element
;
use
Drupal\Core\Block\BlockManager
;
...
...
@@ -15,6 +16,7 @@ use Drupal\Core\Cache\CacheableMetadata;
use
Drupal\Component\Uuid\UuidInterface
;
use
Drupal\Core\Block\BlockPluginInterface
;
use
Drupal\Core\Theme\ThemeManagerInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\context\ContextReactionPluginBase
;
use
Drupal\Core\Block\TitleBlockPluginInterface
;
use
Drupal\Core\Extension\ThemeHandlerInterface
;
...
...
@@ -79,6 +81,11 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
*/
protected
$contextRepository
;
/**
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected
$entityTypeManager
;
/**
* @var ContextHandlerInterface
*/
...
...
@@ -107,7 +114,8 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
ContextRepositoryInterface
$contextRepository
,
ContextHandlerInterface
$contextHandler
,
AccountInterface
$account
,
BlockManager
$blockManager
BlockManager
$blockManager
,
EntityTypeManagerInterface
$entityTypeManager
)
{
parent
::
__construct
(
$configuration
,
$pluginId
,
$pluginDefinition
);
...
...
@@ -118,6 +126,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
$this
->
contextHandler
=
$contextHandler
;
$this
->
account
=
$account
;
$this
->
blockManager
=
$blockManager
;
$this
->
entityTypeManager
=
$entityTypeManager
;
}
/**
...
...
@@ -134,7 +143,8 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
$container
->
get
(
'context.repository'
),
$container
->
get
(
'context.handler'
),
$container
->
get
(
'current_user'
),
$container
->
get
(
'plugin.manager.block'
)
$container
->
get
(
'plugin.manager.block'
),
$container
->
get
(
'entity_type.manager'
)
);
}
...
...
@@ -201,6 +211,10 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
$this
->
contextHandler
->
applyContextMapping
(
$block
,
$contexts
);
}
$context_entity
=
$this
->
entityTypeManager
->
getStorage
(
'context'
)
->
load
(
$configuration
[
'context_id'
]);
// Create the render array for the block as a whole.
// @see template_preprocess_block().
$blockBuild
=
[
...
...
@@ -222,7 +236,7 @@ class Blocks extends ContextReactionPluginBase implements ContainerFactoryPlugin
'block'
,
$block_placement_key
,
],
'tags'
=>
$block
->
getCacheTags
(),
'tags'
=>
Cache
::
mergeTags
(
$block
->
getCacheTags
(),
$context_entity
->
getCacheTags
()),
'contexts'
=>
$block
->
getCacheContexts
(),
'max-age'
=>
$block
->
getCacheMaxAge
(),
],
...
...
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