Commit Graph

67 Commits

Author SHA1 Message Date
Blaine Schmeisser
81a2f5b919 Pass the response by reference so it can be overwritten in filters
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>
2012-10-16 09:12:29 -05:00
Chris Berthe
b325e954e3 Merge remote-tracking branch 'upstream/develop' into develop 2012-07-12 11:15:43 -04:00
Jason Lewis
ac810f8597 Allow filter patterns to supply a name and callback as an easier alternative.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-06-24 19:28:53 +09:30
Chris Berthe
fafaf724b0 Grammar/Vocabulary fixes
Signed-off-by: Chris Berthe <chrisberthe@gmail.com>
2012-06-13 11:19:20 -04:00
Taylor Otwell
21a51b7cf9 Add controller and controller_action to route. 2012-05-10 08:44:43 -05:00
Andrew Ellis
fdad58383b cleaned up phpdoc and removed as it is not used 2012-05-03 11:14:33 -06:00
Taylor Otwell
34cb9a00f4 move 'is' method to the str class where it belongs. 2012-04-12 22:54:50 -05:00
Taylor Otwell
3c3e913689 Renamed Route::load to Route::forward. 2012-03-21 11:19:29 -05:00
Taylor Otwell
6e82a4ac8d Merge pull request #359 from akuzemchak/feature/load-route
Load designated route's response
2012-03-21 09:15:42 -07:00
Taylor Otwell
425192a05d fix bug in route. 2012-02-28 09:30:43 -06:00
Taylor Otwell
5325acac64 adding support for attaching filters based on URI routing.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-02-28 09:28:23 -06:00
Aaron Kuzemchak
115eb8d085 Added shortcut method to load a designated route's response 2012-02-23 20:08:12 -05:00
Taylor Otwell
14c9d38270 add facade for filter::register. 2012-02-14 08:22:10 -06:00
Taylor Otwell
6ced385d20 use 'as' instead of 'name'. 2012-02-13 16:50:41 -06:00
Taylor Otwell
86e109b7bc simplify route parameter parsing and fix default value bug. 2012-02-13 14:42:38 -06:00
Taylor Otwell
3d1a44028a added route::share method. 2012-02-12 16:41:03 -06:00
Taylor Otwell
3a92facc76 updated routing to fix several issues. 2012-02-12 14:48:36 -06:00
Taylor Otwell
31cf44c374 working on routing. 2012-02-09 23:43:02 -06:00
Taylor Otwell
4330124d79 added route:destination method. 2012-02-09 23:36:08 -06:00
Taylor Otwell
3dab550681 fixing route bundle determination. 2012-02-06 09:21:35 -06:00
Phill Sparks
62072e5281 PHPDoc fixes 2012-02-04 21:30:52 +00:00
Taylor Otwell
d462a72981 adjusting route class. 2012-02-03 10:43:09 -06:00
Taylor Otwell
17213fe073 urldecode all route parameters. 2012-02-03 10:35:15 -06:00
Eric Barnes
ea8c6e1825 Fixed route handles for uri's that partially match 2012-01-19 08:47:17 -05:00
Taylor Otwell
9bcbe6a357 fix bug in route handles method. 2012-01-18 15:28:16 -06:00
Taylor Otwell
eb193c1d12 working on the route class. 2012-01-18 12:44:00 -06:00
Taylor Otwell
73c09f2f29 fixed bug in router. 2012-01-18 11:41:13 -06:00
Taylor Otwell
aa427bbd39 added route test for handles method. fixed bug in route class. 2012-01-18 11:25:11 -06:00
Taylor Otwell
b5442c67fc merged skunkworks into develop. 2012-01-16 13:59:24 -06:00
Taylor Otwell
ad9b49a23e Extract callback validation into method. 2011-11-23 08:49:09 -06:00
Taylor Otwell
937441d31b cleaning up more code. 2011-11-21 22:22:41 -06:00
Taylor Otwell
5e95f05d9b added more to comment. 2011-11-20 22:51:31 -06:00
Taylor Otwell
10b9001e13 adjust how the response is rendered, as well as move input flashing to after filter. 2011-11-20 22:47:56 -06:00
Taylor Otwell
7a9631975f dont return 404 error on null return from existing route. 2011-11-20 22:28:51 -06:00
Phill Sparks
58638216e8 Throw better Exceptions 2011-11-15 12:35:04 +00:00
Taylor Otwell
d1a969bd29 added uri class. refactored. 2011-11-14 21:18:18 -06:00
Taylor Otwell
a38ba2a6ab clean up controller and session. 2011-11-08 20:35:24 -06:00
Taylor Otwell
a1e82d2166 added section class. refactored session for ioc usage. improved controller. added yielding and sections to blade. general blade improvements. 2011-11-08 20:08:20 -06:00
Taylor Otwell
895d876463 fixed bugs found when unit testing. 2011-11-02 23:02:23 -05:00
Taylor Otwell
7bf84066bf refactoring. added redis drivers. 2011-10-26 21:21:31 -05:00
Taylor Otwell
32989d39c8 some small refactorings and cleanup. 2011-10-22 23:25:07 -05:00
Taylor Otwell
af36cb3d5a various refactoring and tweaks. 2011-10-20 21:44:18 -05:00
Taylor Otwell
3a08b138b0 changed route __call exception. 2011-10-16 21:35:11 -05:00
Phill Sparks
7f2fd60e9f Fixed route before filter
and throw an Exception for anything falling through __call
2011-10-16 11:46:38 +01:00
Taylor Otwell
4a5e7c6f61 fixed controller routing bug. 2011-10-15 21:43:07 -05:00
Taylor Otwell
a6eaa06981 refactoring routing and comments. 2011-10-15 14:04:11 -05:00
Taylor Otwell
9fa69e0844 refactoring routing and class comments. 2011-10-13 21:32:11 -05:00
Taylor Otwell
6cb79e6676 refactoring 2011-10-10 21:34:15 -05:00
Taylor Otwell
4edcc321aa fixed bug in route to controller delegation. 2011-10-07 12:26:47 -05:00
Taylor Otwell
52b68c060b refactoring. adding back pagination. 2011-10-04 21:43:39 -05:00