richdocuments/lib/request.php

39 lines
676 B
PHP
Raw Normal View History

2013-08-06 18:07:05 +03:00
<?php
namespace OCA\Office;
class Request {
protected $data = array();
protected $rawRequest = '';
2013-08-06 18:07:05 +03:00
public function __construct(){
$this->rawRequest = file_get_contents('php://input');
$this->data = json_decode($this->rawRequest, true);
}
public function getRawRequest(){
return $this->rawRequest;
2013-08-06 18:07:05 +03:00
}
2013-08-06 18:07:05 +03:00
public function getParam($name){
if (empty($name)){
return $this->data;
}
2013-08-06 18:07:05 +03:00
$path = explode('/', $name);
reset($path);
$index = current($path);
$param = $this->data;
do {
if (!array_key_exists($index, $param)){
return null;
}
$param = $param[$index];
} while (($index = next($path)) !== false);
return $param;
}
}