Is the module autoloader set up before the session is started? If you are
using protected _init* methods in your bootstrap, make sure the autoloader
method is above the session one, or call $this->bootstrap('autoloader')
within your _initSession method.

--
Hector Virgen
Sent from my Droid X
On Nov 28, 2010 7:43 AM, "Bram Gadeyne" <gadeyneb...@gmail.com> wrote:
> Dear all,
>
> I'm trying to persist some objects to the session. But everything I try
> end up with the following error message:
>
> Fatal error: Shop_CardController::addAction(): The script tried to
> execute a method or access a property of an incomplete object. Please
> ensure that the class definition "Default_Model_Card" of the object you
> are trying to operate on was loaded _before_ unserialize() gets called
> or provide a __autoload() function to load the class definition in
>
/var/www/uitleendienst/application/modules/shop/controllers/CardController.php

> on line 43
>
> These are my settings in the bootstrap.php for autoloading modules:
>
> $modelLoader=new Zend_Application_Module_Autoloader(array(
> 'namespace' => '',
> 'basePath' => APPLICATION_PATH.'/modules/default'));
>
> In the bootstrap I've also entered:
> class_exists('Shop_Model_Card', true); //returns false
> Zend_Session::start();
>
> This is the code that results in an error:
>
> 37 $ns = new Zend_Session_Namespace('mysession');
> 38 if(!isset($ns->card)){
> 39 $card=new Shop_Model_Card();
> 40 }else{
> 41 $card=$ns->card;
> 42 }
> 43 $card->addUitleningToList("value");
> 44 $ns->card = $card;
>
> The code returns this error when the else part is executed and $ns->card
> should get deserialized. How do I get Zend framework to autoload the
> Shop_Model_Card class?
>
> This is my class definition for Shop_Model_Card.
>
> class Shop_Model_Card{
>
> private $uitleningen;
>
> public function getUitleningen(){
> return $this->uitleningen;
> }
>
> public function __construct() {
> //$this->uitleningen=array();
> }
>
> public function clear(){
> $this->uitleningen=array();
> }
>
> public function addUitleningToList($uitlening){
> if($this->uitleningen==null){
> $this->uitleningen=array();
> }
> array_push($this->uitleningen, $uitlening);
> }
>
> public function removeFromList($uitleningid){
> $temparr=array();
> $i=$uitleningid;
> while($i<sizeof($this->uitleningen-1)){
> $this->uitleningen[$i]=$this->uitleningen[$i+1];
> $i++;
> }
> $this->uitleningen[$i+1]=null;
> }
> }
>
> Can someone help me please?
>
> With kind regards,
> Bram Gadeyne

Reply via email to