Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    23
    Plugin Contributions
    0

    Default 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?

  2. #2
    Join Date
    Feb 2006
    Location
    Tampa Bay, Florida
    Posts
    10,511
    Plugin Contributions
    126

    Default 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.

 

 

Similar Threads

  1. Replies: 0
    Last Post: 4 Mar 2014, 02:19 PM
  2. Replies: 1
    Last Post: 20 Jan 2012, 01:43 AM
  3. Replies: 2
    Last Post: 17 May 2011, 03:50 AM
  4. Replies: 3
    Last Post: 3 Jun 2008, 11:41 AM
  5. For images, does "base" = "small"? And a question about alternates.
    By molywerks in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 29 Feb 2008, 02:49 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg