/** * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * @throws \RuntimeException */ public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if (!$request) { return; } if (!$request->hasSession()) { return; } $adminCode = $request->get('_sonata_admin'); if (!is_null($adminCode)) { $this->admin = $this->adminPool->getAdminByAdminCode($adminCode); if (!$this->admin) { throw new \RuntimeException(sprintf('Unable to find the admin class related to the current controller (%s)', get_class($this))); } if (method_exists($this->admin, 'getTrackedActions')) { foreach ($this->admin->getTrackedActions() as $trackedAction) { // if an action which is flagged as 'to be tracked' is matching the end of the route: add info to session if (preg_match('#' . $trackedAction . '$#', $request->get('_route'), $matches)) { $this->updateTrackedInfo($request->getSession(), '_networking_initcms_admin_tracker', array('url' => $request->getRequestUri(), 'controller' => $this->admin->getBaseControllerName(), 'action' => $trackedAction)); } } } } }