function RenderElementBase::changeType
Change the type of the element.
Changes only the #type all other properties and children are preserved.
@template T of \Drupal\Core\Render\Element\ElementInterface
Parameters
class-string<T> $class: The class of the new render object.
Return value
T The new render object.
Overrides ElementInterface::changeType
File
-
core/
lib/ Drupal/ Core/ Render/ Element/ RenderElementBase.php, line 699
Class
- RenderElementBase
- Provides a base class for render element plugins.
Namespace
Drupal\Core\Render\ElementCode
public function changeType(string $class) : ElementInterface {
$this->storage['#type'] = $this->elementInfoManager()
->getIdFromClass($class);
unset($this->storage['##object']);
return $this->elementInfoManager()
->fromRenderable($this->storage);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.