forked from kraftwagen/kraftwagen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
database.init.kw.inc
41 lines (33 loc) · 1.19 KB
/
database.init.kw.inc
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
<?php
/**
* @file
* This file contains the functions that are required to execute
* `drush kw-init-database`.
*/
/**
* Implements drush_COMMAND_init() for `drush kw-init-database`.
*/
function drush_kw_init_database_init() {
kraftwagen_context_init_kraftwagen_root();
}
/**
* Implements drush_COMMAND() for `drush kw-init-database`.
*/
function drush_kraftwagen_kw_init_database() {
// Find out where the Kraftwagen root is.
$root = kraftwagen_context_get_option('root-path');
if (!($dir_src = kraftwagen_context_get_option('src-dir'))) {
return drush_set_error(dt('No src dir name set.'));
}
if (!lstat($root . DIRECTORY_SEPARATOR . $dir_src)) {
return drush_set_error(dt('Src dir not found at !path', array('!path' => $root . DIRECTORY_SEPARATOR . $dir_src)));
}
$files = drush_scan_directory($root . DIRECTORY_SEPARATOR . $dir_src, "/\.info$/", array('.', '..', '.git'), 0, FALSE);
if (empty($files) || count($files) > 1) {
return drush_set_error(dt('Could not determine profile name from src dir.'));
}
$files = array_values($files);
$file = $files[0];
$profile_name = $file->name;
drush_invoke_process('@self', 'site-install', array($profile_name, '--yes'));
}