You are here

public function cf_dom::remove_element in Common Functionality 7.2

Removes the given element from its parent.

This preserves child elements. To remove entirely, use removeElement() directly.

Parameters

DOMNode $element: The object to convert to markup text.

bool $preserve_children: (optional) If TRUE, children are re-attached to the parent node to preserved their location in the markup. If FALSE, the children remain attached to the removed element.

Return value

bool The removed element on success, FALSE otherwise.

File

modules/cf_dom/classes/cf_dom.php, line 423
Provides the cf_dom handling class.

Class

cf_dom
The cf_dom class assists in setting up and managing the custom dom object.

Code

public function remove_element($element, $preserve_children = TRUE) {
  if (!$element instanceof DOMNode) {
    if (class_exists('cf_error')) {
      cf_error::invalid_object('element');
    }
    return FALSE;
  }
  if (!is_bool($preserve_children)) {
    if (class_exists('cf_error')) {
      cf_error::invalid_bool('preserve_children');
    }
    return FALSE;
  }
  return $this
    ->p_remove_element($element, $preserve_children);
}