diff --git a/CHANGELOG.md b/CHANGELOG.md index fa47857..bd85a28 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - send the request id in headers and use the open handler to retreive the dataset - !! modified sendDataAsHeaders() to add $useOpenHandler as the first argument + - OpenHandler::handle() can now take any objects implementing ArrayAccess as request data 2013-09-19: diff --git a/src/DebugBar/OpenHandler.php b/src/DebugBar/OpenHandler.php index a8e514d..0fc7772 100644 --- a/src/DebugBar/OpenHandler.php +++ b/src/DebugBar/OpenHandler.php @@ -33,23 +33,25 @@ class OpenHandler * * @param array $request Request data */ - public function handle(array $request = null, $echo = true, $sendHeader = true) + public function handle($request = null, $echo = true, $sendHeader = true) { if ($request === null) { $request = $_REQUEST; } - if (!isset($request['op'])) { - $request['op'] = 'find'; - } - if (!in_array($request['op'], array('find', 'get', 'clear'))) { - throw new DebugBarException("Invalid operation '{$request['op']}'"); + + $op = 'find'; + if (isset($request['op'])) { + $op = $request['op']; + if (!in_array($op, array('find', 'get', 'clear'))) { + throw new DebugBarException("Invalid operation '{$request['op']}'"); + } } if ($sendHeader) { header('Content-Type: application/json'); } - $response = json_encode(call_user_func(array($this, $request['op']), $request)); + $response = json_encode(call_user_func(array($this, $op), $request)); if ($echo) { echo $response; } @@ -59,7 +61,7 @@ class OpenHandler /** * Find operation */ - protected function find(array $request) + protected function find($request) { $max = 20; if (isset($request['max'])) { @@ -84,7 +86,7 @@ class OpenHandler /** * Get operation */ - protected function get(array $request) + protected function get($request) { if (!isset($request['id'])) { throw new DebugBarException("Missing 'id' parameter in 'get' operation"); @@ -95,7 +97,7 @@ class OpenHandler /** * Clear operation */ - protected function clear(array $request) + protected function clear($request) { $this->debugBar->getStorage()->clear(); return array('success' => true);