From: Kennedy Clark Date: Wed, 25 Feb 2009 20:43:49 +0000 (+0000) Subject: Apply doc patch from Genius_Spot X-Git-Tag: 5.71001~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=28f21b21ae1cca1ec8c5b098a8cedcc37756ba5a Apply doc patch from Genius_Spot --- diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index f2688c9..8b8cb3f 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -1022,10 +1022,18 @@ EOF =item $action A Catalyst::Action object representing the Catalyst action you want to -create a URI for. To get one for an action in the current controller, -use C<< $c->action('someactionname') >>. To get one from different -controller, fetch the controller using C<< $c->controller() >>, then -call C on it. +create a URI for. + +To get an action object: + + From another controller, anywhere: + C<< $c->controller('ControllerName')->action_for('someactionname') >> + Shorter styles useful in particular places: + In the current controller's action method: + C<< $self->action_for('someactionname') >> + From the view for currently dispatched action: + C<< $c->controller->action_for('someactionname') >> + This method must be used to create URIs for L actions. @@ -1057,7 +1065,7 @@ to the URI, with the keys as the names, and the values as the values. Returns a L object. ## Ex 1: a path with args and a query parameter - $c->uri_for('user/list', 'short', { page => 2}); + $c->uri_for($c->controller('User')->action_for('list'), 'short', { page => 2}); ## -> ($c->req->base is 'http://localhost:3000/' URI->new('http://localhost:3000/user/list/short?page=2) @@ -1072,6 +1080,11 @@ Returns a L object. ## outputs: URI->new('http://localhost:3000/myuser/42/view') + ## Ex 3: this style is deprecated and should be omitted + $c->uri_for('user/list', 'short', { page => 2}); + ## -> ($c->req->base is 'http://localhost:3000/' + URI->new('http://localhost:3000/user/list/short?page=2) + Creates a URI object using C<< $c->request->base >> and a path. If an Action object is given instead of a path, the path is constructed using C<< $c->dispatcher->uri_for_action >> and passing it the