=head2 $self->action_namespace($c)
-Determine the namespace for actions in this component.
+Returns the private namespace for actions in this component. Defaults to a value
+from the controller name (for e.g. MyApp::Controller::Foo::Bar becomes
+"foo/bar") or can be overriden from the "namespace" config key.
=cut
=head2 $self->path_prefix($c)
-alias for action_namespace
+Returns the default path prefix for :Local, :LocalRegex and relative :Path
+actions in this component. Defaults to the action_namespace or can be
+overriden from the "path" config key.
=cut
-sub path_prefix { shift->action_namespace(@_); }
+sub path_prefix {
+ my ( $self, $c ) = @_;
+ my $hash = (ref $self ? $self : $self->config); # hate app-is-class
+ return $hash->{path} if exists $hash->{path};
+ return shift->action_namespace(@_);
+}
=head2 $self->register_actions($c)
-package TestApp::Controller::Action::Relative;
+package TestApp::Controller::Action::TestRelative;
use strict;
use base 'TestApp::Controller::Action';
+__PACKAGE__->config(
+ path => 'action/relative'
+);
+
sub relative : Local {
my ( $self, $c ) = @_;
$c->forward('/action/forward/one');
}
{
my @expected = qw[
- TestApp::Controller::Action::Relative->begin
- TestApp::Controller::Action::Relative->relative
+ TestApp::Controller::Action::TestRelative->begin
+ TestApp::Controller::Action::TestRelative->relative
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
'action/relative/relative', 'Test Action' );
is(
$response->header('X-Test-Class'),
- 'TestApp::Controller::Action::Relative',
+ 'TestApp::Controller::Action::TestRelative',
'Test Class'
);
is( $response->header('X-Catalyst-Executed'),
}
{
my @expected = qw[
- TestApp::Controller::Action::Relative->begin
- TestApp::Controller::Action::Relative->relative_two
+ TestApp::Controller::Action::TestRelative->begin
+ TestApp::Controller::Action::TestRelative->relative_two
TestApp::Controller::Action::Forward->one
TestApp::Controller::Action::Forward->two
TestApp::Controller::Action::Forward->three
);
is(
$response->header('X-Test-Class'),
- 'TestApp::Controller::Action::Relative',
+ 'TestApp::Controller::Action::TestRelative',
'Test Class'
);
is( $response->header('X-Catalyst-Executed'),