| 1 |
package Dancer2::Plugin::OnPluginImport; |
| 2 |
use Dancer2::Plugin; |
| 3 |
|
| 4 |
# register keyword |
| 5 |
register some_import => sub { shift->dancer_version }; |
| 6 |
|
| 7 |
# register hook |
| 8 |
register_hook qw(imported_plugin); |
| 9 |
|
| 10 |
# add hook. This triggers the $dsl->hooks attribute |
| 11 |
# to be built plugins added after this should still |
| 12 |
# be able to register and add hooks. See #889. |
| 13 |
on_plugin_import { |
| 14 |
my $dsl = shift; |
| 15 |
|
| 16 |
$dsl->app->add_hook( |
| 17 |
Dancer2::Core::Hook->new( |
| 18 |
name => 'imported_plugin', |
| 19 |
code => sub { $dsl->dancer_version } |
| 20 |
) |
| 21 |
); |
| 22 |
}; |
| 23 |
|
| 24 |
register_plugin; |
| 25 |
|
| 26 |
1; |