Created
October 6, 2014 18:56
-
-
Save Ocramius/3e1c24dfc3c67f003653 to your computer and use it in GitHub Desktop.
my-thing protection module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Zend\EventManager\EventInterface; | |
use Zend\ModuleManager\Feature\BootstrapListenerInterface; | |
use Zend\Mvc\MvcEvent; | |
use Zend\Http\Response; | |
class Module implements BootstrapListenerInterface | |
{ | |
public function onBootstrap(EventInterface $event) | |
{ | |
$event->getTarget()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) { | |
$routeMatch = $e->getRouteMatch(); | |
if ($routeMatch && 'my-route' === $routeMatch->getMatchedRouteName()) { | |
$response = new Response(); | |
$response->setContent('Can\'t touch this!'); | |
$response->setStatusCode(403); | |
return $response; | |
} | |
}, 1000); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment