my $class = shift;
my $config = $class->config->{ setup_components };
+ my $search_extra = $config->{ search_extra };
my @comps = $class->locate_components($config);
my %comps = map { $_ => 1 } @comps;
for my $component (@comps) {
my $instance = $class->components->{ $component } = $class->setup_component($component);
- if ( my ($type, $name) = _get_component_type_name($component) ) {
+ if ( my ($type, $name) = _get_component_type_name($component, $search_extra) ) {
$containers->{$type}->add_service(Catalyst::IOC::BlockInjection->new( name => $name, block => sub { return $instance } ));
}
my @expanded_components = $instance->can('expand_modules')
qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
) if $deprecatedcatalyst_component_names;
- if (my ($type, $name) = _get_component_type_name($component)) {
+ if (my ($type, $name) = _get_component_type_name($component, $search_extra)) {
$containers->{$type}->add_service(Catalyst::IOC::BlockInjection->new( name => $name, block => sub { return $class->setup_component($component) } ));
}
# should it be moved to Catalyst::Utils,
# or replaced by something already existing there?
sub _get_component_type_name {
- my $component = shift;
- my @parts = split /::/, $component;
+ my ( $component, $search_extra) = @_;
+ $search_extra ||= [];
+ my @search_extra = map { s/^:://; lc $_ } @$search_extra;
+
+ my @parts = split /::/, $component;
if (scalar @parts == 1) {
return (undef, $component);
return ('view', join '::', @parts)
if $type =~ /^(v|view)$/i;
+
+ return (_get_component_type($component), join '::', @parts)
+ if @search_extra and ( grep { lc $type eq $_ } @search_extra );
}
}
+sub _get_component_type {
+ my ( $instance ) = @_;
+
+ return 'controller' if $instance->isa('Catalyst::Controller');
+ return 'model' if $instance->isa('Catalyst::Model');
+ return 'view' if $instance->isa('Catalyst::View');
+}
+
=head2 $c->locate_components( $setup_component_config )
This method is meant to provide a list of component modules that should be