Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize or remove site-set #2952

Closed
weitzman opened this issue Sep 22, 2017 · 2 comments
Closed

Modernize or remove site-set #2952

weitzman opened this issue Sep 22, 2017 · 2 comments
Milestone

Comments

@weitzman
Copy link
Member

public function siteSet($site = '@none', $options = ['a' =>'b'])
{
if ($filename = drush_sitealias_get_envar_filename()) {
$last_site_filename = drush_sitealias_get_envar_filename('drush-drupal-prev-site-');
if ($site == '-') {
if (file_exists($last_site_filename)) {
$site = file_get_contents($last_site_filename);
} else {
$site = '@none';
}
}
if ($site == '@self') {
$path = drush_cwd();
$site_record = drush_sitealias_lookup_alias_by_path($path, true);
if (isset($site_record['#name'])) {
$site = '@' . $site_record['#name'];
} else {
$site = '@none';
}
// Using 'site-set @self' is quiet if there is no change.
$current = is_file($filename) ? trim(file_get_contents($filename)) : "@none";
if ($current == $site) {
return;
}
}
if (_drush_sitealias_set_context_by_name($site)) {
if (file_exists($filename)) {
@unlink($last_site_filename);
@rename($filename, $last_site_filename);
}
$success_message = dt("Site set to !site", array('!site' => $site));
if ($site == '@none') {
if (drush_delete_dir($filename)) {
$this->logger()->success(dt('Site unset.'));
}
} elseif (drush_mkdir(dirname($filename), true)) {
if (file_put_contents($filename, $site)) {
$this->logger()->success($success_message);
$this->logger()->info(dt("Site information stored in !file", array('!file' => $filename)));
}
}
} else {
throw new \Exception(dt("Could not find a site definition for !site.", array('!site' => $site)));
}
}
}

@weitzman weitzman added this to the drush9 milestone Sep 22, 2017
@weitzman
Copy link
Member Author

The command is hidden for now.

@greg-1-anderson
Copy link
Member

Fixed by #2989

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants