function drush_apps_install in Apps 7
Install an app, or list.
File
- ./
apps.drush.inc, line 145 - Apps module drush integration.
Code
function drush_apps_install() {
module_load_include('inc', 'apps', 'apps.installer');
$apps = func_get_args();
$installable = drush_apps_installable_apps();
$to_install = array();
// Verify that all apps are installable,
foreach ($apps as $app) {
if (array_key_exists($app, $installable)) {
$to_install[$app] = $installable[$app];
}
else {
drush_log(dt('App @app is not available for installation', array(
'@app' => $app,
)), 'error');
}
}
// If we have no installable apps, list all apps that are installable.
if (empty($to_install)) {
$type = drush_choice($installable, 'Enter a number to choose which App to install.', '!key');
if ($type === FALSE) {
return;
}
$to_install[$type] = $installable[$type];
}
// For each app we want to download its dependencies and itself.
foreach ($to_install as $app => $server) {
drush_print(dt('Install @app for server @server', array(
'@app' => $app,
'@server' => $server,
)));
$downloadables = apps_download_apps_list(apps_app_load($server, $app));
foreach ($downloadables as $downloadable) {
$download = array(
'url' => $downloadable['url'],
);
$name = $downloadable['name'];
$download_location = variable_get('apps_install_path', APPS_INSTALL_PATH) . "/" . $name;
$parts = explode('.', DRUSH_VERSION);
if ($parts[0] < 6 && !($parts[0] == 5 && $parts[1] > 9)) {
$downloaded = make_download_file($name, $download, $download_location);
}
else {
$downloaded = make_download_file($name, 'file', $download, $download_location);
}
if (!$downloaded) {
drush_log(dt('One of the dependencies of @app failed to download, canceling installation', array(
'@app' => $app,
)), 'error');
return;
}
}
// As there are now new modules, we have to reset the module data static
// cache.
drupal_static_reset('system_rebuild_module_data');
drush_invoke('pm-enable', $app);
}
}