Skip to content

Instantly share code, notes, and snippets.

@dhotson
Created January 22, 2013 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhotson/4592467 to your computer and use it in GitHub Desktop.
Save dhotson/4592467 to your computer and use it in GitHub Desktop.
<?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