expand_component_module (rjbs)
- Allow Components to return anon classed from their COMPONENT method
correctly, and have action registration work on Controllers returned
- as such by adding a _component_name accessor for all components
+ as such by adding a catalyst_component_name accessor for all components
which returns the component instance's name to be used when building
actions etc.
- Adding X-Forwarded-Port to allow the frontend proxy to dictate the
my @comps = sort { length $a <=> length $b }
$class->locate_components($config);
- my $deprecated_component_names = grep { /::[CMV]::/ } @comps;
+ my $deprecatedcatalyst_component_names = grep { /::[CMV]::/ } @comps;
$class->log->warn(qq{Your application is using the deprecated ::[MVC]:: type naming scheme.\n}.
qq{Please switch your class names to ::Model::, ::View:: and ::Controller: as appropriate.\n}
- ) if $deprecated_component_names;
+ ) if $deprecatedcatalyst_component_names;
for my $component ( @comps ) {
my $suffix = Catalyst::Utils::class2classsuffix( $component );
my $config = $class->config->{ $suffix } || {};
- # Stash _component_name in the config here, so that custom COMPONENT
+ # Stash catalyst_component_name in the config here, so that custom COMPONENT
# methods also pass it. local to avoid pointlessly shitting in config
# for the debug screen, as $component is already the key name.
- local $config->{_component_name} = $component;
+ local $config->{catalyst_component_name} = $component;
my $instance = eval { $component->COMPONENT( $class, $config ); };
=head2 class
Returns the name of the component where this action is defined.
-Derived by calling the L<Catalyst::Component/_component_name|_component_name>
+Derived by calling the L<Catalyst::Component/catalyst_component_name|catalyst_component_name>
method on each component.
=head2 code
__PACKAGE__->mk_classdata('_plugins');
__PACKAGE__->mk_classdata('_config');
-has _component_name => ( is => 'ro' ); # Cannot be required => 1 as context
+has catalyst_component_name => ( is => 'ro' ); # Cannot be required => 1 as context
# class @ISA component - HATE
# Make accessor callable as a class method, as we need to call setup_actions
# on the application class, which we don't have an instance of, ewwwww
# Also, naughty modules like Catalyst::View::JSON try to write to _everything_,
# so spit a warning, ignore that (and try to do the right thing anyway) here..
-around _component_name => sub {
+around catalyst_component_name => sub {
my ($orig, $self) = (shift, shift);
- Carp::cluck("Tried to write to the _component_name accessor - is your component broken or just mad? (Write ignored - using default value.)") if scalar @_;
+ Carp::cluck("Tried to write to the catalyst_component_name accessor - is your component broken or just mad? (Write ignored - using default value.)") if scalar @_;
blessed($self) ? $self->$orig() || blessed($self) : $self;
};
}
}
- my $namespace = Catalyst::Utils::class2prefix($self->_component_name, $case_s) || '';
+ my $namespace = Catalyst::Utils::class2prefix($self->catalyst_component_name, $case_s) || '';
$self->$orig($namespace) if ref($self);
return $namespace;
};
sub register_action_methods {
my ( $self, $c, @methods ) = @_;
- my $class = $self->_component_name;
+ my $class = $self->catalyst_component_name;
#this is still not correct for some reason.
my $namespace = $self->action_namespace($c);
my $response = request('http://localhost/anon/test');
ok($response->is_success);
is($response->header('X-Component-Name-Action'),
- 'TestApp::Controller::Anon', 'Action can see correct _component_name');
+ 'TestApp::Controller::Anon', 'Action can see correct catalyst_component_name');
isnt($response->header('X-Component-Instance-Name-Action'),
- 'TestApp::Controller::Anon', 'ref($controller) ne _component_name');
+ 'TestApp::Controller::Anon', 'ref($controller) ne catalyst_component_name');
is($response->header('X-Component-Name-Controller'),
- 'TestApp::Controller::Anon', 'Controller can see correct _component_name');
+ 'TestApp::Controller::Anon', 'Controller can see correct catalyst_component_name');
is($response->header('X-Class-In-Action'),
- 'TestApp::Controller::Anon', '$action->class is _component_name');
+ 'TestApp::Controller::Anon', '$action->class is catalyst_component_name');
is($response->header('X-Anon-Trait-Applied'),
'1', 'Anon controller class has trait applied correctly');
}
my $self = shift;
my ( $controller, $c, $test ) = @_;
$c->res->header( 'X-TestAppActionTestMyAction', 'MyAction works' );
- $c->res->header( 'X-Component-Name-Action', $controller->_component_name);
+ $c->res->header( 'X-Component-Name-Action', $controller->catalyst_component_name);
$c->res->header( 'X-Component-Instance-Name-Action', ref($controller));
$c->res->header( 'X-Class-In-Action', $self->class);
$self->next::method(@_);
sub test : Local ActionClass('+TestApp::Action::TestMyAction') {
my ($self, $c) = @_;
- $c->res->header('X-Component-Name-Controller', $self->_component_name);
+ $c->res->header('X-Component-Name-Controller', $self->catalyst_component_name);
$c->res->body('It works');
}