- ๐บ๐ธUnited States smustgrave
Since there hasn't been a follow up going to close for now.
If still a valid bug please reopen adding steps to reproduce. Will have to determine what has a NULL lable though per #8.
Thanks all!
- ๐ฉ๐ชGermany Anybody Porta Westfalica
More or less happy to be able to add the missing information here. At least in my case it's the
layout_builder_blank
layout causing this.These are the values it has
layout_builder_blank => Drupal\Core\Layout\LayoutDefinition#1237 (19) Properties (19) protected id -> string (20) "layout_builder_blank" protected class -> string (47) "Drupal\layout_builder\Plugin\Layout\BlankLayout" protected provider -> string (14) "layout_builder" protected deriver -> null protected label -> null protected description -> null protected category -> null protected template -> null protected templatePath -> null protected theme_hook -> string (6) "layout" โงprotected path -> string (27) "core/modules/layout_builder" protected library -> null protected icon -> null protected icon_map -> null protected regions -> array (0) protected default_region -> null protected additional -> array (0) protected contextDefinitions -> array (0) protected config_dependencies -> array (0)
within the getSortedDefinitions() function in LayoutPluginManager.php:
/** * {@inheritdoc} * * @return \Drupal\Core\Layout\LayoutDefinition[] */ public function getSortedDefinitions(array $definitions = NULL, $label_key = 'label') { // Sort the plugins first by category, then by label. $definitions = $definitions ?? $this->getDefinitions(); uasort($definitions, function (LayoutDefinition $a, LayoutDefinition $b) { if ($a->getCategory() != $b->getCategory()) { return strnatcasecmp($a->getCategory(), $b->getCategory()); } return strnatcasecmp($a->getLabel(), $b->getLabel()); }); return $definitions; }
This is the BlankLayout.php definition:
<?php namespace Drupal\layout_builder\Plugin\Layout; use Drupal\Core\Layout\LayoutDefault; /** * Provides a layout plugin that produces no output. * * @see \Drupal\layout_builder\Field\LayoutSectionItemList::removeSection() * @see \Drupal\layout_builder\SectionListTrait::addBlankSection() * @see \Drupal\layout_builder\SectionListTrait::hasBlankSection() * * @internal * This layout plugin is intended for internal use by Layout Builder only. * * @Layout( * id = "layout_builder_blank", * ) */ class BlankLayout extends LayoutDefault { /** * {@inheritdoc} */ public function build(array $regions) { // Return no output. return []; } }
So it makes sense that ->getLabel and ->getCategory return NULL.
The question is, why it's not being sorted out.
I'm building a list of layouts using
Drupal\Core\Layout\LayoutPluginManager->getLayoutOptions()
and would expect this internal layout isn't returned there, but it is!Any ideas? Why do I have to sort it out manually when calling the above function?
Layout builder does the following:
/** * Implements hook_plugin_filter_TYPE_alter(). */ function layout_builder_plugin_filter_layout_alter(array &$definitions, array $extra, $consumer) { // Hide the blank layout plugin from listings. unset($definitions['layout_builder_blank']); }
But it doesn't have any effect here?
Related issues:
๐ layout_builder_blank must not be disabled Fixed - Status changed to Active
over 1 year ago 7:56pm 31 October 2023 - ๐ฉ๐ชGermany Anybody Porta Westfalica
I guess we should close this as duplicate of ๐ Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts Fixed but try to fix it.
@longwave & @cilefen would you mind taking a look perhaps?
- Status changed to Closed: duplicate
over 1 year ago 6:06am 1 November 2023 - ๐ฉ๐ชGermany Anybody Porta Westfalica
Closing this as duplicate of ๐ Add missing category to Drupal\layout_builder\Plugin\Layout\BlankLayout and let modules and themes alter the list of layouts Fixed . Let's proceed there.
@longwave & @cilefen would you mind taking a look perhaps? Or anyone else who can tell why
layout_builder_plugin_filter_layout_alter()
is not called to sort out that internal layout?