Undoing my commit since the issue had been fixed in Catalyst::Devel 1.08 (#37869)
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 22deaf1..02f1216 100644 (file)
@@ -64,7 +64,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
 
 # Remember to update this in Catalyst::Runtime as well!
 
-our $VERSION = '5.7014';
+our $VERSION = '5.7099_03';
 
 sub import {
     my ( $class, @arguments ) = @_;
@@ -452,10 +452,16 @@ sub _comp_search_prefixes {
 
     # regexp fallback
     $query  = qr/$name/i;
-    @result = grep { $eligible{ $_ } =~ m{$query} } keys %eligible;
+    @result = map { $c->components->{ $_ } } grep { $eligible{ $_ } =~ m{$query} } keys %eligible;
+
+    # no results? try against full names
+    if( !@result ) {
+        @result = map { $c->components->{ $_ } } grep { m{$query} } keys %eligible;
+    }
 
     # don't warn if we didn't find any results, it just might not exist
     if( @result ) {
+        $c->log->warn( qq(Found results for "${name}" using regexp fallback.) );
         $c->log->warn( 'Relying on the regexp fallback behavior for component resolution is unreliable and unsafe.' );
         $c->log->warn( 'If you really want to search, pass in a regexp as the argument.' );
     }
@@ -525,7 +531,7 @@ Gets a L<Catalyst::Model> instance by name.
 Any extra arguments are directly passed to ACCEPT_CONTEXT.
 
 If the name is omitted, it will look for 
- - a model object in $c->stash{current_model_instance}, then
+ - a model object in $c->stash->{current_model_instance}, then
  - a model name in $c->stash->{current_model}, then
  - a config setting 'default_model', or
  - check if there is only one model, and return it if that's the case.
@@ -578,7 +584,7 @@ Gets a L<Catalyst::View> instance by name.
 Any extra arguments are directly passed to ACCEPT_CONTEXT.
 
 If the name is omitted, it will look for 
- - a view object in $c->stash{current_view_instance}, then
+ - a view object in $c->stash->{current_view_instance}, then
  - a view name in $c->stash->{current_view}, then
  - a config setting 'default_view', or
  - check if there is only one view, and return it if that's the case.
@@ -677,11 +683,13 @@ sub component {
 
         if( !ref $name ) {
             # is it the exact name?
-            return $comps->{ $name } if exists $comps->{ $name };
+            return $c->_filter_component( $comps->{ $name }, @args )
+                       if exists $comps->{ $name };
 
             # perhaps we just omitted "MyApp"?
             my $composed = ( ref $c || $c ) . "::${name}";
-            return $comps->{ $composed } if exists $comps->{ $composed };
+            return $c->_filter_component( $comps->{ $composed }, @args )
+                       if exists $comps->{ $composed };
 
             # search all of the models, views and controllers
             my( $comp ) = $c->_comp_search_prefixes( $name, qw/Model M Controller C View V/ );
@@ -692,12 +700,13 @@ sub component {
         my $query = ref $name ? $name : qr{$name}i;
 
         my @result = grep { m{$query} } keys %{ $c->components };
-        return @result if ref $name;
+        return map { $c->_filter_component( $_, @args ) } @result if ref $name;
 
         if( $result[ 0 ] ) {
+            $c->log->warn( qq(Found results for "${name}" using regexp fallback.) );
             $c->log->warn( 'Relying on the regexp fallback behavior for component resolution' );
             $c->log->warn( 'is unreliable and unsafe. You have been warned' );
-            return $result[ 0 ];
+            return $c->_filter_component( $result[ 0 ], @args );
         }
 
         # I would expect to return an empty list here, but that breaks back-compat
@@ -1906,6 +1915,11 @@ search paths, specify a key named C<search_extra> as an array
 reference. Items in the array beginning with C<::> will have the
 application class name prepended to them.
 
+All components found will also have any 
+L<Devel::InnerPackage|inner packages> loaded and set up as components.
+Note, that modules which are B<not> an I<inner package> of the main
+file namespace loaded will not be instantiated as components.
+
 =cut
 
 sub setup_components {
@@ -2411,13 +2425,15 @@ Wiki:
 
 =head2 L<Catalyst::Test> - The test suite.
 
-=head1 CREDITS
+=head1 PROJECT FOUNDER
 
-Andy Grundman
+sri: Sebastian Riedel <sri@cpan.org>
 
-Andy Wardley
+=head1 CONTRIBUTORS
 
-Andreas Marienborg
+abw: Andy Wardley
+
+acme: Leon Brocard <leon@astray.com>
 
 Andrew Bramble
 
@@ -2425,65 +2441,67 @@ Andrew Ford
 
 Andrew Ruthven
 
-Arthur Bergman
-
-Autrijus Tang
+andyg: Andy Grundman <andy@hybridized.org>
 
-Brian Cassidy
+audreyt: Audrey Tang
 
-Carl Franks
+bricas: Brian Cassidy <bricas@cpan.org>
 
-Christian Hansen
+chansen: Christian Hansen
 
-Christopher Hicks
+chicks: Christopher Hicks
 
-Dan Sully
+dkubb: Dan Kubb <dan.kubb-cpan@onautopilot.com>
 
-Danijel Milicevic
+Drew Taylor
 
-David Kamholz
+esskar: Sascha Kiefer
 
-David Naughton
+fireartist: Carl Franks <cfranks@cpan.org>
 
-Drew Taylor
+gabb: Danijel Milicevic
 
 Gary Ashton Jones
 
 Geoff Richards
 
-Jesse Sheidlower
-
-Jesse Vincent
+jcamacho: Juan Camacho
 
 Jody Belka
 
 Johan Lindstrom
 
-Juan Camacho
+jon: Jon Schutz <jjschutz@cpan.org>
 
-Leon Brocard
+marcus: Marcus Ramberg <mramberg@cpan.org>
 
-Marcus Ramberg
+miyagawa: Tatsuhiko Miyagawa <miyagawa@bulknews.net>
 
-Matt S Trout
+mst: Matt S. Trout <mst@shadowcatsystems.co.uk>
 
-Robert Sedlacek
+mugwump: Sam Vilain
 
-Sam Vilain
+naughton: David Naughton
 
-Sascha Kiefer
+ningu: David Kamholz <dkamholz@cpan.org>
 
-Sebastian Willert
+nothingmuch: Yuval Kogman <nothingmuch@woobling.org>
 
-Tatsuhiko Miyagawa
+numa: Dan Sully <daniel@cpan.org>
 
-Ulf Edvinsson
+obra: Jesse Vincent
+
+omega: Andreas Marienborg
 
-Yuval Kogman
+phaylon: Robert Sedlacek <phaylon@dunkelheit.at>
 
-=head1 AUTHOR
+sky: Arthur Bergman
+
+the_jester: Jesse Sheidlower
+
+Ulf Edvinsson
 
-Sebastian Riedel, C<sri@oook.de>
+willert: Sebastian Willert <willert@cpan.org>
 
 =head1 LICENSE