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 |
---|---|---|
.. | ||
auth/drivers | Loading commit data... | |
cache/drivers | Loading commit data... | |
cli | Loading commit data... | |
database | Loading commit data... | |
documentation | Loading commit data... | |
profiling | Loading commit data... | |
routing | Loading commit data... | |
session | Loading commit data... | |
tests | Loading commit data... | |
vendor/Symfony/Component | Loading commit data... | |
asset.php | Loading commit data... | |
auth.php | Loading commit data... | |
autoloader.php | Loading commit data... | |
blade.php | Loading commit data... | |
bundle.php | Loading commit data... | |
cache.php | Loading commit data... | |
config.php | Loading commit data... | |
cookie.php | Loading commit data... | |
core.php | Loading commit data... | |
crypter.php | Loading commit data... | |
database.php | Loading commit data... | |
error.php | Loading commit data... | |
event.php | Loading commit data... | |
file.php | Loading commit data... | |
fluent.php | Loading commit data... | |
form.php | Loading commit data... | |
hash.php | Loading commit data... | |
helpers.php | Loading commit data... | |
html.php | Loading commit data... | |
input.php | Loading commit data... | |
ioc.php | Loading commit data... | |
lang.php | Loading commit data... | |
laravel.php | Loading commit data... | |
log.php | Loading commit data... | |
memcached.php | Loading commit data... | |
messages.php | Loading commit data... | |
paginator.php | Loading commit data... | |
pluralizer.php | Loading commit data... | |
redirect.php | Loading commit data... | |
redis.php | Loading commit data... | |
request.php | Loading commit data... | |
response.php | Loading commit data... | |
section.php | Loading commit data... | |
session.php | Loading commit data... | |
str.php | Loading commit data... | |
uri.php | Loading commit data... | |
url.php | Loading commit data... | |
validator.php | Loading commit data... | |
view.php | Loading commit data... |