use Class::C3::Adopt::NEXT;
use List::MoreUtils qw/uniq/;
use attributes;
+use String::RewritePrefix;
use utf8;
use Carp qw/croak carp shortmess/;
use Try::Tiny;
# Remember to update this in Catalyst::Runtime as well!
-our $VERSION = '5.80024';
+our $VERSION = '5.80025';
sub import {
my ( $class, @arguments ) = @_;
For example:
MyApp->config({ 'Model::Foo' => { bar => 'baz', overrides => 'me' } });
- MyApp::Model::Foo->config({ quux => 'frob', 'overrides => 'this' });
+ MyApp::Model::Foo->config({ quux => 'frob', overrides => 'this' });
will mean that C<MyApp::Model::Foo> receives the following data when
constructed:
overrides => 'me',
});
+It's common practice to use a Moose attribute
+on the receiving component to access the config value.
+
+ package MyApp::Model::Foo;
+
+ use Moose;
+
+ # this attr will receive 'baz' at construction time
+ has 'bar' => (
+ is => 'rw',
+ isa => 'Str',
+ );
+
+You can then get the value 'baz' by calling $c->model('Foo')->bar
+
=cut
around config => sub {
Constructs an absolute L<URI> object based on the application root, the
provided path, and the additional arguments and query parameters provided.
-When used as a string, provides a textual URI.
+When used as a string, provides a textual URI. If you need more flexibility
+than this (i.e. the option to provide relative URIs etc.) see
+L<Catalyst::Plugin::SmartURI>.
If no arguments are provided, the URI for the current action is returned.
To return the current action and also provide @args, use
my $config = $class->config->{ setup_components };
- my @comps = sort { length $a <=> length $b }
- $class->locate_components($config);
+ my @comps = $class->locate_components($config);
my %comps = map { $_ => 1 } @comps;
my $deprecatedcatalyst_component_names = grep { /::[CMV]::/ } @comps;
%$config
);
- my @comps = $locator->plugins;
+ # XXX think about ditching this sort entirely
+ my @comps = sort { length $a <=> length $b } $locator->plugins;
return @comps;
}
unless ($engine) {
$engine = $class->engine_class;
}
- $engine = 'Catalyst::Engine::' . $engine
- unless $engine =~ /^Catalyst::Engine/;
+ else {
+ $engine = String::RewritePrefix->rewrite( { '' => 'Catalyst::Engine::', '+' => '' }, $engine );
+ }
$engine = 'Catalyst::Engine' if $engine eq 'Catalyst::Engine::HTTP';
);
}
+ if ($ENV{MOD_PERL}) {
+ require 'Catalyst/Engine/Loader.pm';
+ my $apache = Catalyst::Engine::Loader->auto;
+ # FIXME - Immutable
+ $class->meta->add_method(handler => sub {
+ my $r = shift;
+ my $app = $class->psgi_app;
+ $apache->call_app($r, $app);
+ });
+ }
+
$class->engine( $engine->new );
$class->psgi_app( $class->engine->build_psgi_app($class) );
+
}
=head2 $c->setup_home
Yuval Kogman, C<nothingmuch@woobling.org>
+rainboxx: Matthias Dietrich, C<perl@rainboxx.de>
+
=head1 LICENSE
This library is free software. You can redistribute it and/or modify it under