Skip to content

Commit

Permalink
Make compatible with Laravel 5.5
Browse files Browse the repository at this point in the history
app()->make() parameters were removed in Laravel 5.4 (laravel/framework#17556) - to work around that, we need to set the parameters manually after creating/retrieving the instance.
  • Loading branch information
Tobias Jacksteit committed Feb 2, 2018
1 parent 227eac7 commit e89f4e7
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
11 changes: 11 additions & 0 deletions src/Contract/EventClassHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,15 @@ interface EventClassHandlerInterface
*/
public function getEventClass();

/**
* Set parameters for EventClassHandler
*
* @param WebhooksInterface $webhooks
* @param $webhookName
* @param $eventName
* @param array $eventMap
*
* @return mixed
*/
public function setParameters(WebhooksInterface $webhooks, $webhookName, $eventName, $eventMap = []);
}
5 changes: 3 additions & 2 deletions src/Handler/EventClassHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,14 @@ class EventClassHandler implements EventClassHandlerInterface
protected $webhooks;

/**
* EventClassHandler constructor.
* Set parameters for EventClassHandler
*
* @param WebhooksInterface $webhooks
* @param $webhookName
* @param string $eventName
* @param array $eventMap
*/
public function __construct(WebhooksInterface $webhooks, $webhookName, $eventName, $eventMap = [])
public function setParameters(WebhooksInterface $webhooks, $webhookName, $eventName, $eventMap = [])
{
$this->eventName = $eventName;
$this->webhookName = $webhookName;
Expand Down
9 changes: 5 additions & 4 deletions src/Http/WebhookRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,13 @@ protected function getEventClass()
*/
protected function getEventClassHandler()
{
return app(EventClassHandlerInterface::class, [
app(WebhooksInterface::class),
$eventClassHandler = app(EventClassHandlerInterface::class);
$eventClassHandler->setParameters(app(WebhooksInterface::class),
$this->getWebhookName(),
$this->getEventName(),
$this->getEvents(),
]);
$this->getEvents());

return $eventClassHandler;
}

/**
Expand Down

0 comments on commit e89f4e7

Please sign in to comment.