Skip to content

Commit

Permalink
Allow plugin classes with colons, allow non-fully qualified names:
Browse files Browse the repository at this point in the history
If you call the `execute_hook` method, you need the fully qualified
name. We protect against it elsewhere, but not here. Here at least
we throw a warning. We should do the same elsewhere.

Anyway, we also check for nested classes, which I missed.
  • Loading branch information
xsawyerx authored and veryrusty committed Mar 3, 2016
1 parent d2ef910 commit 6308871
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/Dancer2/Plugin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,16 @@ sub _exporter_app {

my $plugin_class = lc $class;
$plugin_class =~ s/^dancer2::plugin:://;
$plugin_class =~ s{::}{_}g;

# you're either calling it with the full qualifier or not
# if not, use the execute_plugin_hook instead
if ( $plugin->hooks->{"plugin.$plugin_class.$hook_name"} ) {
Carp::carp("Please use fully qualified hook name or "
. "the method execute_plugin_hook");
$hook_name = "plugin.$plugin_class.$hook_name";
}

$hook_name =~ /^plugin\.$plugin_class/
or Carp::croak('Unknown plugin called through other plugin');

Expand Down

0 comments on commit 6308871

Please sign in to comment.