|
Posted by Schraalhans Keukenmeester on 05/14/07 20:29
At Mon, 14 May 2007 09:47:15 -0700, carrion let his monkeys type:
> On 14 Mai, 18:36, ZeldorBlat <zeldorb...@gmail.com> wrote:
>> On May 14, 12:14 pm, carrion <hofmann.johan...@gmail.com> wrote:
>>
>>
>>
>> > >...
>> > > > 3. can I get __autoload to help me out of this?
>>
>> > > Absolutely. I highly recommend the use of __autoload() for a lot
>> > > of reasons, not the least of which is the problem you've described.
>>
>> > > function __autoload($class_name) {
>> > > $fn = $class_name . '.php';
>> > > require_once $fn;
>>
>> > > }
>>
>> > Thanks for the quick response.
>> > However, autoload() doesn't do what it should.
>>
>> > The code below is about all that happens in the css skript.
>>
>> > //START
>> > session_start();
>> > $objController=$_SESSION['controller']; var_dump($objController);
>> > $objCssParser=new CssParser($objController); //END
>>
>> > Now autoload() is triggered by the "new CSSParser" part and loads the
>> > whole hierarchy of CSSParser's parent classes and interfaces. But the
>> > unserializing doesn't bother it at all. The function is not called.
>>
>> > So after that the type-hinting in CssParser's constructor causes an
>> > error to be thrown since it can't determine the class of
>> > $objController.
>>
>> > Suggestions?
>>
>> Try adding this immediately after you define __autoload():
>>
>> ini_set('unserialize_callback_func', '__autoload');
>
> Good idea, that almost did the trick. I say almost since now i get one
> call to __autoload for the Controller class that is loaded.
> However that also doesn't take care of the inner objects.
>
>
> Yet... if i can load the containing class, maybe i can use it's __wakeup
> method to require the other files as needed... Anyone tried that? Or is
> there a chicken/egg problem?
>
> Greetings,
>
> Johannes
Perhaps you can store class info (use get_class() on the parsed
$objController inside the CssParser class definition) so you can
reconstruct it. If not, the object becomes stdClass.
Not my sharpest hour today, so I may be way off the mark here. Perhaps
having another look at:
http://www.php.net/manual/en/language.oop.serialization.php yields some
useful insights.
Sh.
[Back to original message]
|