I got an error when try to click Preview link.

LogicException: Render context is empty, because render() was called outside of a renderRoot() or renderPlain() call. Use renderPlain()/renderRoot() or #lazy_builder/#pre_render instead. in Drupal\Core\Render\Renderer->doRender() (line 263 of /core/lib/Drupal/Core/Render/Renderer.php).

Comments

lebster created an issue. See original summary.

ugolek’s picture

Status: Active » Needs review
StatusFileSize
new554 bytes

Patch is attached.

ugolek’s picture

Issue summary: View changes
ankush_03’s picture

StatusFileSize
new2.06 KB

Adding updated patch !

Remove direct service calls, add renderer service as an dependency injection.

ankush_03’s picture

bleen’s picture

Except for the minor whitespace issue in #4 this looks good to me ... I'd like at least one other review and Im ready to commit this

berdir’s picture

Status: Needs review » Reviewed & tested by the community
+++ b/src/Controller/FocalPointPreviewController.php
@@ -141,7 +151,7 @@ class FocalPointPreviewController extends ControllerBase {
     ];
 
-    $html = render($output);
+    $html = $this->renderer->renderPlain($output);
 

this in theory drops cacheability information, but afaik this is a backend and POST-only (at least until ajax will support GET) request, so it's not cached anyway. So probably fine :)

Note. render() isn't technically deprecated but should be. The real difference here is changing $renderer->render() to $renderer->renderPlain()

bleen’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.