src/EventSubscriber/ExtendUserByApp.php line 30
<?phpnamespace App\EventSubscriber;use App\Common\Functions\Helpers;use App\Common\Globals\MainGlobals;use App\Functions\Common\GetUser;use Doctrine\ODM\MongoDB\DocumentManager;use Symfony\Bundle\SecurityBundle\Security;use Symfony\Component\EventDispatcher\EventSubscriberInterface;use Symfony\Component\HttpFoundation\JsonResponse;use Symfony\Component\HttpFoundation\Request;use Symfony\Component\HttpKernel\Event\ControllerEvent;use Symfony\Component\HttpKernel\Event\RequestEvent;use Symfony\Component\HttpKernel\KernelEvents;class ExtendUserByApp implements EventSubscriberInterface{public function __construct(private Security $security,public DocumentManager $dm){}public static function getSubscribedEvents(){return array(KernelEvents::CONTROLLER => array(array('onKernelController', 200)),);}public function onKernelController(ControllerEvent $event){if(MainGlobals::$app){$header_app = MainGlobals::$app->id;$account_fun = Helpers::getMethod(GetUser::class, $header_app);if(!$account_fun){$account_fun = Helpers::getMethod(GetUser::class, 'MainAccount');}$user = $this->security->getUser();MainGlobals::$user = $user;if($account_fun && $user){$account = $account_fun->invoke((object)[], $this->dm, $user, $header_app);if($account){MainGlobals::$account = $account;}else{MainGlobals::$account = (object) [];}}if(MainGlobals::$extra){foreach(MainGlobals::$extra as $key => $val){MainGlobals::$account->{$key} = $val;}}}}}