my ( $c, $name, @args ) = @_;
if (ref $c && !$name) {
+ my $current_instance = $c->stash->{current_model_instance};
return $current_instance
- if my $current_instance = $c->stash->{current_model_instance};
+ if $current_instance;
$name = $c->stash->{current_model};
}
my ( $c, $name, @args ) = @_;
if (ref $c && !$name) {
+ my $current_instance = $c->stash->{current_view_instance};
return $current_instance
- if my $current_instance = $c->stash->{current_view_instance};
+ if $current_instance;
$name = $c->stash->{current_view};
}
my $container = $class->container;
if ( $comps ) {
- $container->add_component(
- $_, $class
- ) for keys %$comps;
+ $container->add_component( $_ ) for keys %$comps;
}
return $container->get_all_components();
my $container_class = Class::MOP::load_first_existing_class(@container_classes);
- my $container = $container_class->new( %args, name => "$class" );
+ my $container = $container_class->new( %args, application_name => "$class", name => "$class" );
$class->container($container);
my $config = $container->resolve(service => 'config');
=cut
sub setup_components {
- my $class = shift;
- # FIXME - I believe I shouldn't be handing $class over
- # Just don't know how to solve this.
- return $class->container->setup_components( $class );
+ shift->container->setup_components();
}
+=head2 locate_components
+
+=cut
+
# FIXME - removed locate_components
# don't people mess with this method directly?
# what to do with that?
+sub locate_components {
+ my $class = shift;
+
+ $class->log->warn('The locate_components method has been deprecated.');
+ $class->log->warn('Please read Catalyst::IOC::Container documentation to');
+ $class->log->warn('update your application.');
+
+ # XXX think about ditching this sort entirely
+ return sort { length $a <=> length $b }
+ @{ $class->container->resolve( service => 'locate_components' ) };
+}
+
+
=head2 $c->setup_dispatcher
Sets up dispatcher.