
class Rewards extends PluginBase {
    
    protected $storage = 'DbStorage';    
    static protected $description = 'Rewards plugin';
    static protected $name = "Rewards";
    
    
    public function __construct(PluginManager $manager, $id) {
        parent::__construct($manager, $id);
        /**
         * Here you should handle subscribing to the events your plugin will handle
         */
       
        $this->subscribe('afterAdminMenuLoad');
        $this->subscribe('newDirectRequest');
    }
    
    public function afterAdminMenuLoad(){
        $event = $this->event;
        $menu = $event->get('menu', array());
        $menu['items']['left'][]=array(
                'href' => "plugins/direct/rewards?function=assignRewards",
                'alt' => gT('Rewards'),
                'image' => 'bounce.png'
            );
        
        $event->set('menu', $menu);
    }
    
    public function newDirectRequest(){
        $event = $this->event;
        $request = $event->get('request');
        //get the function param and then you can call that method
        $functionToCall = $event->get('function');        
        $content = call_user_func(array($this,$functionToCall));        
        $event->setContent($this, $content);        
    }
    
    function assignRewards() {
        $content = "<h1> plugin content set succesfully </h1>";
        return $content;        
    }
    
    
}
