Skip to content
Snippets Groups Projects
Commit d8abfb3f authored by Justin Toupin's avatar Justin Toupin
Browse files

Issue #3470915: Not compatible with layout_paragraphs 2.1.0

parent c794c71a
No related branches found
No related tags found
1 merge request!63Fix compatibility with Layout Paragraphs 2.1.x
......@@ -198,6 +198,10 @@ function _mercury_editor_replace_ajax_class(&$classes) {
function _mercury_editor_replace_layout_paragraphs_routes(Url &$url) {
$route_name = $url->getRouteName();
$parameters = $url->getRouteParameters();
// Compatibility with layout_paragraphs 2.1.x.
if (!empty($parameters['paragraph_type_id']) && empty($parameters['paragraph_type'])) {
$parameters['paragraph_type'] = $parameters['paragraph_type_id'];
}
$options = $url->getOptions();
$route_name = str_replace('layout_paragraphs.', 'mercury_editor.', $route_name);
$url = Url::fromRoute($route_name, $parameters, $options);
......
......@@ -179,13 +179,17 @@ class InsertComponentController extends ComponentFormController {
*
* Uses mercury editor form class instead of layout paragraphs form class.
*/
public function insertForm(Request $request, LayoutParagraphsLayout $layout_paragraphs_layout, ParagraphsTypeInterface $paragraph_type) {
public function insertForm(Request $request, LayoutParagraphsLayout $layout_paragraphs_layout, ParagraphsTypeInterface | string $paragraph_type) {
$parent_uuid = $request->query->get('parent_uuid');
$region = $request->query->get('region');
$sibling_uuid = $request->query->get('sibling_uuid');
$placement = $request->query->get('placement');
if (is_string($paragraph_type)) {
$paragraph_type = $this->entityTypeManager()->getStorage('paragraphs_type')->load($paragraph_type);
}
$form = $this->formBuilder()->getForm('\Drupal\mercury_editor\Form\InsertComponentForm', $layout_paragraphs_layout, $paragraph_type, $parent_uuid, $region, $sibling_uuid, $placement);
return $this->openForm($form, $layout_paragraphs_layout);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment