Problem/Motivation
In token_requirements, problems are output as follows:
$requirements['token-' . $problem_key] = array(
'title' => $problem['label'],
// @todo Use render arrays. See https://drupal.org/node/2195739
'value' => \Drupal::theme()->render('item_list', array('items' => $problems)),
'severity' => $problem['severity'],
);
This works fine on the requirements page, where the list of requirements is being rendered. However, when calling SystemManager::listRequirements() during hook_cron, for example, this causes an Exception:
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()
Proposed resolution
From what I can see in the documentation for renderRoot and renderPlain, using renderPlain is probably the best option in this case. We can also use this time to fix the todo in the code above.
I'll attach a patch right away.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | token_requirements-2686959-2.patch | 888 bytes | Mirroar |
Comments
Comment #2
Mirroar commentedAnd here's the patch I'd suggest.
Comment #3
berdirMakes sense, thanks.
Comment #5
berdirCommitted.