Version 5.71001.
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 5294064..5d96074 100644 (file)
@@ -64,7 +64,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
 
 # Remember to update this in Catalyst::Runtime as well!
 
-our $VERSION = '5.71000';
+our $VERSION = '5.71001';
 
 sub import {
     my ( $class, @arguments ) = @_;
@@ -328,9 +328,9 @@ When called with no arguments it escapes the processing chain entirely.
 
 sub detach { my $c = shift; $c->dispatcher->detach( $c, @_ ) }
 
-=head2 $c->visit( $action [, \@arguments ] )
+=head2 $c->visit( $action [, \@captures, \@arguments ] )
 
-=head2 $c->visit( $class, $method, [, \@arguments ] )
+=head2 $c->visit( $class, $method, [, \@captures, \@arguments ] )
 
 Almost the same as C<forward>, but does a full dispatch, instead of just
 calling the new C<$action> / C<$class-E<gt>$method>. This means that C<begin>,
@@ -354,9 +354,9 @@ been reached directly from a URL.
 
 sub visit { my $c = shift; $c->dispatcher->visit( $c, @_ ) }
 
-=head2 $c->go( $action [, \@arguments ] )
+=head2 $c->go( $action [, \@captures, \@arguments ] )
 
-=head2 $c->go( $class, $method, [, \@arguments ] )
+=head2 $c->go( $class, $method, [, \@captures, \@arguments ] )
 
 Almost the same as C<detach>, but does a full dispatch like C<visit>,
 instead of just calling the new C<$action> /
@@ -461,6 +461,7 @@ sub _comp_search_prefixes {
     my ( $c, $name, @prefixes ) = @_;
     my $appclass = ref $c || $c;
     my $filter   = "^${appclass}::(" . join( '|', @prefixes ) . ')::';
+    $filter = qr/$filter/; # Compile regex now rather than once per loop
 
     # map the original component name to the sub part that we will search against
     my %eligible = map { my $n = $_; $n =~ s{^$appclass\::[^:]+::}{}; $_ => $n; }
@@ -488,7 +489,9 @@ sub _comp_search_prefixes {
 
     # don't warn if we didn't find any results, it just might not exist
     if( @result ) {
-        my $msg = "Used regexp fallback for \$c->model('${name}'), which found '" .
+        # Disgusting hack to work out correct method name
+        my $warn_for = lc $prefixes[0];
+        my $msg = "Used regexp fallback for \$c->{$warn_for}('${name}'), which found '" .
            (join '", "', @result) . "'. Relying on regexp fallback behavior for " .
            "component resolution is unreliable and unsafe.";
         my $short = $result[0];
@@ -501,9 +504,9 @@ sub _comp_search_prefixes {
            $msg .= " You probably need to set '$short' instead of '${name}' in this " .
               "component's config";
         } else {
-           $msg .= " You probably meant \$c->model('$short') instead of \$c->model{'${name}'}, " .
+           $msg .= " You probably meant \$c->${warn_for}('$short') instead of \$c->${warn_for}({'${name}'}), " .
               "but if you really wanted to search, pass in a regexp as the argument " .
-              "like so: \$c->model(qr/${name}/)";
+              "like so: \$c->${warn_for}(qr/${name}/)";
         }
         $c->log->warn( "${msg}$shortmess" );
     }
@@ -1022,10 +1025,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<action_for> 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<Catalyst::DispatchType::Chained> actions.
@@ -1057,7 +1068,7 @@ to the URI, with the keys as the names, and the values as the values.
 Returns a L<URI> 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 +1083,11 @@ Returns a L<URI> 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
@@ -1266,7 +1282,7 @@ sub welcome_message {
                     they can save you a lot of work.</p>
                     <pre><code>script/${prefix}_create.pl -help</code></pre>
                     <p>Also, be sure to check out the vast and growing
-                    collection of <a href="http://cpansearch.perl.org/search?query=Catalyst%3A%3APlugin%3A%3A&amp;mode=all">plugins for Catalyst on CPAN</a>;
+                    collection of <a href="http://search.cpan.org/search?query=Catalyst">plugins for Catalyst on CPAN</a>;
                     you are likely to find what you need there.
                     </p>