Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
alcalyn committed Sep 1, 2017
2 parents ebbf467 + d1104cb commit caff19b
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion src/Application.php
Expand Up @@ -11,13 +11,23 @@

class Application extends BaseApplication
{
/**
* Events lists marked as to forward before application boot.
* Needs to be forwarded once application booted.
*
* @var string[][]
*/
private $events;

/**
* {@InheritDoc}
*/
public function __construct(array $values = array())
{
parent::__construct($values);

$this->events = [];

$this->fixAuthorizationHeader();
}

Expand Down Expand Up @@ -100,8 +110,35 @@ public function forwardEventsToPushServer(array $eventsNames)
));
}

$this['sandstone.push.event_forwarder']->forwardAllEvents($eventsNames);
if ($this->booted) {
$this['sandstone.push.event_forwarder']->forwardAllEvents($eventsNames);
} else {
$this->events []= $eventsNames;
}

return $this;
}

/**
* {@InheritDoc}
*
* Forward events marked as to be forwarded before application boot.
*
* Allow to use forwardEventsToPushServer in register
* instead of forcing user to forward event only at boot.
*/
public function boot()
{
if ($this->booted) {
return;
}

parent::boot();

foreach ($this->events as $eventsNames) {
$this->forwardEventsToPushServer($eventsNames);
}

$this->events = [];
}
}

0 comments on commit caff19b

Please sign in to comment.