function RenderElementBase::removeChild

Removes a child.

Parameters

int|string $name: The name of the child. Can also be an integer.

Return value

?\Drupal\Core\Render\Element\ElementInterface The removed render object if any, or NULL if the child could not be found.

Overrides ElementInterface::removeChild

File

core/lib/Drupal/Core/Render/Element/RenderElementBase.php, line 690

Class

RenderElementBase
Provides a base class for render element plugins.

Namespace

Drupal\Core\Render\Element

Code

public function removeChild(int|string $name) : ?ElementInterface {
  $return = $this->storage[$name] ?? NULL;
  unset($this->storage[$name]);
  return $return ? $this->elementInfoManager()
    ->fromRenderable($return) : NULL;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.