Resolve "Auto-assign hub and rider" #1231

Merged
korina.cordero merged 22 commits from 374-auto-assign-hub-and-rider into master 2020-04-15 03:34:58 +00:00
3 changed files with 63 additions and 1 deletions
Showing only changes of commit 1e23f0cd55 - Show all commits

View file

@ -53,7 +53,7 @@ use DateTime;
use Exception;
// mobile API
class APIController extends Controller
class APIController extends Controller implements LoggedController
{
protected $session;

View file

@ -0,0 +1,7 @@
<?php
namespace App\Controller;
interface LoggedController
{
}

View file

@ -0,0 +1,55 @@
<?php
namespace App\EventSubscriber;
use App\Controller\LoggedController;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
class LogSubscriber implements EventSubscriberInterface
{
protected $allow;
public function __construct()
{
$this->allow = true;
}
public function onKernelController(ControllerEvent $event)
{
$controller = $event->getController();
// when a controller class defines multiple action methods, the controller
// is returned as [$controllerInstance, 'methodName']
if (is_array($controller))
$controller = $controller[0];
if ($controller instanceof LoggedController)
$this->allow = true;
else
$this->allow = false;
}
public function onKernelResponse(ResponseEvent $event)
{
if (!$this->allow)
return;
$resp = $event->getResponse();
$content = $resp->getContent();
error_log(print_r($content, true));
}
public static function getSubscribedEvents()
{
return [
KernelEvents::CONTROLLER => 'onKernelController',
KernelEvents::RESPONSE => 'onKernelResponse',
];
}
}