You are here

public function cf_dom::change_element in Common Functionality 7.2

Changes the element from one type to another.

Parameters

DOMNode $element: The element whose type will be changed.

string $type: The new element type to use.

Return value

DOMNode |bool The changed element on success, FALSE otherwise.

1 call to cf_dom::change_element()
cf_dom::p_change_elements in modules/cf_dom/classes/cf_dom.php
Change all elements of a given element type to another type.

File

modules/cf_dom/classes/cf_dom.php, line 336
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 change_element($element, $type) {
  if (!$this->dom instanceof DOMDocument) {
    if (class_exists('cf_error')) {
      cf_error::invalid_object('this->dom');
    }
    return FALSE;
  }
  if (!$element instanceof DOMNode) {
    if (class_exists('cf_error')) {
      cf_error::invalid_object('element');
    }
    return FALSE;
  }
  if (cf_is_empty_or_non_string('type', $type)) {
    return FALSE;
  }
  return $this
    ->p_change_element($element, $type);
}