X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst.pm;fp=lib%2FCatalyst.pm;h=134f5b63e85d635dc3c3233ed072dc768a1ad69c;hb=0e747f0c25f646d0b9d3157a7082ce9ebee4cdb7;hp=e07166383ea6a14d7a18a73e1c17d7642eaf2747;hpb=d0354b83c4f17ad335d09394a335f86bd77906a1;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst.pm b/lib/Catalyst.pm index e071663..134f5b6 100644 --- a/lib/Catalyst.pm +++ b/lib/Catalyst.pm @@ -595,33 +595,16 @@ If you want to search for models, pass in a regexp as the argument. sub model { my ( $c, $name, @args ) = @_; - my $appclass = ref($c) || $c; - my $container = $c->container->get_sub_container('model'); - - return $c->container->get_component_from_sub_container( 'model', $name, $c, @args) - if( $name ); - if (ref $c) { + if (ref $c && !$name) { return $c->stash->{current_model_instance} - if $c->stash->{current_model_instance}; - return $c->model( $c->stash->{current_model} ) - if $c->stash->{current_model}; - } - return $c->model( $appclass->config->{default_model} ) - if $appclass->config->{default_model}; - -# FIXME: will this still be mantained? - my( $comp, $rest ) = $container->get_service_list; + if $c->stash->{current_model_instance}; - if( $rest ) { - $c->log->warn( Carp::shortmess('Calling $c->model() will return a random model unless you specify one of:') ); - $c->log->warn( '* $c->config(default_model => "the name of the default model to use")' ); - $c->log->warn( '* $c->stash->{current_model} # the name of the model to use for this request' ); - $c->log->warn( '* $c->stash->{current_model_instance} # the instance of the model to use for this request' ); - $c->log->warn( 'NB: in version 5.81, the "random" behavior will not work at all.' ); + $name = $c->stash->{current_model} + if $c->stash->{current_model}; } - return $container->get_component( $comp, $c, @args ); + return $c->container->get_component_from_sub_container( 'model', $name, $c, @args); } @@ -648,32 +631,16 @@ If you want to search for views, pass in a regexp as the argument. sub view { my ( $c, $name, @args ) = @_; - my $appclass = ref($c) || $c; - my $container = $c->container->get_sub_container('view'); - - return $c->container->get_component_from_sub_container( 'view', $name, $c, @args) - if( $name ); - if (ref $c) { + if (ref $c && !$name) { return $c->stash->{current_view_instance} - if $c->stash->{current_view_instance}; - return $c->view( $c->stash->{current_view} ) - if $c->stash->{current_view}; - } - return $c->view( $appclass->config->{default_view} ) - if $appclass->config->{default_view}; - - my( $comp, $rest ) = $container->get_service_list; + if $c->stash->{current_view_instance}; - if( $rest ) { - $c->log->warn( 'Calling $c->view() will return a random view unless you specify one of:' ); - $c->log->warn( '* $c->config(default_view => "the name of the default view to use")' ); - $c->log->warn( '* $c->stash->{current_view} # the name of the view to use for this request' ); - $c->log->warn( '* $c->stash->{current_view_instance} # the instance of the view to use for this request' ); - $c->log->warn( 'NB: in version 5.81, the "random" behavior will not work at all.' ); + $name = $c->stash->{current_view} + if $c->stash->{current_view}; } - return $container->get_component( $comp, $c, @args ); + return $c->container->get_component_from_sub_container( 'view', $name, $c, @args); } =head2 $c->controllers