/**
  * Constructor
  *
  * @param ApplicationUserId $id
  * @param string            $username
  * @param string            $preferredLanguage
  */
 public function __construct(ApplicationUserId $id, $username, $preferredLanguage)
 {
     parent::__construct(self::NAME);
     $this->userId = $id;
     $this->username = $username;
     $this->preferredLanguage = $preferredLanguage;
 }
 function it_should_emit_string_event_when_committing_if_transaction_is_running(EmitterInterface $emitter)
 {
     $this->beginTransaction();
     $this->emit('test');
     $emitter->emit(Event::named('test'))->shouldBeCalled();
     $this->commit();
 }
 /**
  * Constructor
  *
  * @param MiniGameId $gameId
  * @param PlayerId   $playerId
  * @param string     $message
  */
 public function __construct(MiniGameId $gameId, PlayerId $playerId, $message)
 {
     parent::__construct(static::NAME);
     $this->gameId = $gameId;
     $this->playerId = $playerId;
     $this->message = $message;
 }
 /**
  * @param $event
  *
  * @return EventInterface
  */
 private function addEvent($event)
 {
     if (is_string($event)) {
         $event = Event::named($event);
     }
     if (!$event instanceof EventInterface) {
         throw new \InvalidArgumentException('Events should be provides as Event instances or string, received type: ' . gettype($event));
     }
     $this->events[] = $event;
     return $event;
 }
 /**
  * @param int   $league
  *
  * @return null|array
  */
 public function retrieve($league = null)
 {
     $url = $this->getSchedulesUrlByLeagueId($league['id']);
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_PRE_MATCH), ['league' => &$league, 'url' => &$url]);
     }
     $schedules = json_decode(file_get_contents($url), true);
     unset($schedules['players']);
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_POST_MATCH), ['league' => &$league, 'schedules' => &$schedules]);
     }
     return $schedules;
 }
Exemple #6
0
 /**
  * @param mixed $param
  *
  * @return null|array
  */
 public function retrieve($param = null)
 {
     $url = $this->getUrl();
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_PRE_LEAGUES), ['url' => &$url]);
     }
     $leagues = json_decode(file_get_contents($url), true);
     if (isset($leagues['leagues'])) {
         $leagues =& $leagues['leagues'];
     }
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_POST_LEAGUES), ['blocks' => &$leagues]);
     }
     return $leagues;
 }
Exemple #7
0
 public function exportAll($calendars)
 {
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_PRE_EXPORT));
     }
     foreach ($this as $exporter) {
         if ($exporter instanceof ExporterInterface) {
             foreach ($calendars as $calendar) {
                 $exporter->export($calendar);
             }
         }
     }
     if ($this->getEmitter() instanceof EmitterInterface) {
         $this->getEmitter()->emit(Event::named(self::EVENT_POST_EXPORT));
     }
 }
Exemple #8
0
 protected function respondError($errorStr)
 {
     $this->emitter->emit(Event::named('error'), $errorStr);
     http_response_code(500);
     Header('Content-type: application/json');
     echo json_encode(['status_code' => 500, 'message' => 'Internal server error']);
     exit;
 }
Exemple #9
0
 /**
  * TestEvent constructor.
  */
 public function __construct()
 {
     parent::__construct('test');
 }
Exemple #10
0
 public function __construct()
 {
     parent::__construct('foo.event');
 }
 /**
  * Sets the event name
  */
 public function __construct()
 {
     parent::__construct(Events::TAKE_PAYMENT_SUCCESS);
 }
 /**
  * Ensure event input is of type EventInterface or convert it.
  *
  * @param string|EventInterface $event
  *
  * @throws InvalidArgumentException
  *
  * @return EventInterface
  */
 protected function ensureEvent($event)
 {
     if (is_string($event)) {
         return Event::named($event);
     }
     if (!$event instanceof EventInterface) {
         throw new InvalidArgumentException('Events should be provides as Event instances or string, received type: ' . gettype($event));
     }
     return $event;
 }
Exemple #13
0
 /**
  * @param string $eventName
  * @param array $params
  */
 public function __construct($eventName, array $params = array())
 {
     parent::__construct($eventName);
     $this->params = $params;
 }
Exemple #14
0
 public function __construct()
 {
     parent::__construct(get_called_class());
 }
Exemple #15
0
 public function __construct($name)
 {
     parent::__construct($name);
     $this->parameters = new \hass\base\classes\Parameters();
 }
 public function addToEventsTriggered(Event $event, $params = [])
 {
     $this->eventsTriggered[$event->getName()][] = ['event' => $event, 'params' => $params];
 }
Exemple #17
0
 public static function emitEventNamed($eventName)
 {
     return self::emitter()->emit(Event::named($eventName));
 }
 /**
  * SerializableEvent constructor.
  *
  * @param string $name
  * @param array $payload
  */
 public function __construct($name, array $payload = [])
 {
     parent::__construct($name);
     $this->payload = $payload;
 }
Exemple #19
0
 public function __construct(ServerRequestInterface $request, string $name)
 {
     parent::__construct($name);
 }
 /**
  * RequestEvent constructor.
  *
  * @param string                 $name
  * @param ServerRequestInterface $request
  */
 public function __construct($name, ServerRequestInterface $request)
 {
     parent::__construct($name);
     $this->request = $request;
 }
Exemple #21
0
 /**
  * Manage session timeout.
  *
  * @throws \InvalidArgumentException
  */
 protected function manageSessionTimeout()
 {
     if (array_key_exists($this->sessionTimeoutKey, $_SESSION) && $_SESSION[$this->sessionTimeoutKey] < time()) {
         $this->emit(Event::named('pre.session_timeout'), session_id());
         $this->recreateSession();
         $this->emit(Event::named('post.session_timeout'), session_id());
     }
     $_SESSION[$this->sessionTimeoutKey] = time() + $this->sessionLifetime;
 }
Exemple #22
0
 /**
  * Returns events to be emitted whenever a state transition is attempted
  *
  * @param Input $input
  * @param State $currentState
  *
  * @return Generator
  */
 private function eventProvider(Input $input, State $currentState) : Generator
 {
     $anyInput = FlyweightInput::any();
     $anyState = FlyweightState::any();
     (yield Event::named($this->getEventName('before', $input, $currentState)));
     (yield Event::named($this->getEventName('before', $anyInput, $currentState)));
     (yield Event::named($this->getEventName('before', $input, $anyState)));
     (yield Event::named($this->getEventName('before', $anyInput, $anyState)));
     (yield Event::named($this->getEventName('on', $anyInput, $anyState)));
     (yield Event::named($this->getEventName('after', $input, $currentState)));
     (yield Event::named($this->getEventName('after', $anyInput, $currentState)));
     (yield Event::named($this->getEventName('after', $input, $anyState)));
     (yield Event::named($this->getEventName('after', $anyInput, $anyState)));
 }
 /**
  * Constructor
  *
  * @param ApplicationUserId        $userId
  * @param UndefinedApplicationUser $user
  */
 public function __construct(ApplicationUserId $userId, UndefinedApplicationUser $user)
 {
     parent::__construct(self::NAME);
     $this->userId = $userId;
     $this->user = $user;
 }
 /**
  * Sets the event name
  */
 public function __construct()
 {
     parent::__construct(Events::TAKE_PAYMENT_FAILURE);
 }
Exemple #25
0
 /**
  * @param Session $session
  * @param string $name
  */
 public function __construct(Session $session, $name = null)
 {
     parent::__construct($name);
     $this->session = $session;
 }
 /**
  * Constructor
  *
  * @param string     $name
  * @param MiniGameId $gameId
  * @param PlayerId   $playerId
  */
 public function __construct($name, MiniGameId $gameId, PlayerId $playerId = null)
 {
     parent::__construct($name);
     $this->gameId = $gameId;
     $this->playerId = $playerId;
 }
 public function __invoke(Event $event, Stateful $object, Context $context, Input $input, State $nextState)
 {
     /*
      * We only care that the same context was passed to each event, so we'll
      * keep track of it here for asserting in our tests.
      */
     if (!$this->context) {
         $this->context = $context;
     }
     $this->append([$event->getName(), $object, $context, $input, $nextState]);
 }
Exemple #28
0
 public function __construct()
 {
     parent::__construct(Engine::APP_CLEANUP_EVENT);
 }
 /**
  * ThirdPartyAccountLinkedEvent constructor.
  *
  * @param ApplicationUserId $userId
  * @param Account           $thirdPartyAccount
  */
 public function __construct(ApplicationUserId $userId, Account $thirdPartyAccount)
 {
     parent::__construct(self::NAME);
     $this->userId = $userId;
     $this->thirdPartyAccount = $thirdPartyAccount;
 }
Exemple #30
0
 /**
  * @param Environment $environment
  */
 public function __construct()
 {
     parent::__construct(Engine::ENGINE_BOOTUP_EVENT);
 }