blocks plugin can't execute observer

blocks plugin can't execute observer

by g g -
Number of replies: 2

Hi all, my block plugin observer always got "Can not execute event observer" error. Searched and checked many times. Pls help take a look what's wrong with my setting.

/mypluginname/db/events.php:

$observers = array(

    array(

        'eventname' => '\mod_page\event\course_module_viewed',

        'callback' => '\blocks_mypluginname\page_video_observers::get_token_and_video_url',

    ),

);


/mypluginname/classes/page_video_observers.php:

namespace blocks_mypluginname;

class page_video_observers {

    public static function get_token_and_video_url($event) {

        //some business logic;

    }

}


with moodle cache purged, plugin version number increased. upgrade finally got "section error" at /admin/index.php/cache=1, not sure this matters. No db change so I only increased the version number, no change of upgrade.php.

access page can trigger the event but debug saying:Can not execute event observer '\blocks_mypluginname\page_video_observer::get_token_and_video'

Thanks a lot.


Average of ratings: -
In reply to g g

Re: blocks plugin can't execute observer

by Andreas Grabs -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Translators

Hi,

You are using the wrong namespace. For your block the namespace would be "block_mypluginname".

Best regards
Andreas

Average of ratings: Useful (1)
In reply to Andreas Grabs

回复: Re: blocks plugin can't execute observer

by g g -
Great thanks Andreas. You saved my day.