Created
September 8, 2016 20:11
-
-
Save ppeiris/78c4e4cc96d09adbbc8b9e9754b3397a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
namespace ispaccount; | |
use ZF\ApiProblem\ApiProblem; | |
use ZF\Apigility\Provider\ApigilityProviderInterface; | |
use Zend\Http\Response\ApiProblemResponse; | |
use Zend\Mvc\MvcEvent; | |
class Module implements ApigilityProviderInterface | |
{ | |
public function getConfig() | |
{ | |
return include __DIR__ . '/../../config/module.config.php'; | |
} | |
public function getAutoloaderConfig() | |
{ | |
return array( | |
'ZF\Apigility\Autoloader' => array( | |
'namespaces' => array( | |
__NAMESPACE__ => __DIR__, | |
), | |
), | |
); | |
} | |
public function onBootstrap($e) | |
{ | |
$eventm = $e->getTarget()->getEventManager(); | |
$eventm->attach(MvcEvent::EVENT_ROUTE, [$this, 'onEventRoute']); | |
} | |
public function onEventRoute($e) | |
{ | |
$eventManager = $e->getTarget()->getEventManager(); | |
$request = $e->getRequest(); | |
if (strpos($e->getRouter()->getRequestUri()->getPath(), 'api') == false) { | |
return; // not a api call | |
} | |
if (!method_exists($request, 'getUri')) { | |
return; // Not a HTTP request | |
} | |
$routematch = $e->getRouteMatch(); | |
if (!$routematch) { | |
return; | |
} | |
print_r($routematch->getMatchedRouteName()); | |
if ($routematch->getMatchedRouteName() != 'ispaccount.rest.ispaccount') { | |
return; | |
} | |
print_r(get_class_methods($request)); | |
// print_r($routematch->getMatchedRouteName()); | |
print_r($routematch->getParam('ispaccount_id')); | |
$eventManager->trigger('logit', $this, array("in the renderEntity")); | |
$apiProblem = new ApiProblem(200, 'There were no routes found matching your request.'); | |
// $e->stopPropagation(true); | |
// $e->setResponse(new ApiProblemResponse($apiProblem)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment