/** * Executes the given callback, returns the callback's return value. * * @param \Philip\IRC\Event $event The Philip IRC event * * @return mixed */ public function testAndExecute(Event $event) { if ($this->shouldExecuteCallback($event->getRequest()->getMessage())) { $event->setMatches($this->getMatches()); return call_user_func($this->callback, $event); } return false; }
/** * Add the login event to the log record. * * @param Event $event */ public function onSecurityInteractiveLogin(Event $event) { $logger = $this->container->get('BnvWebLogger'); $trans = $this->container->get('translator'); $username = $this->container->get('security.context')->getToken()->getUser()->getUsername(); $msg = $trans->trans('User %username% logged in.', array('%username%' => $username), 'BinovoElkarBackup'); $logger->info($msg, array('source' => 'Authentication')); $user = $this->container->get('security.context')->getToken()->getUser(); $locale = $user->getLanguage(); $request = $event->getRequest(); $request->getSession()->set('_locale', $locale); }
/** * filter the `core.response` event to decorated the action * * @param \Symfony\Component\EventDispatcher\Event $event * @return \Symfony\Component\HttpFoundation\Response */ public function onCoreResponse(Event $event) { $response = $event->getResponse(); $requestType = $event->getRequestType(); $request = $event->getRequest(); if ($this->isDecorable($request, $requestType, $response)) { $page = $this->defineCurrentPage($request); // only decorate hybrid page and page with decorate = true if ($page && $page->isHybrid() && $page->getDecorate()) { $parameters = array('content' => $response->getContent()); $response = $this->renderPage($page, $parameters, $response); } } return $response; }
public function subdomainParse(Event $event) { $request = $event->getRequest(); $session = $request->getSession(); // todo: parsing subdomain to detect country $default_hosts = array("professionals", "varavan", "www", "professionals"); $parts = explode(".", $request->getHost()); if (in_array($parts[0], $default_hosts)) { $username = false; } else { $username = $parts[0]; $user = $this->em->getRepository("CoreUserBundle:User")->findOneByUsername($username); $session->set('style', false); if ($user) { $session->set('style', $user->getProfessional()->getStyles()->getWebPath()); } } $session->set('subdomain', $username); $session->set('host', $parts[0]); }
public function handleRequest(Event $event, $router) { $request = $event->getRequest(); $ofwnize = new OfwnInit($request); $info = $ofwnize->getRouteByCurrentUri(); // print_r($info); if ($info['controller']) { if ($info['type'] == "rest") { $method = strtolower($request->getMethod()); if ($ofwnize->isAllowedMethod($method)) { $request->attributes->set('_controller', $info['controller'] . ':' . $method); } else { $request->attributes->set('_controller', $info['controller'] . ':get'); } } else { if ($info['action']) { $request->attributes->set('_controller', $info['controller'] . ':' . $info['action']); } } } else { $request->attributes->set('_controller', 'HomepageDefaultBundle:Blog:index'); } }
public function onResponse(Event $event) { $response = $event->getResponse(); /* @var $response \Symfony\Component\HttpFoundation\Response */ $session = $event->getRequest()->getSession(); /* @var $session \Symfony\Component\HttpFoundation\Session */ $response->headers->setCookie(new Cookie('locale', $session->get('localeIdentified'))); if (null !== $this->logger) { $this->logger->info(sprintf('Locale Cookie set to: [ %s ]', $session->get('localeIdentified'))); } }
public function routeInit(Event $event) { $request = $event->getRequest(); $request->attributes->add(array('_controller' => "Homepage\\DefaultBundle\\Controller\\BlogController::indexAction")); }
/** * Method call on the first request * @param Event $event The kernel request event */ public function onKernelRequest(Event $event) { if (HttpKernelInterface::MASTER_REQUEST == $event->getRequestType()) { $this->cacheResetter->setRequest($event->getRequest()); } }