my @result = $c->container->find_component( $component, $c, @args );
+ # one last search for things like $c->comp(qr/::M::/)
+ @result = $c->container->find_component_regexp(
+ $c->components, $component, $c, @args
+ ) if !@result and ref $component;
+
# list context for regexp searches
return @result if ref $component;
return @result;
}
+sub find_component_regexp {
+ my ( $self, $components, $component, @args ) = @_;
+ my @result;
+
+ my @components = grep { m{$component} } keys %{ $components };
+
+ for (@components) {
+ # FIXME this is naughty enough being called inside Catalyst.pm
+ # find some alternative for this sub and remember to delete here
+ my ($type, $name) = Catalyst::_get_component_type_name($_);
+
+ push @result, $self->get_component_from_sub_container(
+ $type, $name, @args
+ ) if $type;
+ }
+
+ return @result;
+}
+
1;
=head2 find_component
+=head2 find_component_regexp
+
=head2 _fix_syntax
=head2 _config_substitutions
# multiple returns
{
-# FIXME: this cannot be found by looking only in the container.
-# either the test must be changed, or the regexp must be run against
-# $c->components() in Catalyst.pm
- diag('this test will not work by searching the container');
- diag('check the source of this file for more info');
my @expected = sort qw( MyApp::C::Controller MyApp::M::Model );
my @got = sort MyApp->comp( qr{::[MC]::} );
is_deeply( \@got, \@expected, 'multiple results from regexp ok' );