|
From: Norman M. <no...@se...> - 2006-05-08 17:16:52
|
Hi folks,
I want to add some hint for the one who will refactor Meta, Settings and so
on.
Currently we have a contructor with $dom and $root as parameters.
So mainly a class looks like:
class oldclass {
private $dom;
private $root;
function __contruct($dom=0, $root=0) {
if (empty($dom)) {
$this->dom = new DOMDocument('1.0', 'UTF-8');
$this->root = $this->dom->createElement('root');
} else {
$this->dom = $dom;
$this->root = $root;
}
...
}
}
But the parameter $dom is not really necessary. We can get the same
functionality with this construct:
class newclass {
private $dom;
private $root;
function __contruct($root=0) {
if (empty($root)) {
$this->dom = new DOMDocument('1.0', 'UTF-8');
$this->root = $this->dom->createElement('root');
} else {
$this->dom = $root->ownerDocument;
$this->root = $root;
}
...
}
}
We need the DOMDocument only to make new DOMElements. So please use the new
approach if you refactor the classes.
Yours
Norman
|