class level config merged with container's config
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index 30e3854..65bc1dc 100644 (file)
@@ -1031,11 +1031,11 @@ EOF
 
     if (
         $class->debug and
-        my @comps_types = $class->container->get_components_types
+        my @comps_names_types = $class->container->get_components_names_types
     ) {
         my $column_width = Catalyst::Utils::term_width() - 8 - 9;
         my $t = Text::SimpleTable->new( [ $column_width, 'Class' ], [ 8, 'Type' ] );
-        $t->row( @$_ ) for @comps_types;
+        $t->row( @$_ ) for @comps_names_types;
 
         $class->log->debug( "Loaded components:\n" . $t->draw . "\n" );
     }
@@ -1446,9 +1446,7 @@ sub components {
     my $container = $class->container;
 
     if ( $comps ) {
-        $container->add_component(
-            $_, $class
-        ) for keys %$comps;
+        $container->add_component( $_ ) for keys %$comps;
     }
 
     return $container->get_all_components();
@@ -2283,17 +2281,17 @@ sub setup_actions { my $c = shift; $c->dispatcher->setup_actions( $c, @_ ) }
 sub setup_config {
     my $class = shift;
 
-    my %args = %{ $class->config || {} };
+    my $args = $class->config || {};
 
     my @container_classes = ( "${class}::Container", 'Catalyst::IOC::Container');
-    unshift @container_classes, delete $args{container_class} if exists $args{container_class};
+    unshift @container_classes, delete $args->{container_class} if exists $args->{container_class};
 
     my $container_class = Class::MOP::load_first_existing_class(@container_classes);
 
-    my $container = $container_class->new( %args, application_name => "$class", name => "$class" );
+    my $container = $container_class->new( application_name => "$class", name => "$class" );
     $class->container($container);
 
-    my $config = $container->resolve(service => 'config');
+    my $config = $container->resolve( service => 'config' );
     $class->config($config);
     $class->finalize_config; # back-compat
 }
@@ -2317,13 +2315,30 @@ The C<setup_components> config option is passed to both of the above methods.
 =cut
 
 sub setup_components {
-    shift->container->resolve( service => 'setup_components' );
+    shift->container->setup_components();
 }
 
+=head2 locate_components
+
+=cut
+
 # FIXME - removed locate_components
 # don't people mess with this method directly?
 # what to do with that?
 
+sub locate_components {
+    my $class = shift;
+
+    $class->log->warn('The locate_components method has been deprecated.');
+    $class->log->warn('Please read Catalyst::IOC::Container documentation to');
+    $class->log->warn('update your application.');
+
+    # XXX think about ditching this sort entirely
+    return sort { length $a <=> length $b }
+        @{ $class->container->resolve( service => 'locate_components' ) };
+}
+
+
 =head2 $c->setup_dispatcher
 
 Sets up dispatcher.