Welcome Guest, Not a member yet? Register   Sign In
Dan Horrigan (Eric Barnes) Events Library - Help?
#4

[eluser]Devon Lambert[/eluser]
Thanks again for your help on this Eric. It works like a charm.

I have 1 final question/stumping block that I'm facing...

How would you handle the situation of multiple events which in turn require multiple functions to fire given certain scenarios. To put this another way, I am trying to use this library in a user experience module.

1) Users are awarded experience points for completing certain actions on my site.
2) The module would listen for the required action and once complete would award the user the appropriate amount of points.

Obviously, your events library fits this scenario perfectly. However, let's say I have 20 actions that a user can complete for a given event, then wouldn't my "Experience_Events" class look something like below:

Code:
class Events_Experience {
    
    public function __construct()
    {
        
        Events::register('admin_controller', array($this, 'method_name1'));
        Events::register('admin_controller', array($this, 'method_name2'));
        Events::register('admin_controller', array($this, 'method_name3'));
        Events::register('admin_controller', array($this, 'method_name4'));
        Events::register('admin_controller', array($this, 'method_name5'));
        Events::register('admin_controller', array($this, 'method_name6'));
        Events::register('admin_controller', array($this, 'method_name7'));
        Events::register('admin_controller', array($this, 'method_name8'));
        Events::register('admin_controller', array($this, 'method_name9'));
        Events::register('admin_controller', array($this, 'method_name10'));
        Events::register('admin_controller', array($this, 'method_name11'));
        Events::register('admin_controller', array($this, 'method_name12'));
        Events::register('admin_controller', array($this, 'method_name13'));
        Events::register('admin_controller', array($this, 'method_name14'));
        Events::register('admin_controller', array($this, 'method_name15'));
        Events::register('admin_controller', array($this, 'method_name16'));
        Events::register('admin_controller', array($this, 'method_name17'));
        Events::register('admin_controller', array($this, 'method_name18'));
        Events::register('admin_controller', array($this, 'method_name19'));
        Events::register('admin_controller', array($this, 'method_name20'));

    }

    public function method_name1()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }


    public function method_name2()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    
    public function method_name3()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name4()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name5()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name6()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name7()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name8()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name9()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name10()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }

    public function method_name11()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name12()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    
    public function method_name13()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name14()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name15()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name16()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name17()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name18()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name19()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
    public function method_name20()
    {
        echo 'Experience Module is listening for the Admin Controller Event! it works!';
    }
}

Seems like a bit of overkill for one class, no? :-)


Messages In This Thread
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-15-2011, 08:14 PM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-15-2011, 09:15 PM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-15-2011, 11:02 PM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-20-2011, 01:19 AM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-21-2011, 08:09 AM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-28-2011, 03:37 AM
Dan Horrigan (Eric Barnes) Events Library - Help? - by El Forum - 01-28-2011, 11:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB