You are here

public function WebformCliService::drush_webform_composer_update_validate in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Commands/WebformCliService.php \Drupal\webform\Commands\WebformCliService::drush_webform_composer_update_validate()

Implements drush_hook_COMMAND_validate().

Overrides WebformCliServiceInterface::drush_webform_composer_update_validate

File

src/Commands/WebformCliService.php, line 1055

Class

WebformCliService
Drush version agnostic commands.

Namespace

Drupal\webform\Commands

Code

public function drush_webform_composer_update_validate() {
  $msg = $this
    ->dt('THIS IS AN EXPERIMENTAL DRUSH COMMAND.') . PHP_EOL . $this
    ->dt('PLEASE MAKE SURE TO BACKUP YOUR COMPOSER.JSON FILE.') . PHP_EOL . $this
    ->dt("Are you sure you want update your Drupal installation's composer.json file?");
  if (!$this
    ->drush_confirm($msg)) {
    return $this
      ->drush_user_abort();
  }
  $drupal_root = Drush::bootstrapManager()
    ->getRoot();
  if (file_exists($drupal_root . '/composer.json')) {
    $composer_json = $drupal_root . '/composer.json';
    $composer_directory = '';
  }
  elseif (file_exists(dirname($drupal_root) . '/composer.json')) {

    // The "Composer template for Drupal projects" install Drupal in /web'.
    // @see https://github.com/drupal-composer/drupal-project/blob/8.x/composer.json
    $composer_json = dirname($drupal_root) . '/composer.json';
    $composer_directory = basename($drupal_root) . '/';
  }
  else {
    return $this
      ->drush_set_error($this
      ->dt('Unable to locate composer.json'));
  }
  $this->composer_json = $composer_json;
  $this->composer_directory = $composer_directory;
}