get the components from their services in the sub-containers, not from $c->components
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 3dad0df..5a66003 100644 (file)
@@ -548,9 +548,11 @@ sub _comp_names_search_prefixes {
     my $filter   = "^${appclass}::(" . join( '|', @prefixes ) . ')::';
     $filter = qr/$filter/; # Compile regex now rather than once per loop
 
+    my @components = map { $c->container->get_sub_container($_)->get_service_list } $c->container->get_sub_container_list; 
+
     # map the original component name to the sub part that we will search against
     my %eligible = map { my $n = $_; $n =~ s{^$appclass\::[^:]+::}{}; $_ => $n; }
-        grep { /$filter/ } keys %{ $c->components };
+        grep { /$filter/ } @components; 
 
     # undef for a name will return all
     return keys %eligible if !defined $name;
@@ -2484,12 +2486,30 @@ sub setup_components {
     for my $component (@comps) {
         my $instance = $class->components->{ $component } = $class->setup_component($component);
         my $type = lc((split /::/, $component)[1]);
+        if ($deprecatedcatalyst_component_names) {
+            $type = 'controller' if $type eq 'c';
+            $type = 'model' if $type eq 'm';
+            $type = 'view' if $type eq 'v';
+        }
         $containers->{$type}->add_service(Bread::Board::BlockInjection->new( name => $component, block => sub { return $instance } ));
         my @expanded_components = $instance->can('expand_modules')
             ? $instance->expand_modules( $component, $config )
             : $class->expand_component_module( $component, $config );
         for my $component (@expanded_components) {
             next if $comps{$component};
+
+            $deprecatedcatalyst_component_names = grep { /::[CMV]::/ } @expanded_components;
+            $class->log->warn(qq{Your application is using the deprecated ::[MVC]:: type naming scheme.\n}.
+                qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
+            ) if $deprecatedcatalyst_component_names;
+
+            if ($deprecatedcatalyst_component_names) {
+                $type = lc((split /::/, $component)[1]);
+                $type = 'controller' if $type eq 'c';
+                $type = 'model' if $type eq 'm';
+                $type = 'view' if $type eq 'v';
+            }
+            $containers->{$type}->add_service(Bread::Board::BlockInjection->new( name => $component, block => sub { return $class->setup_component($component) } ));
             $class->components->{ $component } = $class->setup_component($component);
         }
     }