예제 #1
0
 /**
  * Constructor.
  *
  * @param string $baseUrl
  * @param string $basePath
  * @param array  $request
  * @param array  $server
  */
 public function __construct($baseUrl, $basePath, array $request = array(), array $server = array())
 {
     $this->baseUrl = $baseUrl;
     $this->basePath = $basePath;
     $this->attributes = new ParameterBag();
     $this->request = new ParameterBag($request ?: $_REQUEST);
     $this->server = new ServerBag($server ?: $_SERVER);
     $this->headers = new HeaderBag($this->server->getHeaders());
     // decode json content type
     if (stripos($this->headers->get('CONTENT_TYPE'), 'application/json') !== false) {
         if ($json = json_decode(@file_get_contents('php://input'), true)) {
             $this->request->add($json);
         }
     }
 }