Skip to content

Conversation

@laryn
Copy link
Contributor

@laryn laryn commented Jan 4, 2025

@backdrop-ci
Copy link
Collaborator

Related to: backdrop/backdrop-issues#6808

Copy link
Member

@quicksketch quicksketch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great! I have some questions about namespaces.

Unfortunately I don't think I can write test coverage in time for the 1.32.0 feature freeze, so this likely won't make it for this release.

Comment on lines 2395 to 2399
* @param string $flexible_template_type
* The type of flexible template to save. Defaults to 'flexible'.
*/
function layout_flexible_tempstore_set(LayoutFlexibleTemplate $flexible_template) {
tempstore_set('layout.flexible', $flexible_template->name, $flexible_template, 604800);
function layout_flexible_tempstore_set(LayoutFlexibleTemplate $flexible_template, $flexible_template_type = 'flexible') {
tempstore_set('layout.' . $flexible_template_type, $flexible_template->name, $flexible_template, 604800);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is only tempstore storage, we don't need to be compatible with the previous tempstore naming. I would suggest maybe making $flexible_template_type = 'default' by default, and save the tempstore location like this:

tempstore_set('layout.flexible.' . $flexible_template_type, $flexible_template->name, $flexible_template, 604800);

That makes it more clear that the tempstore entries are different kinds of flexible layout templates, and not tempstore of other layout configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below.

$item = layout_flexible_template_load($flexible_template_name);
$caches = &backdrop_static(__FUNCTION__ . ':' . $flexible_template_type, array());
if (!isset($caches[$flexible_template_type . ':' . $flexible_template_name])) {
if (!$item = tempstore_get('layout.' . $flexible_template_type, $flexible_template_name)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, make $flexible_template_type default to default and update this to:

Suggested change
if (!$item = tempstore_get('layout.' . $flexible_template_type, $flexible_template_name)) {
if (!$item = tempstore_get('layout.flexible.' . $flexible_template_type, $flexible_template_name)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See below.

else {
$configs = array();
$config_names = config_get_names_with_prefix('layout.flexible.');
$config_names = config_get_names_with_prefix('layout.' . $flexible_type . '.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, now I see. We also get into config file names here, which would be cumbersome to rename. We could possibly do something like:

Suggested change
$config_names = config_get_names_with_prefix('layout.' . $flexible_type . '.');
$flexible_config_type = ($flexible_type === 'default' ? 'flexible' : 'flexible_' . $flexible_type);
$config_names = config_get_names_with_prefix('layout.' . $flexible_config_type . '.');

Which would use the current config name for flexible templates and append the namespace to the word "flexible_" if using something else.

@laryn What kind of names are you expecting for the $flexible_type variable? If we left as-is, we'd need to safe-guard certain words like "layout" and "settings" to prevent config name clashes, which is why I would prefer doing name-spacing.

@indigoxela, if you have some suggestions on naming (having led our "layout" vs. "layout template"), I would love your feedback here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@quicksketch I added a change that processes the template type string and prefixes it with 'custom_' if it's not either 'flexible' or 'layout' (from core usage). See _layout_check_template_type(). I haven't changed the tempstore names or changed references to 'flexible' to be 'default' as you floated in another comment, because the template type is used in config as well, as you found here. Let me know your thoughts on the current state.

@dragonbot
Copy link
Collaborator

Tugboat has finished building a preview for this pull request!

Website: https://pr4977-2snumhssqoe5q0xf7592fzcm6p3tv8lw.tugboatqa.com/
Username: admin
Password: bbe085fcec6b

This preview will automatically expire on the 19th of February, 2026.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to specify a Layout template type

4 participants