Example #1
0
 /**
  * Get the event name for the loop depending of the event name and the loop name.
  *
  * This function also checks if there are services that listen to this event.
  * If not the function returns null.
  *
  * @param string $eventName the event name (`TheliaEvents::LOOP_EXTENDS_ARG_DEFINITIONS`,
  *                          `TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS`, ...)
  * @return null|string The event name for the loop if listeners exist, otherwise null is returned
  */
 protected function getDispatchEventName($eventName)
 {
     $customEventName = TheliaEvents::getLoopExtendsEvent($eventName, $this->loopName);
     if (!isset(self::$dispatchCache[$customEventName])) {
         self::$dispatchCache[$customEventName] = $this->dispatcher->hasListeners($customEventName);
     }
     return self::$dispatchCache[$customEventName] ? $customEventName : null;
 }
 /**
  * Returns an array of event names this subscriber wants to listen to.
  *
  * @return array The event names to listen to
  *
  * @api
  */
 public static function getSubscribedEvents()
 {
     return [TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'customer') => ['extendCustomerLoop', 128], TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'order') => ['extendOrderLoop', 128], TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_INITIALIZE_ARGS, 'order') => ['changeLimit', 128], TheliaEvents::getLoopExtendsEvent(TheliaEvents::LOOP_EXTENDS_BUILD_MODEL_CRITERIA, 'product') => ['extendProductBuildModelCriteria', 120]];
 }