Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292571

Improve DX around setting the theme when adding a (custom) block

$
0
0

Follow up for #1871772-108: Convert custom blocks to content entities

Problem/Motivation

+++ b/core/modules/block/custom_block/custom_block.pages.inc
@@ -0,0 +1,153 @@
+function custom_block_add_page() {
...
+ $request = drupal_container()->get('request');
+ if (($theme = $request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) {
+ // We have navigated to this page from the block library and will keep track
+ // of the theme for redirecting the user to the configuration page for the
+ // newly created block in the given theme.
+ $options = array(
+ 'query' => array('theme' => $theme)
+ );
+ }
...
+function custom_block_add(CustomBlockType $block_type) {
...
+ $request = drupal_container()->get('request');
+ if (($theme = $request->attributes->get('theme')) && in_array($theme, array_keys(list_themes()))) {
+ // We have navigated to this page from the block library and will keep track
+ // of the theme for redirecting the user to the configuration page for the
+ // newly created block in the given theme.
+ $block->setTheme($theme);
+ }
+ return entity_get_form($block);
This definitely needs a follow-up issue to improve the DX/API situation.

My prediction is that there will be many more custom_block-alike modules in contrib in D8, and we really do not want them to have to repeat this request-futzing weirdness. :)

Proposed resolution

Investigate and improve DX of setting a theme for a block instance.

Remaining tasks

Investigate and improve DX of setting a theme for a block instance.


Viewing all articles
Browse latest Browse all 292571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>