Skip to content

Commit

Permalink
support event
Browse files Browse the repository at this point in the history
  • Loading branch information
hhxsv5 committed Jan 25, 2018
1 parent 6f93f1c commit 9e8c212
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Illuminate/Laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,9 @@ protected function clean(Request $request)

//...
}

public function fireEvent($name, array $params = [])
{
$this->app->events->fire($name, $params);
}
}
2 changes: 2 additions & 0 deletions src/LaravelS.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function onRequest(\swoole_http_request $request, \swoole_http_response $
$laravelRequest = (new Request($request))->toIlluminateRequest();
$success = $this->handleStaticResource($laravelRequest, $response);
if (!$success) {
$this->laravel->fireEvent('laravels.request', [$laravelRequest]);
$this->handleDynamicResource($laravelRequest, $response);
}

Expand All @@ -74,6 +75,7 @@ protected function handleStaticResource(IlluminateRequest $laravelRequest, \swoo
protected function handleDynamicResource(IlluminateRequest $laravelRequest, \swoole_http_response $swooleResponse)
{
$laravelResponse = $this->laravel->handleDynamic($laravelRequest);
$this->laravel->fireEvent('laravels.response', [$laravelResponse]);
(new DynamicResponse($swooleResponse, $laravelResponse))->send();
return true;
}
Expand Down

0 comments on commit 9e8c212

Please sign in to comment.