Created
January 22, 2013 06:02
-
-
Save dhotson/4592467 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Symfony\Component\HttpFoundation\Request; | |
class KelpieSymfonyAdaptor | |
{ | |
public function __construct($app) | |
{ | |
$this->_app = $app; | |
} | |
public function call($env) | |
{ | |
$response = $this->_app->handle($this->_createRequest($env)); | |
return array( | |
$response->getStatusCode(), | |
$response->headers->all(), | |
array($response->getContent()) | |
); | |
} | |
private function _createRequest($env) | |
{ | |
$get = $post = $cookie = $files = array(); | |
if (isset($env['QUERY_STRING'])) | |
parse_str($env['QUERY_STRING'], $get); | |
if (isset($env['REQUEST_BODY'])) | |
parse_str($env['REQUEST_BODY'], $post); | |
if (isset($env['HTTP_COOKIE'])) | |
$cookie = http_parse_cookie($env['HTTP_COOKIE'])->cookies; | |
$server = $env; | |
$body = $env['REQUEST_BODY']; | |
return new Request($get, $post, array(), $cookie, $files, $server, $body); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment