in general any request or response trait on CPAN that used 'CatalystX::RoleApplicator'
should now just work with this core feature. Note that can also set thse roles
via new configuration keys, 'request_class_traits', 'response_class_traits'
- and 'stats_class_traits'. If you use both config at application class methods, they
- are combined.
+ and 'stats_class_traits'. If you use both configuration and application class methods,
+ they are combined.
- NEW FEATURE: Core concepts from 'CatalystX::ComponentsFromConfig'. You can now
setup components directly from configuration. This could save you some effort and
creating 'empty' base classes in your Model/View and Controller directories. This
C<< $c->go >> will perform a full dispatch on the specified action or method,
with localized C<< $c->action >> and C<< $c->namespace >>. Like C<detach>,
C<go> escapes the processing of the current request chain on completion, and
-does not return to its caller.
+does not return to its cunless blessed $cunless blessed $caller.
@arguments are arguments to the final destination of $action. @captures are
arguments to the intermediate steps, if any, on the way to the final sub of
sub stash {
my $c = shift;
+ $c->log->error("You are requesting the stash but you don't have a context") unless blessed $c;
return Catalyst::Middleware::Stash::get_stash($c->req->env)->(@_);
}
# die "Circular Dependencies Detected." if $tracker{$comp};
# $tracker{$comp}++;
if(ref $comp eq 'CODE') {
- $comp = $comp->($c);
+ $comp = $comp->();
}
#$tracker{$comp}++;
if ( eval { $comp->can('ACCEPT_CONTEXT'); } ) {
+ die "Component '${\$comp->catalyst_component_name}' does ACCEPT_CONTEXT but I am in application scope" unless blessed $c;
return $comp->ACCEPT_CONTEXT( $c, @args );
}
}
# All components are registered, now we need to 'init' them.
- foreach my $component_name (keys %{$class->components||{}}) {
+ foreach my $component_name (@comps, @injected_components) {
$class->components->{$component_name} = $class->components->{$component_name}->() if
- (ref($class->components->{$component_name}) || '') eq 'CODE';
+ (ref($class->components->{$component_name}) || '') eq 'CODE';
}
}
$self->_load_dispatch_types( @{ $self->preload_dispatch_types } );
@{ $self->_registered_dispatch_types }{@classes} = (1) x @classes;
- foreach my $comp_key ( keys %{ $c->components } ) {
- my $comp = $c->component($comp_key);
+ foreach my $comp ( values %{ $c->components } ) {
+ $comp = $comp->() if ref($comp) eq 'CODE';
$comp->register_actions($c) if $comp->can('register_actions');
}
--- /dev/null
+use Test::Most;
+
+{
+ package MyApp::Model::AcceptContext;
+ use base 'Catalyst::Model';
+
+ sub ACCEPT_CONTEXT {
+ my ($self, $c, @args) = @_;
+ Test::Most::ok( ref $c);
+ }
+
+ $INC{'MyApp/Model/AcceptContext.pm'} = __FILE__;
+
+ package MyApp::Controller::Root;
+ use base 'Catalyst::Controller';
+
+ sub test_model :Local {
+ my ($self, $c) = @_;
+ $c->res->body('test');
+ }
+
+ $INC{'MyApp/Controller/Root.pm'} = __FILE__;
+
+ package MyApp;
+ use Catalyst;
+
+ MyApp->setup;
+}
+
+use Catalyst::Test 'MyApp';
+
+my ($res, $c) = ctx_request('/test_model');
+
+ok $res;
+
+use Devel::Dwarn;
+#Dwarn $c->model('AcceptContext');
+
+done_testing;
+