public function LayoutBuilderHtmlEntityFormController::getContentResult in Drupal 10
Same name and namespace in other branches
- 8 core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php \Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController::getContentResult()
- 9 core/modules/layout_builder/src/Controller/LayoutBuilderHtmlEntityFormController.php \Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController::getContentResult()
Invokes the form and returns the result.
Parameters
\Symfony\Component\HttpFoundation\Request $request: The request object.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.
Return value
array The render array that results from invoking the controller.
Overrides FormController::getContentResult
File
- core/
modules/ layout_builder/ src/ Controller/ LayoutBuilderHtmlEntityFormController.php, line 38
Class
- LayoutBuilderHtmlEntityFormController
- Overrides the entity form controller service for layout builder operations.
Namespace
Drupal\layout_builder\ControllerCode
public function getContentResult(Request $request, RouteMatchInterface $route_match) {
$form = $this->entityFormController
->getContentResult($request, $route_match);
// If the form render element has a #layout_builder_element_keys property,
// first set the form element as a child of the root render array. Use the
// keys to get the layout builder element from the form render array and
// copy it to a separate child element of the root element to prevent any
// forms within the layout builder element from being nested.
if (isset($form['#layout_builder_element_keys'])) {
$build['form'] =& $form;
$layout_builder_element =& NestedArray::getValue($form, $form['#layout_builder_element_keys']);
$build['layout_builder'] = $layout_builder_element;
// Remove the layout builder element within the form.
$layout_builder_element = [];
return $build;
}
// If no #layout_builder_element_keys property, return form as is.
return $form;
}