@@ -28,6 +28,11 @@ public function handle(MatchingResult $result, \WP $wp, $doParseRequest)
2828 $ result = apply_filters ('cortex.match.done ' , $ result , $ wp , $ doParseRequest );
2929 $ handlerResult = $ doParseRequest ;
3030
31+ if (! $ result instanceof MatchingResult) {
32+ return $ result ;
33+ }
34+
35+ /** @var \Brain\Cortex\Router\MatchingResult $result */
3136 if ($ result ->matched ()) {
3237 $ doParseRequest = false ;
3338 $ origHandler = $ result ->handler ();
@@ -37,12 +42,13 @@ public function handle(MatchingResult $result, \WP $wp, $doParseRequest)
3742 $ template = $ result ->template ();
3843 (is_string ($ template )) or $ template = '' ;
3944 $ vars = $ result ->vars ();
45+ $ matches = $ result ->matches ();
4046
4147 do_action ('cortex.matched ' , $ result , $ wp );
4248
43- is_callable ($ before ) and $ before ($ vars , $ wp , $ template );
44- is_callable ($ handler ) and $ handlerResult = $ handler ($ vars , $ wp , $ template );
45- is_callable ($ after ) and $ after ($ vars , $ wp , $ template );
49+ is_callable ($ before ) and $ before ($ vars , $ wp , $ template, $ matches );
50+ is_callable ($ handler ) and $ handlerResult = $ handler ($ vars , $ wp , $ template, $ matches );
51+ is_callable ($ after ) and $ after ($ vars , $ wp , $ template, $ matches );
4652 $ template and $ this ->setTemplate ($ template );
4753
4854 do_action ('cortex.matched-after ' , $ result , $ wp , $ handlerResult );
0 commit comments