Make making inner packages in COMPONENT method work again. Horrible! Thanks DBIC...
Tomas Doran [Mon, 24 Oct 2011 18:27:23 +0000 (11:27 -0700)]
lib/Catalyst/IOC/Container.pm
t/aggregate/unit_core_component_loading.t

index 6a834ad..8102262 100644 (file)
@@ -683,8 +683,15 @@ sub add_component {
             dependencies => [
                 depends_on( '/application_name' ),
             ],
-        )
+        ),
     );
+    # XXX - FIXME - We have to explicitly build the service here,
+    #               causing the COMPONENT method to be called early here, as otherwise
+    #               if the component method defines other classes (e.g. the
+    #               ACCEPT_CONTEXT injection Model::DBIC::Schema does)
+    #               then they won't be found by Devel::InnerPackage
+    # see also t/aggregate/unit_core_component_loading.t
+    $instance_container->get_service($component_service_name)->get;
 
     $accept_context_container->add_service(
         Catalyst::IOC::BlockInjection->new(
index 19a316c..7415a25 100644 (file)
@@ -238,7 +238,11 @@ eval "package $appclass; use Catalyst; __PACKAGE__->setup";
 is($@, '', "Didn't load component twice");
 is($appclass->model('TopLevel::Nested')->called,1, 'COMPONENT called once');
 
-# FIXME - OMG why should this even work?!!
+# FIXME we need a much better way of components being able to generate
+#       sub-components of themselves (e.g. bring back expand_component_modules?)
+#       as otherwise we _have_ to construct / call the COMPONENT method
+#       explicitly to get all the sub-components built for Devel::InnerPackage
+#       to find them. See FIXME in Catalyst::IOC::Container
 ok($appclass->model('TopLevel::GENERATED'), 'Have generated model');
 is(ref($appclass->model('TopLevel::GENERATED')), 'FooBarBazQuux',
     'ACCEPT_CONTEXT in generated inner package fired as expected');