- Issue created by @JayDarnell
- 🇨🇦Canada JayDarnell Guelph, Ontario
The initial merge request takes care of not tracking these items for export, but I need to update it so the custom blocks aren't deleted on import.
- 🇨🇭Switzerland bircher 🇨🇿
I am sympathetic to this request. But I would rather not have any code for specific config in the event subscriber. It is complicated enough as it is.
Especially if dealing with the issue could easily be done with the new hook we added. So the easiest is to create a module which only implements the hook and adds an ignore pattern for all the content block placements.
Then by virtue of installing that specific module you say that you want to ignore all the content blocks. You could then on your site even add a pattern to not ignore a specific content block.I can provide feedback on the hook implementation of course. If you want me to maintain it as a sub module of config ignore then it needs to have test coverage, if you want to maintain it as a standalone module you are welcome to do so too. I am happy to help with the hook in either case.
- 🇨🇦Canada JayDarnell Guelph, Ontario
Hi bircher, first of all thank you for this awesome module. I wasn't quite sure how to utilize the new hook and would greatly appreciate any guidance in that respect. I couldn't figure out how to create a pattern that only ignores block config from the block_content module because the naming convention for block_content blocks and blocks from a different module all follow the same naming convention: block.block.
_.ymlExamples:
We have a custom block type called "Text" that is simply a block description and body field. I created one of these with the block description "Carl Sagan" and config management wanted to export the file: block.block.mytheme_carlsagan.yml.
A block from the book module for book navigation is exported as the file: block.block.mytheme_booknavigation.yml.
In our environment end users could create an infinite number of custom text blocks so we don't want to track any of them, but with the way these ymls are named, I can't tell the difference between a block created by block_content and other blocks. The only difference I could find was the settings->provider value within each of their yaml files (which tells us the module responsible for creating them)
Thank you in advance for your help. If we can avoid using a one off patch and can work with the module as provided that would be preferable.
- 🇨🇭Switzerland bircher 🇨🇿
Hi sorry for the wait.
The hook should look something like:
/** * Implements hook_config_ignore_ignored_alter(). */ function mymodule_config_ignore_ignored_alter(\Drupal\config_ignore\ConfigIgnoreConfig $ignored) { $patterns = []; // We ignore only the content blocks that exist on the site. // But because we ignore them also when exporting they should not get into the sync directory. foreach(\Drupal::configFactory()->listAll('block.block') as $name) { $block = \Drupal::config($name); if ($block->get('settings.provider') === 'block_content') { $patterns[] = $name; } } if (empty($patterns)) { // There were no content blocks. return; } // This is the easiest way to add patterns to the ConfigIgnoreConfig object. $blockIgnore = new \Drupal\config_ignore\ConfigIgnoreConfig('simple', $patterns); $ignored->mergeWith($blockIgnore); }
Like I said I would be ok adding this as a sub-module of config ignore because it would serve as a great example of such a hook implementation, but someone needs to write a test for it.
- 🇨🇦Canada JayDarnell Guelph, Ontario
Thanks so much bircher. I need some practice writing tests as it is. If you want I could turn this issue into a feature request and create a new branch and PR to add this as a sub module with a suitable test.
- Assigned to JayDarnell
- Issue was unassigned.
- 🇮🇳India sakthi_dev
@JayDarnell, As there is no activity more than 2 months I unassigned you from this issue.
- Merge request !28Issue#3405605: Create sub module for ignoring block content configs. → (Open) created by sakthi_dev
- Status changed to Needs review
8 months ago 11:55am 26 March 2024 - 🇮🇳India sakthi_dev
Hi @bircher and @JayDarnell, created the sub module for ignoring block content along with the test. Please review.
- Status changed to Needs work
7 months ago 11:17am 14 April 2024 - 🇨🇭Switzerland bircher 🇨🇿
This should be rebased.
But more importantly the test added in this issue is not doing its job. The test needs to assert that blocks are indeed ignored. - Status changed to Needs review
7 months ago 1:54pm 23 April 2024 - Status changed to Needs work
7 months ago 8:04am 24 April 2024 - 🇨🇭Switzerland bircher 🇨🇿
The test does still not test what this module is made to do.