Skip to content
Snippets Groups Projects

Issue #3416266 by grimreaper, kevinquillen, hydra: Switch from useing array_pop/array_push for section manipulation to preserve key integrity and ensure module integration compatibility

Merged Issue #3416266 by grimreaper, kevinquillen, hydra: Switch from useing array_pop/array_push for section manipulation to preserve key integrity and ensure module integration compatibility
1 file
+ 7
4
Compare changes
  • Side-by-side
  • Inline
@@ -81,8 +81,10 @@ class SectionLibraryRender implements TrustedCallbackInterface {
// Add save to library link to the built section.
elseif (isset($section['configure']) && isset($section['configure']['#url'])) {
$params = $section['configure']['#url']->getRouteParameters();
// Pop the last item to add the link before it.
$last_item_section = array_pop($sections[$key]);
// Save the layout to replace it later in the last position.
$layout_section = $sections[$key]['layout-builder__section'];
unset($sections[$key]['layout-builder__section']);
$add_to_library_url = Url::fromRoute(
'section_library.add_section_to_library',
[
@@ -108,8 +110,9 @@ class SectionLibraryRender implements TrustedCallbackInterface {
'#url' => $add_to_library_url,
'#access' => $add_to_library_url->access(),
];
// Push the last item again.
array_push($sections[$key], $last_item_section);
// Ensure layout section is the last item.
$sections[$key]['layout-builder__section'] = $layout_section;
}
}
Loading