Timeline for How to clear the a block cache programmically
Current License: CC BY-SA 4.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 25, 2020 at 18:18 | vote | accept | iStryker | ||
Jun 25, 2020 at 18:18 | comment | added | iStryker | Thanks for adding to Answer. It works! | |
Jun 25, 2020 at 17:55 | history | edited | 4uk4 | CC BY-SA 4.0 |
add access caching
|
Jun 25, 2020 at 17:39 | comment | added | iStryker | Your 2 examples do work for the message field, however, they do not work for my blockAccess. My answer does. Hope you can read this... protected function blockAccess(AccountInterface $account) { $config = \Drupal::config(static::SETTINGS); $display = $config->get('display_option'); if ($display) return AccessResult::allowed(); } return AccessResult::forbidden();} | |
Jun 25, 2020 at 15:13 | history | edited | 4uk4 | CC BY-SA 4.0 |
add another example
|
Jun 25, 2020 at 13:53 | comment | added | sonfd |
As a note, in case it's unclear, if you're building your custom block with your own plugin, you can add the cache dependencies in your build() method.
|
|
Jun 25, 2020 at 12:48 | comment | added | sonfd |
The relevant cache tag in this instance is config:my_module.settings . See Cache tags on d.o.
|
|
Jun 25, 2020 at 12:42 | history | answered | 4uk4 | CC BY-SA 4.0 |