示例#1
0
 /**
  * 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;
 }
示例#5
0
 /**
  * @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;
 }
示例#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;
 }
示例#7
0
文件: Map.php 项目: olol/lolesp-cal
 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));
     }
 }
示例#8
0
文件: Server.php 项目: sforsman/rest
 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;
 }
示例#9
0
 /**
  * TestEvent constructor.
  */
 public function __construct()
 {
     parent::__construct('test');
 }
示例#10
0
 public function __construct()
 {
     parent::__construct('foo.event');
 }
 /**
  * Sets the event name
  */
 public function __construct()
 {
     parent::__construct(Events::TAKE_PAYMENT_SUCCESS);
 }
示例#12
0
 /**
  * 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;
 }
示例#13
0
文件: Event.php 项目: evaneos/berthe
 /**
  * @param string $eventName
  * @param array $params
  */
 public function __construct($eventName, array $params = array())
 {
     parent::__construct($eventName);
     $this->params = $params;
 }
示例#14
0
 public function __construct()
 {
     parent::__construct(get_called_class());
 }
示例#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];
 }
示例#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;
 }
示例#19
0
 public function __construct(ServerRequestInterface $request, string $name)
 {
     parent::__construct($name);
 }
示例#20
0
 /**
  * RequestEvent constructor.
  *
  * @param string                 $name
  * @param ServerRequestInterface $request
  */
 public function __construct($name, ServerRequestInterface $request)
 {
     parent::__construct($name);
     $this->request = $request;
 }
示例#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;
 }
示例#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);
 }
示例#25
0
文件: Event.php 项目: sobstel/sesshin
 /**
  * @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;
 }
示例#27
0
 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]);
 }
示例#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;
 }
示例#30
0
 /**
  * @param Environment $environment
  */
 public function __construct()
 {
     parent::__construct(Engine::ENGINE_BOOTUP_EVENT);
 }