Skip to content

Commit

Permalink
compatibility swoole branch
Browse files Browse the repository at this point in the history
  • Loading branch information
xujiajun committed Jul 25, 2017
1 parent 93858dd commit 9323289
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/Framework/Event/HttpEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ final class HttpEvent extends Event

protected $response;

public function __construct($request = null, $response = null)
protected $parameters;

public function __construct($request = null, $response = null, $parameters = null)
{
$this->request = $request;
$this->response = $response;
$this->parameters = $parameters;
}

public function getResponse()
Expand All @@ -25,4 +28,9 @@ public function getRequest()
{
return $this->request;
}
}

public function getParameters()
{
return $this->parameters;
}
}
4 changes: 4 additions & 0 deletions src/Framework/Listener/ResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ class ResponseListener
public function onResponseAction(Event $event)
{
$response = $event->getResponse();
$app = $event->getParameters();

if (is_string($response)) {
if (!empty($app['swoole'])) {
return $response;
}
echo $response;
return;
}
Expand Down
5 changes: 4 additions & 1 deletion src/Framework/Traits/KernelTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ trait KernelTrait
*/
public function run()
{
$this['eventDispatcher']->dispatch(AppEvent::RESPONSE, new \TastPHP\Framework\Event\HttpEvent(null, $this['router']->matchCurrentRequest()));
$httpEvent = $this['eventDispatcher']->dispatch(AppEvent::RESPONSE, new \TastPHP\Framework\Event\HttpEvent(null, $this['router']->matchCurrentRequest(),$this));
if (!empty($this['swoole'])) {
return $httpEvent;
}
}

/**
Expand Down

0 comments on commit 9323289

Please sign in to comment.