Re: Re: Extending DOMNode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Eli wrote:
> Rob Richards wrote:
>> Due to the internals of the DOM extension, you need to register the
>> class types that are actually instantiated and not the underlying base
>> DOMNode class. Unfortunately in your case this means you need to
>> register all of those classes separately.
>>
>> $dom->registerNodeClass('DOMElement','MyDOMNode');
>> $dom->registerNodeClass('DOMAttr','MyDOMNode');
>> $dom->registerNodeClass('DOMText','MyDOMNode');
>> ...
> 
> Not good... :-(
> 
> <?php
> class MyDOMNode extends DOMNode {
>     public $x = 100;
> }
> 
> $dom = new DOMDocument();
> $dom->registerNodeClass('DOMElement','MyDOMNode');
> ?>
> 
> PHP Fatal error:  DOMDocument::registerNodeClass(): Class MyDOMNode is
> not derived from DOMElement.
> 
> So I have to extend DOMElement and register MyDOMElement. But all my
> nodes should be also based on MyDOMNode.
> Problem is that in PHP you can only extend one class in a time, so you
> cannot build your own class-tree which extends a base class-tree of DOM.
> :-/

maybe the runkit extension can help - no idea how big it might explode in your
face if you try to hack the DOM* stuff with runkit :-)

you never stated why you want to extend all the DOM classes, maybe there
is a different way of achieving what you want (i.e. without going through the
hassle of what you seem to have to do at the moment)

> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux