forked from jigarius/drupal-migration-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc11n_migrate.install
48 lines (41 loc) · 1.11 KB
/
c11n_migrate.install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/**
* @file
* Handle install / uninstall events for the module.
*/
/**
* Implements hook_install().
*
* Copies migration source files to the public:// directory.
*/
function c11n_migrate_install() {
// Prepare destination directory.
$dest_directory = 'public://import/program';
file_prepare_directory($dest_directory, FILE_CREATE_DIRECTORY);
// Copy files to destination directory.
foreach(_c11n_migrate_source_files() as $filename => $file) {
file_unmanaged_copy($file->uri, $dest_directory . '/' . $file->filename, FILE_EXISTS_REPLACE);
}
}
/**
* Implements hook_uninstall().
*
* Deletes migration source files created during installation.
*/
function c11n_migrate_uninstall() {
$dest_directory = 'public://import/program';
file_unmanaged_delete_recursive($dest_directory);
}
/**
* Get a list of import source files.
*
* @return array
* Import source files.
*/
function _c11n_migrate_source_files() {
$dirname = drupal_get_path('module', 'c11n_migrate') . '/import/program';
return file_scan_directory($dirname, '/.*/', [
'recurse' => FALSE,
'key' => 'filename',
]);
}