Subject: | RFE: Make HTML::FormFu able to cope with multiple config_file_path |
As described in my email to the mailing list, I'd like to use multiple config_file_path for webapp
with a plugin mechanism.
attatched is a patch that allows config_file_paths to be an arrayref. can you please take a look?
Subject: | multiple_config_file_path.patch |
=== lib/HTML/FormFu/ObjectUtil.pm
==================================================================
--- lib/HTML/FormFu/ObjectUtil.pm (revision 101119)
+++ lib/HTML/FormFu/ObjectUtil.pm (local)
@@ -470,30 +470,45 @@
my $config_any_arg = $use_stems ? 'stems' : 'files';
my $config_any_method = $use_stems ? 'load_stems' : 'load_files';
+ my @config_file_path;
+ if (my $config_file_path = $self->config_file_path) {
+ if (ref $config_file_path eq 'ARRAY') {
+ push @config_file_path, @$config_file_path;
+ } else {
+ push @config_file_path, $config_file_path;
+ }
+ }
+ push @config_file_path, File::Spec->curdir;
+
for my $file (@filenames) {
- my $config_file_path = $self->config_file_path;
+ my $loaded = 0;
+ my $fullpath;
+ foreach my $config_file_path (@config_file_path) {
+ if ( defined $config_file_path
+ && !File::Spec->file_name_is_absolute($file)
+ )
+ {
+ $fullpath = File::Spec->catfile( $config_file_path, $file );
+ } else {
+ $fullpath = $file;
+ }
- if ( defined $config_file_path
- && !File::Spec->file_name_is_absolute($file)
- )
- {
- $file = File::Spec->catfile( $config_file_path, $file );
- }
-
- my $config = Config::Any->$config_any_method( {
- $config_any_arg => [$file],
- use_ext => 1,
- driver_args => {
- General => { -UTF8 => 1 },
- },
- } );
+ my $config = Config::Any->$config_any_method( {
+ $config_any_arg => [$fullpath],
+ use_ext => 1,
+ driver_args => {
+ General => { -UTF8 => 1 },
+ },
+ } );
- croak "config file '$file' not found"
- if !@$config;
-
- my ( $filename, $filedata ) = %{ $config->[0] };
+ next if ! @$config;
- _load_file( $self, $data_visitor, $filedata );
+ $loaded = 1;
+ my ( $filename, $filedata ) = %{ $config->[0] };
+
+ _load_file( $self, $data_visitor, $filedata );
+ }
+ croak "config file '$file' not found" if !$loaded;
}
return $self;