function RenderElementBase::toRenderable
Returns a render array.
Parameters
string|null $wrapper_key: An optional wrapper.
Return value
array|\Drupal\Core\Render\Element\ElementInterface A render array. Make sure to take the return value as a reference. If $wrapper_key is not given then the stored render element is returned. If $wrapper_key is given then [$wrapper_key => &$element] is returned. The return value is typed with array|ElementInterface to prepare for Drupal 12, where the plan for this method is to return an ElementInterface object. If that plan goes through then in Drupal 13 support for render arrays will be dropped.
Overrides ElementInterface::toRenderable
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ RenderElementBase.php, line 580
Class
- RenderElementBase
- Provides a base class for render element plugins.
Namespace
Drupal\Core\Render\ElementCode
public function &toRenderable(?string $wrapper_key = NULL) : array {
if ($wrapper_key) {
$return = [
$wrapper_key => &$this->storage,
];
return $return;
}
return $this->storage;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.