Mvc\Router\Route::beforeMatch

public beforeMatch (mixed $callback)

Sets a callback that is called if the route is matched. The developer can implement any arbitrary conditions here If the callback returns false the route is treated as not matched

$router->add('/login', array(
  'module'     => 'admin',
  'controller' => 'session'
 ))->beforeMatch(function ($uri, $route) {
   // Check if the request was made with Ajax
   if ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'xmlhttprequest') {
      return false;
   }
     return true;
 });
doc_Phalcon
2016-10-16 09:55:30
Comments
Leave a Comment

Please login to continue.