diff options
author | rojanu <aliustek@gmail.com> | 2016-01-15 15:40:10 +0100 |
---|---|---|
committer | Gervase Markham <gerv@mozilla.org> | 2016-01-15 15:40:10 +0100 |
commit | 933fe72425f6e657c152950246735370f0f06dcf (patch) | |
tree | 93dba11fac36dae4e3be00d214427028cc6181fc /Bugzilla | |
parent | a0c3ade6d450ee0403612199a96db5bb8a577006 (diff) | |
download | bugzilla-933fe72425f6e657c152950246735370f0f06dcf.tar.gz bugzilla-933fe72425f6e657c152950246735370f0f06dcf.tar.xz |
Bug 922549: Bugzilla::Migrate.pm should provide hook in load function. r=gerv.
Diffstat (limited to 'Bugzilla')
-rw-r--r-- | Bugzilla/Hook.pm | 28 | ||||
-rw-r--r-- | Bugzilla/Migrate.pm | 20 |
2 files changed, 44 insertions, 4 deletions
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index f711907d1..6f85885c3 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -1083,6 +1083,34 @@ A hashref. The set of named parameters passed to C<create>. =back +=head2 migrate_modules + +This hook allows you to add modules to Migrate to support additional systems +to be imported into Bugzilla + +Params: + +=over + +=item C<modules> - An hashref containing data to be returned to L<Bugzilla::Migrate>. +This hashref contains the path and prefix for the modules to be used. + +=over + +=item C<path> - Path to where the modules are kept, on a typical extension this +would be the lib folder of the extension. + +=item C<prefix> - Package prefix of the module to be loaded + +=back + +The definition is structured as: + $modules = { path => $path, prefix => $prefix }; + + +=back + + =head2 object_before_delete This happens in L<Bugzilla::Object/remove_from_db>, after we've confirmed diff --git a/Bugzilla/Migrate.pm b/Bugzilla/Migrate.pm index 0731d4fed..6ecdb5c0d 100644 --- a/Bugzilla/Migrate.pm +++ b/Bugzilla/Migrate.pm @@ -199,12 +199,24 @@ sub load { my @migration_modules = glob("$libdir/Bugzilla/Migrate/*"); my ($module) = grep { basename($_) =~ /^\Q$from\E\.pm$/i } @migration_modules; - if (!$module) { + if ($module) { + require $module; + my $canonical_name = _canonical_name($module); + return "Bugzilla::Migrate::$canonical_name"->new; + } + else { + my $migrate_module = {}; + Bugzilla::Hook::process('migrate_modules', $migrate_module); + @migration_modules = glob($migrate_module->{path}."/*"); + ($module) = grep { basename($_) =~ /^\Q$from\E\.pm$/i } + @migration_modules; + if (!$module) { ThrowUserError('migrate_from_invalid', { from => $from }); + } + require $module; + my $canonical_name = _canonical_name($module); + return "$migrate_module->{prefix}::$canonical_name"->new; } - require $module; - my $canonical_name = _canonical_name($module); - return "Bugzilla::Migrate::$canonical_name"->new; } ############# |