Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created October 6, 2014 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ocramius/3e1c24dfc3c67f003653 to your computer and use it in GitHub Desktop.
Save Ocramius/3e1c24dfc3c67f003653 to your computer and use it in GitHub Desktop.
my-thing protection module
<?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