1. 12 Jan, 2013 1 commit
  2. 16 Oct, 2012 1 commit
    • Pass the response by reference so it can be overwritten in filters · 81a2f5b9
      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>
      Blaine Schmeisser committed
  3. 24 Sep, 2012 3 commits
  4. 03 Aug, 2012 1 commit
  5. 27 Jul, 2012 2 commits
  6. 22 Jul, 2012 1 commit
  7. 27 Jun, 2012 1 commit
  8. 24 Jun, 2012 1 commit
  9. 13 Jun, 2012 1 commit
  10. 30 May, 2012 1 commit
  11. 12 May, 2012 1 commit
  12. 10 May, 2012 4 commits
  13. 03 May, 2012 2 commits
  14. 26 Apr, 2012 1 commit
  15. 19 Apr, 2012 1 commit
  16. 16 Apr, 2012 1 commit
  17. 13 Apr, 2012 1 commit
  18. 21 Mar, 2012 1 commit
  19. 12 Mar, 2012 1 commit
  20. 05 Mar, 2012 1 commit
  21. 28 Feb, 2012 3 commits
  22. 24 Feb, 2012 1 commit
  23. 23 Feb, 2012 3 commits
  24. 22 Feb, 2012 1 commit
  25. 18 Feb, 2012 1 commit
  26. 14 Feb, 2012 1 commit
  27. 13 Feb, 2012 3 commits