Commit Graph

164 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
Taylor Otwell
0a908eff8d Merge pull request #1014 from jasonlewis/feature/root-bundles
Allow bundles to respond to root requests.
2012-09-01 17:26:35 -07:00
Taylor Otwell
feb651f630 Merge pull request #670 from kbanman/hmvc-fix
Add support for non-string parameters in controller routes
2012-08-13 12:13:58 -07:00
Sergii Grebeniuk
690e8572aa phpdoc fixes 2012-08-03 18:17:48 +03:00
Jason Lewis
f408fcc26b Allow bundles to respond to root requests.
Signed-off-by: Jason Lewis <jason.lewis1991@gmail.com>
2012-07-27 12:30:41 +09:30
Chris Berthe
b325e954e3 Merge remote-tracking branch 'upstream/develop' into develop 2012-07-12 11:15:43 -04:00
Taylor Otwell
990f10f6de Merge pull request #854 from jasonlewis/feature/pattern-filters
Allow filter patterns to supply a name and callback as an easier alternative.
2012-07-06 17:57:46 -07:00
Chris Berthe
3b6191ec16 Merge remote-tracking branch 'upstream/develop' into develop 2012-07-01 12:33:03 -04:00
Taylor Otwell
1f93039ba7 Merge pull request #873 from dlpetrie/master
Adding support for '=', in (:any) and (:any?) route patterns
2012-06-27 20:39:59 -07:00
Daniel Petrie
f640cd42ad adding in '=' to regex for (:any) / (:any?) calls. 2012-06-27 11:15:34 -07: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
Phill Sparks
6151886860 Generated URLs default to use the current protocol (http or https)
Signed-off-by: Phill Sparks <phill@bulbstudios.com>
2012-05-30 13:14:16 +01:00
Kelly Banman
1b2ab309c4 Add support for non-string parameters in controller routes
Signed-off-by: Kelly Banman <kelly.banman@gmail.com>
2012-05-11 22:32:19 -07:00
Taylor Otwell
af9f875ee3 Remote unneeded properties. 2012-05-10 11:37:30 -05:00
Taylor Otwell
21a51b7cf9 Add controller and controller_action to route. 2012-05-10 08:44:43 -05:00
Taylor Otwell
641f1d4c14 Merge pull request #615 from awellis13/feature/route-cleanup
Laravel\Route PHPDoc cleanup and removed $uri from Route::parameters().
2012-05-10 06:35:54 -07:00
Taylor Otwell
01894ae4ee Merge pull request #651 from dlpetrie/patch-4
Controller property Bundle ( and some additions )
2012-05-10 06:34:18 -07:00
Daniel Petrie
8a8d331981 Update laravel/routing/controller.php 2012-05-09 17:14:01 -07:00
Daniel Petrie
b6cbac56c8 bundle property wasn't being used, so I made use of it as well as adding the controllers name and action being called. 2012-05-09 17:06:04 -07:00
Andrew Ellis
fdad58383b cleaned up phpdoc and removed as it is not used 2012-05-03 11:14:33 -06:00
Taylor Otwell
4f036cf7dd add spacing to router. 2012-05-03 08:36:32 -05:00
Taylor Otwell
9ca81296d8 Merge pull request #589 from whitman/numeric-routes
Automatically wrap numeric routes in parentheses
2012-05-03 06:36:08 -07:00
Alex Whitman
14961350d0 Automatically wrap numeric routes in parentheses 2012-04-26 16:32:02 +01:00
Taylor Otwell
09e456d2bf fix docblock. 2012-04-19 08:41:23 -05:00
Taylor Otwell
51f5fdd0c9 fix conflicts. 2012-04-18 20:38:36 -05:00
Pavel
482aed9379 Corrected typos in the comments.
Signed-off-by: Pavel <proger.xp@gmail.com>
2012-04-16 18:44:11 +04: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
b65380d6ff Added automatic controller detection.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-03-12 17:03:09 -05:00
Taylor Otwell
8da1c16c8b Tweak controller layout resolution.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-03-05 13:31:30 -06: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
Taylor Otwell
01ddff5cdc adding support for filter patterns.
Signed-off-by: Taylor Otwell <taylorotwell@gmail.com>
2012-02-27 22:36:28 -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
e69f988fe5 improving some comments. 2012-02-23 09:09:56 -06:00
Taylor Otwell
d29a127948 allow multiple request methods for uri. 2012-02-23 09:09:00 -06:00
Taylor Otwell
f624a6849f fix handling of HEAD http requests. 2012-02-23 08:43:55 -06:00
Taylor Otwell
e70261e962 added support for controller factories. 2012-02-22 15:09:04 -06:00
Taylor Otwell
2f66c97806 changes 2012-02-18 13:37:02 -06: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
b353afdc79 fixing router bugs. 2012-02-12 20:09:27 -06:00
Taylor Otwell
74887986a7 fixing bugs in router. 2012-02-12 19:26:16 -06:00
Taylor Otwell
775b97ee76 load controller file before checking in ioc container. 2012-02-12 19:15:13 -06:00
Taylor Otwell
3d1a44028a added route::share method. 2012-02-12 16:41:03 -06:00
Taylor Otwell
ae544b85da fix bug in router::route method. 2012-02-12 15:39:53 -06:00
Taylor Otwell
597feed4a7 fix bug with root routing. 2012-02-12 15:23:20 -06:00