requires 'URI' => '1.35';
requires 'Text::Balanced'; # core in 5.8.x but mentioned for completeness
requires 'MRO::Compat';
+requires 'String::RewritePrefix' => '0.004'; # Catalyst::Utils::resolve_namespace
recommends 'B::Hooks::OP::Check::StashChange';
-Known Bugs:
-
- - Bug ->go or ->visit causes actions which have Args or CaptureArgs called
- twice when called via ->go or ->visit.
-
- Test app: http://github.com/bobtfish/catalyst-app-bug-go_chain/tree/master
-
-Compatibility warnings to add:
-
- - $self->config should warn as config should only ever be called as a
- class method.
-
-Proposed functionality / feature additions:
-
- - Log setup needs to be less lame, so Catalyst::Plugin::Log::* can die
- in a fire. Having $c->log_class would be a good start. kane volunteered
- to do some of this.
-
- Simple example: Catalyst::Plugin::Log::Colorful should just be a
- subclass of Catalyst::Log, no ::Plugin:: needed.
-
- See also: Catalyst::Plugin::Log::Dispatch and
- http://github.com/willert/catalyst-plugin-log4perl-simple/tree
+TODO for brach namespace_handling_refactor:
+- refactor code in
+ * Catalyst::Dispatcher::get_containers # No Idea
+ * Catalyst::Dispatcher::get_containers # No Idea
+ * Catalyst::Controller::_parse_ActionClass_attr # DONE
+ * Catalyst::Dispatcher::_load_dispatch_types # DONE
+ * Catalyst::setup_plugins # DONE
+ to use the same namespacing method
\ No newline at end of file
$class->_plugins( {} ) unless $class->_plugins;
$plugins ||= [];
-
- my @plugins = map { s/\A\+// ? $_ : "Catalyst::Plugin::$_" } @$plugins;
+
+ my @plugins = Catalyst::Utils::resolve_namespace('Catalyst::Plugin', @$plugins);
for my $plugin ( reverse @plugins ) {
Class::MOP::load_class($plugin);
sub _parse_ActionClass_attr {
my ( $self, $c, $name, $value ) = @_;
- unless ( $value =~ s/^\+// ) {
- $value = join('::', $self->_action_class, $value );
- }
+ $value = Catalyst::Utils::resolve_namespace($self->_action_class, $value);
return ( 'ActionClass', $value );
}
# Preload action types
for my $type (@types) {
- my $class =
- ( $type =~ /^\+(.*)$/ ) ? $1 : "Catalyst::DispatchType::${type}";
-
+ my $class = Catalyst::Utils::resolve_namespace('Catalyst::DispatchType', $type);
+
eval { Class::MOP::load_class($class) };
Catalyst::Exception->throw( message => qq/Couldn't load "$class"/ )
if $@;
sub dispatch_type {
my ($self, $name) = @_;
- unless ($name =~ s/^\+//) {
- $name = "Catalyst::DispatchType::" . $name;
- }
+ $name = Catalyst::Utils::resolve_namespace('Catalyst::DispatchType', $name);
for (@{ $self->_dispatch_types }) {
return $_ if ref($_) eq $name;
use Carp qw/croak/;
use Cwd;
+use String::RewritePrefix;
+
use namespace::clean;
=head1 NAME
return $_term_width = $width;
}
+
+=head2 resolve_namespace
+
+Method which adds the namespace for plugins and actions.
+
+ __PACKAGE__->setup(qw(MyPlugin));
+
+ # will load Catalyst::Plugin::MyPlugin
+
+=cut
+
+
+sub resolve_namespace {
+ my $namespace = shift;
+ my @classes = @_;
+ return String::RewritePrefix->rewrite(
+ { '' => $namespace.'::', '+' => '' }, @classes,
+ );
+}
+
+
=head1 AUTHORS
Catalyst Contributors, see Catalyst.pm