@ 2014-07-10T11:21:22Z <?php
namespace Qihoo\Controller\Decorator;
use Beahoo\Controller\Request;
use Beahoo\Controller\Response;
/**
* 前端JSONP回调函数装饰器
*
* @package Qihoo\Controller\Decorator
*/
class CallbackDecorator extends \Beahoo\Controller\Decorator
{
/**
* 执行
*
* @param \Beahoo\Controller\Request $request
* @param \Beahoo\Controller\Response $response
*
* @result void
*/
public function execute(Request $request, Response $response)
{
parent::execute($request, $response);
$callback = $request->getQueryArg('callback');
if ($callback && preg_match('/^[\._a-z0-9]+$/i', $callback)) {
$body = $response->getBody();
if (is_array($body)) {
$body = json_encode($body);
}
$body = "{$callback}({$body})";
$response->setBody($body);
}
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.6 Fatal error: Uncaught Error: Class "Beahoo\Controller\Decorator" not found in /in/hEo4g:13
Stack trace:
#0 {main}
thrown in /in/hEo4g on line 13
Process exited with code 255 . Output for 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 Fatal error: Uncaught Error: Class 'Beahoo\Controller\Decorator' not found in /in/hEo4g:13
Stack trace:
#0 {main}
thrown in /in/hEo4g on line 13
Process exited with code 255 . Output for 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 Fatal error: Class 'Beahoo\Controller\Decorator' not found in /in/hEo4g on line 13
Process exited with code 255 . Output for 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.40 Fatal error: Class 'Beahoo\Controller\Decorator' not found in /in/hEo4g on line 14
Process exited with code 255 . preferences:dark mode live preview
201.92 ms | 402 KiB | 406 Q