Example #1
0
 public function testContinueFalseShouldBreakFilterChain()
 {
     $filters = new Filters();
     $filters->register('myEventType', function () {
         // First filter function returns FALSE and should break the chain of filters
         return false;
     });
     $filters->register('myEventType', function () {
         // Second filter function should never even be called.
         $this->fail();
         return false;
     });
     $this->assertFalse($filters->trigger('myEventType'), 'Continue should break filter function execution when FALSE is explicitly returned');
 }
Example #2
0
 /**
  * Registers a filter function that is called when routing fails (404 error).
  *
  * @param callable $filter
  * @return $this
  */
 public function notFound(callable $filter)
 {
     $this->filters->register(Filters::NO_ROUTE_FOUND, $filter);
     return $this;
 }
Example #3
0
 /**
  * Adds a filter action that should be executed when an exception occurs in this route's action.
  *
  * @param callable $filter
  * @return $this
  */
 public function onException(callable $filter)
 {
     $this->filters->register(Filters::ON_EXCEPTION, $filter);
     return $this;
 }