public function call() { if (strpos($this->app->request()->getPathInfo(), $this->route) !== false) { $this->middleware->setApplication($this->app); $this->middleware->setNextMiddleware($this->next); $this->middleware->call(); } else { $this->next->call(); } }
/** * Add middleware * * This method prepends new middleware to the application middleware stack. * The argument must be an instance that subclasses Slim_Middleware. * * @param \Slim\Middleware */ public function add(\Slim\Middleware $newMiddleware) { $newMiddleware->setApplication($this); $newMiddleware->setNextMiddleware($this->middleware[0]); array_unshift($this->middleware, $newMiddleware); }
/** * Push middleware * * This method adds new middleware to the application middleware stack right after the current one * This enables us to add it from inside an called middleware * The argument must be an instance that subclasses Slim_Middleware. * * @param \Slim\Middleware */ public function push($first, \Slim\Middleware $newMiddleware) { $newMiddleware->setApplication($this); $newMiddleware->setNextMiddleware($first->getNextMiddleware()); $first->setNextMiddleware($newMiddleware); }