Forums / Basic Configuration / observer/notifier the "base" class

observer/notifier the "base" class

Locked

Views: 2,166

Results 1 to 2 of 2
This thread is locked. New replies are disabled.
2 Apr 2007, 12:36 PM
#1
david_bo avatar

david_bo

New Zenner

Join Date:
Oct 2006
Posts:
23
Plugin Contributions:
0

observer/notifier the "base" class

In the API turtorial it is explained that every class that want to make use of observer/notifier system has to extend the "base"
class. However I cannot see how this can work. Maybe it is because I am a C++ guru and not a PHP. The problem as I see it is that we get different instances of the "base" class for every instance of observer or notifier class. Therefore the following observerclass will never get the notification from the shopping_cart class.

<?php class myObserver extends base { function myObserver() { $this->attach($this, array('NOTIFIER_CART_ADD_CART_END')); } ... } If the base class was static or was working on some global variables then it would be different. What have I misunderstood?
3 Apr 2007, 1:23 AM
#2
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,720
Plugin Contributions:
56

Re: observer/notifier the "base" class

The documentation is buggy.

Your c'tor should instead say

$_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END'));

for cart stuff. The cart object maintains a list of observers and calls them when
the notify() method is called for the events they have registered for. Similarly, zco_notifier, etc.

Scott

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.