Forums / Templates, Stylesheets, Page Layout / session objects in the observer class

session objects in the observer class

Locked

Started by wdrwc on 18 Jul 2006, 10:19 AM · Views: 2,414

Results 1 to 1 of 1
This thread is locked. New replies are disabled.
18 Jul 2006, 10:19 AM
#1
wdrwc avatar

wdrwc

New Zenner

Join Date:
Sep 2004
Posts:
13
Plugin Contributions:
0

session objects in the observer class

I apologize for asking such an elementary question, but I am just working on my first php code. And I do not understand how I can refe to the class objects constructed as session variables.

I would like to prepare the observe class attached to certain events. I have prepared the file config.sellingwarehouse.php which contains the following code:

$autoLoadConfig[180][]= array('autoType' => 'class',
        'loadFile' => 'observers/class.sellingwarehouse.php');

$autoLoadConfig[180][]= array('autoType' => 'classInstantiate',
        'className' => 'sellingwarehouse',
        'objectName' => 'sellingWarehouse',
        'checkInstantiated' => true,
        'classSession' => true);

As I uderstand the API tutorial in that way I will get new object instatiated in the following way:

$_SESSION['sellingWarehouse']= new sellingwarehouse();

The class.sellingwarehouse.php looks like this:

class sellingwarehouse extends base {

  var $id, $address, $tax_idno, $licence_id, $telephone, $fax, $extraflags;

  function sellingwarehouse () {
    global $zco_notifier;
    $zco_notifier -> attach($this,
                            array('NOTIFY_HEADER_START_CHECKOUT_PAYMENT',
                                  'NOTIFY_HEADER_START_ACCOUNT_HISTORY_INFO',
                                  'NOTIFY_HEADER_END_CHECKOUT_SUCCESS'));
  } /* end constructor method */
  function update(...) {
  }

But I do not understand how I shall refer in the observer class and in the update() method there to the object variables.
Shal I use simply

$this->address['postcode']="abcde";

or use $_SESSION like this:

$_SESSION['sellingWarehouse']->address['postcode']="abcde";

If it is necessary to refer using $_SESSION, shall then I declare in the constructor method the array for the address?

$_SESSION['sellingWarehouse']->address= array();

It would be great if I could use also message_stack class for displaying debugging info. But I do not understand how does it work. I would appreciate any example on that subject too.

Thanks in advance for any help.
wdrwc