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 20 additions and 0 deletions
Showing only changes of commit 48e95ee581 - Show all commits

View file

@ -63,3 +63,6 @@ INVENTORY_API_URL=insert_api_url_here
INVENTORY_API_OCP=insert_ocp_text_here
INVENTORY_API_AUTH_TOKEN_PREFIX=Bearer
INVENTORY_API_AUTH_TOKEN=insert_auth_token_here
# API logging
API_LOGGING=set_to_true_or_false

View file

@ -234,3 +234,8 @@ services:
$api_ocp_key: "%env(INVENTORY_API_OCP)%"
$api_auth_prefix: "%env(INVENTORY_API_AUTH_TOKEN_PREFIX)%"
$api_auth_token: "%env(INVENTORY_API_AUTH_TOKEN)%"
# API logging
App\EventSubscriber\LogSubscriber:
arguments:
$api_log_flag: "%env(API_LOGGING)%"

View file

@ -12,9 +12,18 @@ use Symfony\Component\HttpKernel\KernelEvents;
class LogSubscriber implements EventSubscriberInterface
{
protected $allow;
protected $api_log_flag;
public function __construct($api_log_flag)
{
$this->api_log_flag = $api_log_flag;
}
public function onKernelController(ControllerEvent $event)
{
if ($this->api_log_flag == 'false')
return;
$controller = $event->getController();
$this->allow = false;
@ -40,6 +49,9 @@ class LogSubscriber implements EventSubscriberInterface
public function onKernelResponse(ResponseEvent $event)
{
if ($this->api_log_flag == 'false')
return;
if (!$this->allow)
return;