moved setup_home to the container
[catagits/Catalyst-Runtime.git] / lib / Catalyst.pm
index da61272..0e01305 100644 (file)
@@ -99,7 +99,7 @@ __PACKAGE__->stats_class('Catalyst::Stats');
 
 # Remember to update this in Catalyst::Runtime as well!
 
-our $VERSION = '5.90014';
+our $VERSION = '5.90015';
 
 sub import {
     my ( $class, @arguments ) = @_;
@@ -131,6 +131,13 @@ sub import {
     }
 
     $caller->arguments( [@arguments] );
+
+    # FIXME
+    # what is this for?
+    # we call setup_home on import AND on ->setup
+    # is there a reason for it?
+    # anyway there is no point for setup_home without setup_config() so...
+    $caller->setup_config;
     $caller->setup_home;
 }
 
@@ -145,6 +152,8 @@ sub MODIFY_CODE_ATTRIBUTES {
 
 sub _application { $_[0] }
 
+=encoding utf8
+
 =head1 NAME
 
 Catalyst - The Elegant MVC Web Application Framework
@@ -1636,7 +1645,7 @@ sub finalize {
             $c->finalize_error;
         }
 
-        $c->finalize_headers;
+        $c->finalize_headers unless $c->response->finalized_headers;
 
         # HEAD request
         if ( $c->request->method eq 'HEAD' ) {
@@ -1746,7 +1755,7 @@ EOF
 
     $c->finalize_cookies;
 
-    $c->engine->finalize_headers( $c, @_ );
+    $c->response->finalize_headers();
 
     # Done
     $response->finalized_headers(1);
@@ -2337,7 +2346,7 @@ sub setup_config {
         $container_class = Class::MOP::load_first_existing_class("${class}::Container", 'Catalyst::IOC::Container');
     }
 
-    my $container = $container_class->new( %args, application_name => "$class", name => "$class" );
+    my $container = $container_class->new( %args, name => $class );
     $class->container($container);
 
     my $config = $container->resolve( service => 'config' );
@@ -2597,18 +2606,19 @@ Sets up the home directory.
 =cut
 
 sub setup_home {
-    my ( $class, $home ) = @_;
-
-    if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) {
-        $home = $env;
-    }
+    my ( $class, $home_flag ) = @_;
 
-    $home ||= Catalyst::Utils::home($class);
+    my $home = $class->container->resolve(
+        service    => 'home',
+        parameters => {
+            home_flag => $home_flag
+        },
+    );
 
     if ($home) {
         #I remember recently being scolded for assigning config values like this
         $class->config->{home} ||= $home;
-        $class->config->{root} ||= Path::Class::Dir->new($home)->subdir('root');
+        $class->config->{root} ||= $class->container->resolve(service => 'root_dir');
     }
 }