X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FManual%2FIntro.pod;h=6ba61e38a9e872f1220be7bd64863607cf1a21fd;hb=a74c2d1a1e12c43e5dbb4caef23f7cc25e57bd1f;hp=910c4c0d1409da4273976f47a34f59f1b1bad3fb;hpb=e76c67cbd171d25797fc03a72118dfa0b7fad6cd;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Manual/Intro.pod b/lib/Catalyst/Manual/Intro.pod index 910c4c0..6ba61e3 100644 --- a/lib/Catalyst/Manual/Intro.pod +++ b/lib/Catalyst/Manual/Intro.pod @@ -349,12 +349,8 @@ this: } 1; - =back -For most applications, Catalyst requires you to define only one config -parameter: - =head4 Action types Catalyst supports several types of actions: @@ -421,54 +417,6 @@ C<$c-Ereq-Ecaptures-E[0]> would be "23". If you want to pass arguments at the end of your URL, you must use regex action keys. See L below. -=item * B - - sub section :PathPart('section') :ChildOf('/') :Captures(1) { } - -ChildOf is a powerful way to handle canonical URIs of the form -/section/1/item/2 - -Taking the above URI as an example in Controller::Root you can do the following :- - - sub section_handler :PathPart('section') :ChildOf('/') :Captures(1) { - my ( $self, $c ) = @_; - $c->stash->{'section'} = $c->Model('Sections')->find($c->req->captures->[0]); - } - - sub item_handler :PathPart('item') :ChildOf('/section_handler') :Args(1) { - my ( $self, $c ) = @_; - $c->stash->{'item'} = $c->stash->{'section'}->find_related('item',$c->args->[0]); - } - -The subroutine section_handler matched the path segment 'section' as a child of '/'. It -then took the next path segment, as referenced by :Captures(1) and stashed it in the -arrayref $c->req->captures. Since there was also a child of this handler - it also gets run. -The same rules apply here - This time however it has the 'Args' attribute which means -this particular routine will run if there is exactly 1 argument. See Args below for more -options. - -=item ChildOf('xyz') - -The action of the parent - for instance, if you have method item_handler in controller -SuperMarket::Aisle, the action would be /supermarket/aisle/item_handler. For a root handler -this would be '/'. - -=item PathPart('xyz') - -The name of this path section in the ChildOf tree mapping to the URI. - -=item Captures(int) - -Will 'collapse' the next x path segments in the request URI and push them into -the arrayref $c->req->captures - -=item Args(int) - -The number of path segments to capture at the end of a request URI. This *must* be -included in your leaf nodes. You can use Args(0) for an equivalent of the index -action. -Args with no parameters will capture every postfixed segment into $c->req->args. - =item * B (B) package MyApp::Controller::Foo; @@ -496,6 +444,24 @@ Catalyst ("MyApp::Controller" in the above example), replaces "::" with explanation of the pre-defined meaning of Catalyst component class names. +=item * B + +Catalyst also provides a method to build and dispatch chains of actions, +like + + sub foo : Chained : CaptureArgs(1) { + my ( $self, $c, $arg ) = @_; + ... + } + + sub bar : Chained('foo') : Args(1) { + my ( $self, $c, $arg ) = @_; + ... + } + +to handle a C path. For more information about this dispatch +type, please read L. + =item * B sub foo : Private { } @@ -528,10 +494,6 @@ would match any URL starting /foo/bar/. To restrict this you can do to only match /foo/bar/*/ -=item * B, B and B - -Matt is an idiot and hasn't documented this yet. - =back B After seeing these examples, you probably wonder what the point @@ -869,7 +831,8 @@ C<$c-Eforward(qw/MyApp::View::TT process/)>. } You normally render templates at the end of a request, so it's a perfect -use for the global C action. +use for the global C action. (In practice, however, you would use a +default C action as supplied by L.) Also, be sure to put the template under the directory specified in C<$c-Econfig-E{root}>, or you'll be forced to look at our