Blame view

sources/apps/documents/lib/request.php 897 Bytes
d1bafeea1   Kload   [fix] Upgrade to ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
  <?php
  /**
   * ownCloud - Documents App
   *
   * @author Victor Dubiniuk
   * @copyright 2013 Victor Dubiniuk victor.dubiniuk@gmail.com
   *
   * This file is licensed under the Affero General Public License version 3 or
   * later.
   */
  
  namespace OCA\Documents;
  
  class Request {
  	protected $data = array();
  	
  	protected $rawRequest = '';
  	
  	public function __construct(){
  		$this->rawRequest = file_get_contents('php://input');
  		$this->data = json_decode($this->rawRequest, true);
  	}
  	
  	public function getRawRequest(){
  		return $this->rawRequest;
  	}
  
  	public function getParam($name){
  		if (empty($name)){
  			return $this->data;
  		}
  		
  		$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;
  	}
  }