mirror of
https://github.com/maximebf/php-debugbar.git
synced 2025-01-17 13:28:35 +01:00
OpenHandler::handle() can now take any objects implementing ArrayAccess as request data
This commit is contained in:
parent
8972b82a9a
commit
9264bd2749
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
- send the request id in headers and use the open handler to retreive the dataset
|
- send the request id in headers and use the open handler to retreive the dataset
|
||||||
- !! modified sendDataAsHeaders() to add $useOpenHandler as the first argument
|
- !! modified sendDataAsHeaders() to add $useOpenHandler as the first argument
|
||||||
|
- OpenHandler::handle() can now take any objects implementing ArrayAccess as request data
|
||||||
|
|
||||||
2013-09-19:
|
2013-09-19:
|
||||||
|
|
||||||
|
@ -33,23 +33,25 @@ class OpenHandler
|
|||||||
*
|
*
|
||||||
* @param array $request Request data
|
* @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) {
|
if ($request === null) {
|
||||||
$request = $_REQUEST;
|
$request = $_REQUEST;
|
||||||
}
|
}
|
||||||
if (!isset($request['op'])) {
|
|
||||||
$request['op'] = 'find';
|
$op = 'find';
|
||||||
}
|
if (isset($request['op'])) {
|
||||||
if (!in_array($request['op'], array('find', 'get', 'clear'))) {
|
$op = $request['op'];
|
||||||
throw new DebugBarException("Invalid operation '{$request['op']}'");
|
if (!in_array($op, array('find', 'get', 'clear'))) {
|
||||||
|
throw new DebugBarException("Invalid operation '{$request['op']}'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($sendHeader) {
|
if ($sendHeader) {
|
||||||
header('Content-Type: application/json');
|
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) {
|
if ($echo) {
|
||||||
echo $response;
|
echo $response;
|
||||||
}
|
}
|
||||||
@ -59,7 +61,7 @@ class OpenHandler
|
|||||||
/**
|
/**
|
||||||
* Find operation
|
* Find operation
|
||||||
*/
|
*/
|
||||||
protected function find(array $request)
|
protected function find($request)
|
||||||
{
|
{
|
||||||
$max = 20;
|
$max = 20;
|
||||||
if (isset($request['max'])) {
|
if (isset($request['max'])) {
|
||||||
@ -84,7 +86,7 @@ class OpenHandler
|
|||||||
/**
|
/**
|
||||||
* Get operation
|
* Get operation
|
||||||
*/
|
*/
|
||||||
protected function get(array $request)
|
protected function get($request)
|
||||||
{
|
{
|
||||||
if (!isset($request['id'])) {
|
if (!isset($request['id'])) {
|
||||||
throw new DebugBarException("Missing 'id' parameter in 'get' operation");
|
throw new DebugBarException("Missing 'id' parameter in 'get' operation");
|
||||||
@ -95,7 +97,7 @@ class OpenHandler
|
|||||||
/**
|
/**
|
||||||
* Clear operation
|
* Clear operation
|
||||||
*/
|
*/
|
||||||
protected function clear(array $request)
|
protected function clear($request)
|
||||||
{
|
{
|
||||||
$this->debugBar->getStorage()->clear();
|
$this->debugBar->getStorage()->clear();
|
||||||
return array('success' => true);
|
return array('success' => true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user