Hi there,
I have an Access class as a Middleware for my Micro App:
namespace Api\Middleware;
use Phalcon\Mvc\Micro as PhMicro,
Phalcon\Mvc\Micro\MiddlewareInterface;
/**
* Class Access
* @package Api\Middleware
*/
class Access implements MiddlewareInterface
{
public function call(PhMicro $application)
{
$session = $application['session'];
if(!$application->session->has('identity')) {
$application->response->unAuthorized(); // Response json error blah blah
return false;
}
return true;
}
}
but when it attached to application as follow:
$application = new \Phalcon\Mvc\Micro();
$application->before(new Api\Middleware\Access());
$application->handle();
The operation does not stop and route execute after middleware returns FALSE!
I confused cause using middleware as a closure already works:
$application = new \Phalcon\Mvc\Micro();
$application->before(function () use($application) {
if(!$application->session->has('identity')) {
$application->response->unAuthorized();
return false;
}
return true;
});
$application->handle();
Is this a bug or something else?
P.S1: I allready use $application->stop() in middleware with no success!
P.S2: What is $this->_stopped
(in this line) for?
Thanks.