# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.90014';
+our $VERSION = '5.90015';
sub import {
my ( $class, @arguments ) = @_;
}
$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->arguments);
$caller->setup_home;
}
sub _application { $_[0] }
+=encoding utf8
+
=head1 NAME
Catalyst - The Elegant MVC Web Application Framework
@arguments = ( @arguments, @{ $class->arguments } );
}
- # Process options
- my $flags = {};
-
- foreach (@arguments) {
-
- if (/^-Debug$/) {
- $flags->{log} =
- ( $flags->{log} ) ? 'debug,' . $flags->{log} : 'debug';
- }
- elsif (/^-(\w+)=?(.*)$/) {
- $flags->{ lc $1 } = $2;
- }
- else {
- push @{ $flags->{plugins} }, $_;
- }
- }
-
- $class->setup_config();
- $class->setup_home( delete $flags->{home} );
+ $class->setup_config(\@arguments);
+ my $flags = $class->container->resolve(service => 'flags');
+ $class->setup_home();
$class->setup_log( delete $flags->{log} );
$class->setup_plugins( delete $flags->{plugins} );
$c->finalize_error;
}
- $c->finalize_headers;
+ $c->finalize_headers unless $c->response->finalized_headers;
# HEAD request
if ( $c->request->method eq 'HEAD' ) {
$c->finalize_cookies;
- $c->engine->finalize_headers( $c, @_ );
+ $c->response->finalize_headers();
# Done
$response->finalized_headers(1);
=cut
sub setup_config {
- my $class = shift;
+ my ($class, $flags) = @_;
my %args = %{ $class->config || {} };
$container_class = Class::MOP::load_first_existing_class("${class}::Container", 'Catalyst::IOC::Container');
}
- my $container = $container_class->new( %args, name => $class );
+ my $container = $container_class->new( %args, name => $class, flags => $flags );
$class->container($container);
my $config = $container->resolve( service => 'config' );
=cut
sub setup_home {
- my ( $class, $home ) = @_;
+ my ( $class ) = @_;
- if ( my $env = Catalyst::Utils::env_value( $class, 'HOME' ) ) {
- $home = $env;
- }
-
- $home ||= Catalyst::Utils::home($class);
+ my $home = $class->container->resolve(
+ service => 'home',
+ );
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');
}
}