예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, tubepress_api_event_EventInterface $event = null)
 {
     if (!$event || !$event instanceof \Symfony\Component\EventDispatcher\Event) {
         $event = new tubepress_event_impl_tickertape_TickertapeEventWrapper($event);
     }
     return $this->_wrappedDispatcher->dispatch($eventName, $event);
 }
예제 #2
0
 /**
  * @param            $slot
  * @param Lead|array $lead
  *
  * @return string
  */
 public function getDynamicContentForLead($slot, $lead)
 {
     $response = $this->campaignEventModel->triggerEvent('dwc.decision', $slot, 'dwc.decision.' . $slot);
     $content = '';
     if (is_array($response) && !empty($response['action']['dwc.push_content'])) {
         $content = array_shift($response['action']['dwc.push_content']);
     } else {
         $data = $this->dynamicContentModel->getSlotContentForLead($slot, $lead);
         if (!empty($data)) {
             $content = $data['content'];
             $dwc = $this->dynamicContentModel->getEntity($data['id']);
             if ($dwc instanceof DynamicContent) {
                 // Determine a translation based on contact's preferred locale
                 /** @var DynamicContent $translation */
                 list($ignore, $translation) = $this->dynamicContentModel->getTranslatedEntity($dwc, $lead);
                 if ($translation !== $dwc) {
                     // Use translated version of content
                     $dwc = $translation;
                     $content = $dwc->getContent();
                 }
                 $this->dynamicContentModel->createStatEntry($dwc, $lead, $slot);
                 $tokenEvent = new TokenReplacementEvent($content, $lead, ['slot' => $slot, 'dynamic_content_id' => $dwc->getId()]);
                 $this->dispatcher->dispatch(DynamicContentEvents::TOKEN_REPLACEMENT, $tokenEvent);
                 $content = $tokenEvent->getContent();
             }
         }
     }
     return $content;
 }
 /**
  * @param \Doctrine\ORM\Event\LifecycleEventArgs $args
  */
 public function postUpdate(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if (!$entity instanceof Transaction) {
         return;
     }
     $this->dispatcher->dispatch(PaymentEvents::TRANSACTION_UPDATED, new TransactionUpdatedEvent($entity));
 }
예제 #4
0
 /**
  * Generate admin menu navigation object
  *
  * @return \Knp\Menu\ItemInterface
  */
 public function adminMenu()
 {
     static $adminMenu;
     if (empty($adminMenu)) {
         $loader = new ArrayLoader($this->factory);
         //dispatch the MENU_BUILD event to retrieve bundle menu items
         $event = new MenuEvent($this->menuHelper, 'admin');
         $this->dispatcher->dispatch(CoreEvents::BUILD_MENU, $event);
         $menuItems = $event->getMenuItems();
         $adminMenu = $loader->load($menuItems);
     }
     return $adminMenu;
 }
예제 #5
0
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     if ($this->disabled) {
         return $event;
     }
     return parent::dispatch($eventName, $event);
 }
예제 #6
0
 public function dispatch($eventName, Event $event = null)
 {
     if ($event instanceof LoggableEventInterface) {
         $this->getContainer()->get('logger')->addInfo($eventName, $event->getLogContext());
     }
     return parent::dispatch($eventName, $event);
 }
예제 #7
0
 /**
  * {@inheritDoc}
  *
  * Lazily loads listeners for this event from the dependency injection
  * container.
  *
  * @throws \InvalidArgumentException if the service is not defined
  */
 public function dispatch($eventName, Event $event = null)
 {
     if ($this->interceptAsyncEvent($eventName, $event) != null) {
         $this->getContainer()->get('logger')->info(sprintf('Async event intercepted[%s]!', $eventName));
     }
     return parent::dispatch($eventName, $event);
 }
예제 #8
0
 /**
  * {@inheritDoc}
  */
 public function get($key)
 {
     $key = $this->updateCacheKey($key);
     $result = $this->getActiveImplementation()->get($key);
     //Parse result to retrieve it raw
     if ($result) {
         try {
             $cacheItemStore = new CacheItemStore();
             $cacheItemStore->hydrateFromCacheData($result);
             $cacheItemStore->getData();
             $result = $cacheItemStore->getData();
         } catch (CorruptedDataException $e) {
             $result = null;
         }
     }
     //Throwing event
     if ($result) {
         //Dispatch memcache hit event
         $event = new CacheHitEvent($this->getActiveImplementation()->getName(), $key, $result);
         $this->eventDispatcher->dispatch("urodoz.events.cachehit", $event);
     } else {
         //Dispatch memcache missed hit event
         $event = new MissedCacheHitEvent($this->getActiveImplementation()->getName(), $key);
         $this->eventDispatcher->dispatch("urodoz.events.missed_cachehit", $event);
     }
     return $result;
 }
예제 #9
0
 /**
  * @param string $eventName
  * @param Event $event
  * @return Event
  */
 public function dispatch($eventName, Event $event = null)
 {
     if (empty($event)) {
         throw new RuntimeException('You have to pass an Event into EventDispatcher::dispatch');
     }
     foreach ($this->catchall as $dispatcher) {
         $dispatcher->dispatch($eventName, $event);
     }
     return parent::dispatch($eventName, $event);
 }
예제 #10
0
 /**
  * @param $name
  *
  * @return mixed
  */
 private function buildMenu($name)
 {
     static $menus = array();
     if (!isset($menus[$name])) {
         $loader = new ArrayLoader($this->factory);
         //dispatch the MENU_BUILD event to retrieve bundle menu items
         $event = new MenuEvent($this->menuHelper, $name);
         $this->dispatcher->dispatch(CoreEvents::BUILD_MENU, $event);
         $menuItems = $event->getMenuItems();
         $menus[$name] = $loader->load($menuItems);
     }
     return $menus[$name];
 }
예제 #11
0
 /**
  * Dispatch hook listeners.
  *
  * @param string $name Hook event name.
  * @param Hook   $hook Hook instance.
  *
  * @return Hook
  */
 public function dispatch($name, Hook $hook)
 {
     if (!$this->loaded) {
         // lazy load handlers for the first time
         $this->loadRuntimeHandlers();
         $this->loaded = true;
     }
     $hook->setName($name);
     $this->decorateHook($hook);
     if (!$hook->getAreaId()) {
         return $hook;
     }
     return $this->dispatcher->dispatch($name, $hook);
 }
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     switch ($eventName) {
         case 'kernel.request':
             $this->stopwatch->openSection();
             break;
         case 'kernel.view':
         case 'kernel.response':
             // stop only if a controller has been executed
             try {
                 $this->stopwatch->stop('controller');
             } catch (\LogicException $e) {
             }
             break;
         case 'kernel.terminate':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->openSection($token);
             break;
     }
     $e1 = $this->stopwatch->start($eventName, 'section');
     parent::dispatch($eventName, $event);
     $e1->stop();
     switch ($eventName) {
         case 'kernel.controller':
             $this->stopwatch->start('controller', 'section');
             break;
         case 'kernel.response':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
                 // The profiles can only be updated once they have been created
                 // that is after the 'kernel.response' event of the main request
                 $this->updateProfiles($token, true);
             }
             break;
         case 'kernel.terminate':
             $this->stopwatch->stopSection($token);
             // The children profiles have been updated by the previous 'kernel.response'
             // event. Only the root profile need to be updated with the 'kernel.terminate'
             // timing informations.
             $this->updateProfiles($token, false);
             break;
     }
     return $event;
 }
예제 #13
0
 /**
  * @param Transaction $transaction
  * @throws Exception
  */
 public function processTransaction(Transaction $transaction)
 {
     $method = $transaction->getMethod();
     if (false === $this->methodIsAvailable($method)) {
         throw new Exception(sprintf('The payment method "%s" is not available', $method->getName()));
     }
     switch (true) {
         case $transaction instanceof CreditCardTransaction:
             $this->processCreditCardTransaction($transaction);
             break;
         case $transaction instanceof PaypalTransaction:
             $this->processPaypalTransaction($transaction);
             break;
         default:
             throw new Exception(sprintf('Unhandled Transaction class "%s"', get_class($transaction)));
     }
     // Persist processed transaction
     $this->em->persist($transaction);
     $this->em->flush();
     // dispatch TransactionCreated event
     $this->dispatcher->dispatch(PaymentEvents::TRANSACTION_PROCESSED, new TransactionProcessedEvent($transaction));
 }
예제 #14
0
 /**
  * Processes the form.
  *
  * @param NotificationInterface $notification
  * @param array                 $parameters
  * @param String                $method
  *
  * @return NotificationInterface
  *
  * @throws \PROCERGS\LoginCidadao\CoreBundle\Exception\Notification\InvalidFormException
  */
 private function processForm(NotificationInterface $notification, array $parameters, $method = "PUT", PersonInterface $person = null)
 {
     $form = $this->formFactory->create($this->notificationType, $notification, compact('method'));
     $form->submit($parameters, 'PATCH' !== $method);
     if ($form->isValid()) {
         $notification = $form->getData();
         $notificationEvent = new NotificationEvent($notification);
         $this->dispatcher->dispatch(NotificationEvents::NOTIFICATION_INITIALIZE, $notificationEvent);
         if (null !== $person && $notification->getPerson()->getId() !== $person->getId()) {
             throw new AccessDeniedHttpException();
         }
         if (null === $notification->getHtmlTemplate()) {
             $notification->setHtmlTemplate(self::renderHtmlByCategory($notification->getCategory(), $notification->getPlaceholders(), $notification->getTitle(), $notification->getShortText()));
         }
         $this->om->persist($notification);
         $this->om->flush($notification);
         $this->dispatcher->dispatch(NotificationEvents::NOTIFICATION_SUCCESS, $notificationEvent);
         $this->dispatcher->dispatch(NotificationEvents::NOTIFICATION_COMPLETED, $notificationEvent);
         return $notification;
     }
     throw new InvalidFormException('Invalid submitted data ' . print_r($this->getErrorMessages($form), 1), $form);
 }
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     switch ($eventName) {
         case 'kernel.request':
             $this->stopwatch->openSection();
             break;
         case 'kernel.view':
         case 'kernel.response':
             // stop only if a controller has been executed
             try {
                 $this->stopwatch->stop('controller');
             } catch (\LogicException $e) {
             }
             break;
         case 'kernel.terminate':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->openSection($token);
             break;
     }
     $e1 = $this->stopwatch->start($eventName, 'section');
     parent::dispatch($eventName, $event);
     $e1->stop();
     switch ($eventName) {
         case 'kernel.controller':
             $this->stopwatch->start('controller', 'section');
             break;
         case 'kernel.response':
             $token = $event->getResponse()->headers->get('X-Debug-Token');
             $this->stopwatch->stopSection($token);
             $this->updateProfile($token);
             break;
         case 'kernel.terminate':
             $this->stopwatch->stopSection($token);
             $this->updateProfile($token);
             break;
     }
     return $event;
 }
예제 #16
0
 /**
  * Dispatch event.
  *
  * @param string                                  $name
  * @param Symfony\Component\EventDispatcher\Event $event
  *
  * @return Zikula_Event
  */
 public function dispatch($name, Event $event = null)
 {
     $dispatcher = func_num_args() === 3 ? func_get_arg(2) : null;
     return parent::dispatch($name, $event, $dispatcher);
 }
 public function testRemoveAfterDispatch()
 {
     $service = $this->getMock('Symfony\\Component\\EventDispatcher\\Tests\\Service');
     $container = new Container();
     $container->set('service.listener', $service);
     $dispatcher = new ContainerAwareEventDispatcher($container);
     $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'));
     $dispatcher->dispatch('onEvent', new Event());
     $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent'));
     $this->assertFalse($dispatcher->hasListeners('onEvent'));
 }
예제 #18
0
 /**
  * @param       $eventName
  * @param array $keys
  *
  * @return array
  */
 protected function dispatchIntegrationKeyEvent($eventName, $keys = array())
 {
     /** @var PluginIntegrationKeyEvent $event */
     $event = $this->dispatcher->dispatch($eventName, new PluginIntegrationKeyEvent($this, $keys));
     return $event->getKeys();
 }
예제 #19
0
 /**
  * Reboot.
  *
  * Shutdown the system flushing all event handlers, services and service arguments.
  *
  * @return void
  */
 public function reboot()
 {
     $event = new GenericEvent($this);
     $this->dispatcher->dispatch('shutdown', $event);
     // flush handlers
     foreach ($this->dispatcher->getListeners() as $eventName => $listener) {
         $this->dispatcher->removeListener($eventName, $listener);
     }
     // flush all services
     $services = $this->container->getServiceIds();
     rsort($services);
     foreach ($services as $id) {
         if (!in_array($id, array('zikula', 'service_container', 'event_dispatcher'))) {
             $this->container->removeDefinition($id);
         }
     }
     // flush arguments.
     $this->container->setArguments(array());
     $this->attachedHandlers = array();
     $this->stage = 0;
     $this->bootime = microtime(true);
 }
예제 #20
0
 public function persistIdCard(FormInterface $form, $data)
 {
     $event = new FormEvent($form, $data);
     $this->dispatcher->dispatch(ValidationEvents::VALIDATION_ID_CARD_PERSIST, $event);
 }
예제 #21
0
 /**
  * Initialise Zikula.
  *
  * Carries out a number of initialisation tasks to get Zikula up and
  * running.
  *
  * @param integer $stage Stage to load.
  *
  * @return boolean True initialisation successful false otherwise.
  */
 public function onInit(GetResponseEvent $event)
 {
     if ($event->getRequestType() === HttpKernelInterface::SUB_REQUEST) {
         return;
     }
     $this->dispatcher = $event->getDispatcher();
     $this->stage = $stage = self::STAGE_ALL;
     $coreInitEvent = new GenericEvent($this);
     $coreInitEvent['request'] = $event->getRequest();
     // store the load stages in a global so other API's can check whats loaded
     $this->dispatcher->dispatch(CoreEvents::PREINIT, new GenericEvent($this));
     //        // Initialise and load configuration
     //        if ($stage & self::STAGE_CONFIG) {
     //            // error reporting
     //            if (!\System::isInstalling()) {
     //                // this is here because it depends on the config.php loading.
     //                $event = new GenericEvent(null, array('stage' => $stage));
     //                $this->dispatcher->dispatch(CoreEvents::ERRORREPORTING, $event);
     //            }
     //
     //            // initialise custom event listeners from config.php settings
     //            $coreInitEvent->setArgument('stage', self::STAGE_CONFIG);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //        // Check that Zikula is installed before continuing
     //        if (\System::getVar('installed') == 0 && !\System::isInstalling()) {
     //            $response = new RedirectResponse(\System::getBaseUrl().'install.php?notinstalled');
     //            $response->send();
     //            \System::shutdown();
     //        }
     //        if ($stage & self::STAGE_DB) {
     //            try {
     //                $dbEvent = new GenericEvent();
     //                $this->dispatcher->dispatch('doctrine.init_connection', $dbEvent);
     //                $dbEvent = new GenericEvent($this, array('stage' => self::STAGE_DB));
     //                $this->dispatcher->dispatch(CoreEvents::INIT, $dbEvent);
     //            } catch (\PDOException $e) {
     //                if (!\System::isInstalling()) {
     //                    header('HTTP/1.1 503 Service Unavailable');
     //                    require_once \System::getSystemErrorTemplate('dbconnectionerror.tpl');
     //                    \System::shutDown();
     //                } else {
     //                    return false;
     //                }
     //            }
     //        }
     if ($stage & self::STAGE_TABLES) {
         // Initialise dbtables
         \ModUtil::initCoreVars();
         if (!\System::isInstalling()) {
             \ModUtil::registerAutoloaders();
         }
         $coreInitEvent->setArgument('stage', self::STAGE_TABLES);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     //
     //        if ($stage & self::STAGE_SESSIONS) {
     ////            \SessionUtil::requireSession();
     //            $coreInitEvent->setArgument('stage', self::STAGE_SESSIONS);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //
     //        // Have to load in this order specifically since we cant setup the languages until we've decoded the URL if required (drak)
     //        // start block
     //        if ($stage & self::STAGE_LANGS) {
     ////            $lang = \ZLanguage::getInstance();
     //        }
     //
     //        if ($stage & self::STAGE_DECODEURLS) {
     ////            \System::queryStringDecode();
     //            $coreInitEvent->setArgument('stage', self::STAGE_DECODEURLS);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //
     //        if ($stage & self::STAGE_LANGS) {
     ////            $lang->setup();
     //            $coreInitEvent->setArgument('stage', self::STAGE_LANGS);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     //        // end block
     //
     //        if ($stage & self::STAGE_MODS) {
     ////            \ModUtil::load('SecurityCenter');
     //
     //            $coreInitEvent->setArgument('stage', self::STAGE_MODS);
     //            $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     //        }
     if ($stage & self::STAGE_THEME) {
         // register default page vars
         \PageUtil::registerVar('title');
         \PageUtil::setVar('title', \System::getVar('defaultpagetitle'));
         \PageUtil::registerVar('keywords', true);
         \PageUtil::registerVar('stylesheet', true);
         \PageUtil::registerVar('javascript', true);
         \PageUtil::registerVar('jsgettext', true);
         \PageUtil::registerVar('body', true);
         \PageUtil::registerVar('header', true);
         \PageUtil::registerVar('footer', true);
         //            $theme = \Zikula_View_Theme::getInstance();
         // set some defaults
         // Metadata for SEO
         //            $this->container['zikula_view.metatags']['description'] = \System::getVar('defaultmetadescription');
         //            $this->container['zikula_view.metatags']['keywords'] = \System::getVar('metakeywords');
         $coreInitEvent->setArgument('stage', self::STAGE_THEME);
         $this->dispatcher->dispatch(CoreEvents::INIT, $coreInitEvent);
     }
     // check the users status, if not 1 then log him out
     //        if (\UserUtil::isLoggedIn()) {
     //            $userstatus = \UserUtil::getVar('activated');
     //            if ($userstatus != UsersConstant::ACTIVATED_ACTIVE) {
     //                \UserUtil::logout();
     //                // TODO - When getting logged out this way, the existing session is destroyed and
     //                //        then a new one is created on the reentry into index.php. The message
     //                //        set by the registerStatus call below gets lost.
     //                \LogUtil::registerStatus(__('You have been logged out.'));
     //                $response = new RedirectResponse(\ModUtil::url('Users', 'user', 'login'));
     //                $response->send();
     //                exit;
     //            }
     //        }
     //        if (($stage & self::STAGE_POST) && ($this->stage & ~self::STAGE_POST)) {
     //            $this->dispatcher->dispatch(CoreEvents::POSTINIT, new GenericEvent($this, array('stages' => $stage)));
     //        }
     //
     //        $this->dispatcher->dispatch('frontcontroller.predispatch', new GenericEvent());
 }
예제 #22
0
 /**
  * Dispatches an event to all registered listeners.
  *
  * Wrapper for Symfony\Component\EventDispatcher\EventDispatcher::dispatch method.
  *
  * @param string $eventName The name of the event to dispatch. The name of the event is the name of the method that is invoked on listeners.
  * @param Event $event The event to pass to the event handlers/listeners. If not supplied, an empty Event instance is created.
  *
  * @return Event
  */
 public function notify($eventName, Event $event)
 {
     return parent::dispatch($eventName, $event);
 }
예제 #23
0
 /**
  * {@inheritdoc}
  */
 public function dispatch($eventName, Event $event = null)
 {
     $this->statsdClient->increment(str_replace('.', '-', $eventName));
     return $this->originalDispatcher->dispatch($eventName, $event);
 }