- Issue created by @Grimreaper
- Merge request !43Draft: Issue #3482151 by grimreaper: Menu: fix module check. → (Open) created by Grimreaper
- 🇫🇷France Grimreaper France 🇫🇷
To store overrides, it would be nice to be able to store into core.menu.static_menu_link_overrides.yml like core does, but the allowed keys of the overrides are hardcoded, not possible to extend currently.
Maybe in a second time when icons in core will have more implementations.
So I will currently store in a ui_icons_menu.settings.yml
- 🇫🇷France Grimreaper France 🇫🇷
When I try to add an element with:
function ui_icons_menu_form_menu_link_edit_alter(&$form, FormStateInterface $form_state, $form_id) { $options = $form_state->getBuildInfo()['args'][0]->getOptions(); $form['icon'] = [ '#type' => 'details', '#title' => t('Icon'), ]; $form['icon']['icon'] = [ '#type' => 'icon_autocomplete', '#title' => t('Icon'), '#default_value' => !empty($options['icon']['icon']) ? $options['icon']['icon'] : '', '#show_settings' => TRUE, ];
I got an ajax error after selecting an icon.
<em class="placeholder">LogicException</em> : The database connection is not serializable. This probably means you are serializing an object that has an indirect reference to the database connection. Adjust your code so that is not necessary. Alternatively, look at DependencySerializationTrait as a temporary solution. in <em class="placeholder">Drupal\Core\Database\Connection->__sleep()</em> (line <em class="placeholder">1920</em> of <em class="placeholder">core/lib/Drupal/Core/Database/Connection.php</em> ). <pre class="backtrace">serialize(Array) (Line: 14) Drupal\Component\Serialization\PhpSerialize::encode(Array) (Line: 129)
I trie to put the DependencySerializationTrait in multiple classes in ui_icons, not better.
The problem comes from ui_icons/src/Element/IconAutocomplete.php::processIconAjaxForm
$element['icon_id']['#ajax'] = [ 'callback' => [static::class, 'buildSettingsAjaxCallback'], 'options' => [ 'query' => [ 'element_parents' => implode('/', $element['#array_parents']), ], ], // Autocomplete is already doing the ajax progress. 'progress' => [ 'type' => 'none', ], 'disable-refocus' => TRUE, 'wrapper' => $ajax_wrapper_id, 'effect' => 'none', // As we used autocomplete we want matching events. // @todo check for too early errors related to change. 'event' => 'autocompleteclose change', ];
- 🇫🇷France Grimreaper France 🇫🇷
Hi,
Except for the AJAX problem, MR is ok for review.
I have not executed code quality tools for now as it is more in a POC state waiting for maintainers feedback.
- 🇫🇷France Grimreaper France 🇫🇷
Wondering about translatability of the alt settings in case of YAML declared links.