broke expand_modules, setup_component became a method
André Walker [Mon, 25 Jul 2011 23:04:22 +0000 (20:04 -0300)]
lib/Catalyst.pm
lib/Catalyst/IOC/Container.pm

index b03920f..a19de10 100644 (file)
@@ -2349,10 +2349,9 @@ sub setup_components {
     my $container = $class->container;
 
     for my $component (@comps) {
-        my $instance = $container->add_component( $component, $class );
-        my @expanded_components = $instance->can('expand_modules')
-            ? $instance->expand_modules( $component, $config )
-            : $class->expand_component_module( $component, $config );
+        $container->add_component( $component, $class );
+# FIXME - $instance->expand_modules() is broken
+        my @expanded_components = $class->expand_component_module( $component, $config );
         for my $component (@expanded_components) {
             next if $comps{$component};
 
index 941516d..bfd1004 100644 (file)
@@ -526,16 +526,12 @@ sub add_component {
 
     return unless $type;
 
-    my $instance = setup_component( $component, $class );
-
     $self->get_sub_container($type)->add_service(
         Catalyst::IOC::BlockInjection->new(
             name  => $name,
-            block => sub { $instance },
+            block => sub { $self->setup_component( $component, $class ) },
         )
     );
-
-    return $instance;
 }
 
 # FIXME: should this sub exist?
@@ -563,7 +559,7 @@ sub _get_component_type_name {
 # FIXME ugly and temporary
 # Just moved it here the way it was, so we can work on it here in the container
 sub setup_component {
-    my ( $component, $class ) = @_;
+    my ( $self, $component, $class ) = @_;
 
     unless ( $component->can( 'COMPONENT' ) ) {
         return $component;
@@ -572,7 +568,7 @@ sub setup_component {
     # FIXME I know this isn't the "Dependency Injection" way of doing things,
     # its just temporary
     my $suffix = Catalyst::Utils::class2classsuffix( $component );
-    my $config = $class->config->{ $suffix } || {};
+    my $config = $self->resolve(service => 'config')->{ $suffix } || {};
 
     # Stash catalyst_component_name in the config here, so that custom COMPONENT
     # methods also pass it. local to avoid pointlessly shitting in config