Guest User

Untitled

a guest
Dec 12th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. $webform = Drupal::entityTypeManager()->getStorage('webform')->load($machineName);
  2. $viewBuilder = Drupal::service('entity_type.manager')->getViewBuilder('webform');
  3. $formBuild = $viewBuilder->view($webform);
  4. return render($formBuild);
  5.  
  6. $build = [
  7. '#type' => 'webform',
  8. '#webform' => $machineName,
  9. ];
  10.  
  11. $result = new FilterProcessResult($text);
  12. ...
  13. // We need to render the embedded entity:
  14. // - without replacing placeholders, so that the placeholders are
  15. // only replaced at the last possible moment. Hence we cannot use
  16. // either renderPlain() or renderRoot(), so we must use render().
  17. // - without bubbling beyond this filter, because filters must
  18. // ensure that the bubbleable metadata for the changes they make
  19. // when filtering text makes it onto the FilterProcessResult
  20. // object that they return ($result). To prevent that bubbling, we
  21. // must wrap the call to render() in a render context.
  22. $entity_output = $this->renderer->executeInRenderContext(new RenderContext(), function () use (&$build) {
  23. return $this->renderer->render($build);
  24. });
  25. $result = $result->merge(BubbleableMetadata::createFromRenderArray($build));
Add Comment
Please, Sign In to add comment