- Issue created by @thejimbirch
- Assigned to Akhil Babu
- Merge request !11161Issues/3491972; Add a config action to alter block settings. → (Open) created by Akhil Babu
- 🇮🇳India Akhil Babu Chengannur
I have added a config action 'setBlockSettings' for updating the block settings
config: actions: block.block.claro_primary_local_tasks: setBlockSettings: secondary: false
Please review. I will add the tests if the current implementation looks good.
- 🇺🇸United States smustgrave
Would recommend adding test coverage to show the solution works.
- 🇺🇸United States thejimbirch Cape Cod, Massachusetts
Adding Needs change record tag, which I can try to add.
- 🇺🇸United States phenaproxima Massachusetts
I think we could actually significantly simplify this.
ConfigEntityBase already exposes
set()
as a config action. This custom action is really just doing validation, which is already covered by config validation!So you could already change block settings:
block.block.foo: set: property_name: settings value: ....
So do we actually need this patch at all? We could probably just close it and update our documentation, no?
- 🇺🇸United States phenaproxima Massachusetts
Discussed in Slack with @thejimbirch and @alexpott: https://drupal.slack.com/archives/C2THUBAVA/p1740500323369529
I think we agreed that a complex config action wrapping
set()
, although it works, feels like the wrong approach here.The real problem is that Block entities don't have a dedicated method to update their settings. If they did, then we'd just throw the
#[ActionMethod]
annotation on it, and call it a day.So why don't we just...do that? Let's add a new method,
Block::setSettings()
, and expose it as a config action method. Tagging this issue for a re-title, issue summary update, and re-scope.Since there is a 1:1 rule about classes and interfaces, we can also add
BlockInterface::setSettings()
too.