| 1 | package Class::Component::Component::Plaggerize::PluginLoader; | ||
| 2 | use strict; | ||
| 3 | use warnings; | ||
| 4 | |||
| 5 | sub setup_config { | ||
| 6 | my $class = shift; | ||
| 7 | my $config = $class->NEXT( setup_config => @_ ); | ||
| 8 | |||
| 9 | $config->{global} = {} unless $config->{global}; | ||
| 10 | $config->{global}->{pluginloader} = {} unless $config->{global}->{pluginloader}; | ||
| 11 | my $conf = $config->{global}->{pluginloader}; | ||
| 12 | $conf->{plugin_list} ||= 'plugins'; | ||
| 13 | |||
| 14 | $config; | ||
| 15 | } | ||
| 16 | |||
| 17 | sub setup_plugins { | ||
| 18 | my $self = shift; | ||
| 19 | |||
| 20 | my @plugins; | ||
| 21 | my $plugin_list = $self->conf->{global}->{pluginloader}->{plugin_list}; | ||
| 22 | for my $plugin (@{ $self->conf->{$plugin_list} }) { | ||
| 23 | push @plugins, { module => $plugin->{module}, config => $plugin }; | ||
| 24 | } | ||
| 25 | $self->load_plugins(@plugins); | ||
| 26 | |||
| 27 | $self->NEXT( setup_plugins => @_ ); | ||
| 28 | } | ||
| 29 | |||
| 30 | 1; |