// automatically by the Renderer. Adding them as though they are
// supported allows us to avoid throwing an exception 100% of the time.
'#weight',
- '#printed'
+ '#printed',
];
$unsupported_keys = array_diff(array_keys($elements), $supported_keys);
if (count($unsupported_keys)) {
}
// All render elements support #markup and #plain_text.
- if (!empty($elements['#markup']) || !empty($elements['#plain_text'])) {
+ if (isset($elements['#markup']) || isset($elements['#plain_text'])) {
$elements = $this->ensureMarkupIsSafe($elements);
}
// being rendered: any code can add messages to render.
// This violates the principle that each lazy builder must be able to render
// itself in isolation, and therefore in any order. However, we cannot
- // change the way drupal_set_message() works in the Drupal 8 cycle. So we
- // have to accommodate its special needs.
+ // change the way \Drupal\Core\Messenger\Messenger works in the Drupal 8
+ // cycle. So we have to accommodate its special needs.
// Allowing placeholders to be rendered in a particular order (in this case:
// last) would violate this isolation principle. Thus a monopoly is granted
// to this one special case, with this hard-coded solution.
* @see \Drupal\Component\Utility\Xss::filterAdmin()
*/
protected function ensureMarkupIsSafe(array $elements) {
- if (empty($elements['#markup']) && empty($elements['#plain_text'])) {
- return $elements;
- }
-
- if (!empty($elements['#plain_text'])) {
+ if (isset($elements['#plain_text'])) {
$elements['#markup'] = Markup::create(Html::escape($elements['#plain_text']));
}
elseif (!($elements['#markup'] instanceof MarkupInterface)) {