added a warning to ->components(), and changed tests which called it to be after...
André Walker [Fri, 20 Jul 2012 04:29:37 +0000 (01:29 -0300)]
lib/Catalyst.pm
t/aggregate/unit_core_component_setup_components.t
t/aggregate/unit_core_mvc.t

index f9ebe51..46fc522 100644 (file)
@@ -1458,12 +1458,18 @@ Returns a hash of components.
 sub components {
     my ( $class, $comps ) = @_;
 
+    # FIXME
+    # this is very wrong
     # people create components calling this sub directly, before setup
+    # also, $class->log doesn't work before setup_log
     $class->setup_config unless $class->container;
 
     my $container = $class->container;
 
     if ( $comps ) {
+        $class->log->warn(q{You are adding components using Catalyst's components method.});
+        $class->log->warn(q{This behaviour is deprecated, please read});
+        $class->log->warn(q{Catalyst::IOC::Container's documentation for better ways to do that.});
         $container->add_component( $_ ) for keys %$comps;
     }
 
index ffbbb99..fd40127 100644 (file)
@@ -10,14 +10,14 @@ Moose::Meta::Class->create( TestAppComponents => (
     },
 ));
 
-TestAppComponents->components( {} );
-
 # this is so TestAppComponents->container will work
 TestAppComponents->setup_config;
 
 # this is so TestAppComponents->log->warn will work
 TestAppComponents->setup_log;
 
+TestAppComponents->components( {} );
+
 my @comps = TestAppComponents->locate_components;
 
 for my $component (@comps) {
index 390c4c6..ea2d916 100644 (file)
@@ -294,11 +294,11 @@ is( MyMVCTestAppDefaultModel->model , 'MyMVCTestAppDefaultModel::Model::M', 'def
 
     __PACKAGE__->config( { disable_component_resolution_regex_fallback => 1 } );
 
-    __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) }
-        qw/MyApp::WithoutRegexFallback::Controller::Another::Foo/ } );
-
     # allow $c->log->warn to work
     __PACKAGE__->setup_log;
+
+    __PACKAGE__->components( { map { ( ref($_)||$_ , $_ ) }
+        qw/MyApp::WithoutRegexFallback::Controller::Another::Foo/ } );
 }
 
 {