From: Tomas Doran Date: Mon, 24 Oct 2011 18:27:23 +0000 (-0700) Subject: Make making inner packages in COMPONENT method work again. Horrible! Thanks DBIC... X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=a987f40a116b21ecb196b0c43442499222e27507 Make making inner packages in COMPONENT method work again. Horrible! Thanks DBIC model for that.. --- diff --git a/lib/Catalyst/IOC/Container.pm b/lib/Catalyst/IOC/Container.pm index 6a834ad..8102262 100644 --- a/lib/Catalyst/IOC/Container.pm +++ b/lib/Catalyst/IOC/Container.pm @@ -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( diff --git a/t/aggregate/unit_core_component_loading.t b/t/aggregate/unit_core_component_loading.t index 19a316c..7415a25 100644 --- a/t/aggregate/unit_core_component_loading.t +++ b/t/aggregate/unit_core_component_loading.t @@ -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');