Open Menu

Exercise Events#^ TOP

As we learned in the previous article, we can implement simple checking directly in our exercise if we don't want to build a check.

However, Self Checking is rather un-flexible in that you can only hook in to the verify/run process at one particular point, immediately after all other checks have run.

We also described the events features in previous chapters Events & Creating Listener Checks. Well, as it goes, any events you can listen to in Listener Checks, you can listen to directly in your exercises!

Check it out:

class MyExercise extends AbstractExercise implements ExerciseInterface

     * @param ExerciseDispatcher $dispatcher
    public function configure(ExerciseDispatcher $dispatcher)

        $dispatcher->getEventDispatcher()->listen('verify.start', function (Event $e) {
            //do something

You can grab the EventDispatcher from ExerciseDispatcher and listen to any events and insert verifiers just like we did in Creating Listener Checks when we inserted a verifier function which verifies the state of a Couch DB database.

You can listen to any of the events listed on Events.