| Name |
Last commit
|
Last update |
|---|---|---|
| application | ||
| bundles | ||
| laravel | ||
| public | ||
| storage | ||
| .gitattributes | ||
| .gitignore | ||
| .travis.yml | ||
| CONTRIBUTING.md | ||
| artisan | ||
| license.txt | ||
| paths.php | ||
| readme.md |
You can edit the response but you can't overwrite it: ~~~ php <?php // https://gist.github.com/3896743 $response = new stdClass(); echo '1): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcd00000000e93b17ba call_user_func_array(function($response) { $response = new stdClass(); echo '2): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba }, array($response)); echo '3): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcd00000000e93b17ba call_user_func_array(function($response) { $response = new stdClass(); echo '4): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba // hash descoped and reused }, array(&$response)); echo '5): ' . spl_object_hash($response) . PHP_EOL; // 0000000021e89fcf00000000e93b17ba ~~~ Otherwise you'd make the new response object and overwrite the values one at a time: ~~~ php <?php // https://gist.github.com/3897032 Route::filter('after', function($response) { $params = \Laravel\Request::$route->parameters; // The 'type' is the last param // example: /product/(:num).(:any) $type = array_pop($params); if($type == 'json') { $res = Response::json($response->content->data); foreach($response as $key => &$value) { $response->$key = $res->$key; } } }); ~~~ Signed-off-by: Blaine Schmeisser <blaine.schmeisser@vitals.com>
| Name |
Last commit
|
Last update |
|---|---|---|
| application | Loading commit data... | |
| bundles | Loading commit data... | |
| laravel | Loading commit data... | |
| public | Loading commit data... | |
| storage | Loading commit data... | |
| .gitattributes | Loading commit data... | |
| .gitignore | Loading commit data... | |
| .travis.yml | Loading commit data... | |
| CONTRIBUTING.md | Loading commit data... | |
| artisan | Loading commit data... | |
| license.txt | Loading commit data... | |
| paths.php | Loading commit data... | |
| readme.md | Loading commit data... |