You are here

public function WebformCliService::drush_webform_libraries_composer in Webform 6.x

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

Implements drush_hook_COMMAND().

How to handle module library dependencies #68

Overrides WebformCliServiceInterface::drush_webform_libraries_composer

See also

https://github.com/drupal-composer/drupal-project/issues/68

File

src/Commands/WebformCliService.php, line 690

Class

WebformCliService
Drush version agnostic commands.

Namespace

Drupal\webform\Commands

Code

public function drush_webform_libraries_composer() {

  // Load existing composer.json file and unset certain properties.
  $composer_path = drupal_get_path('module', 'webform') . '/composer.json';
  $json = file_get_contents($composer_path);
  $data = json_decode($json, FALSE, $this
    ->drush_webform_composer_get_json_encode_options());
  $data = (array) $data;
  unset($data['extra'], $data['require-dev']);
  $data = (object) $data;

  // Set disable tls.
  $this
    ->drush_webform_composer_set_disable_tls($data);

  // Set libraries.
  $data->repositories = (object) [];
  $data->require = (object) [];
  $this
    ->drush_webform_composer_set_libraries($data->repositories, $data->require);

  // Remove _webform property.
  foreach ($data->repositories as &$repository) {
    unset($repository['_webform']);
  }
  $this
    ->drush_print(json_encode($data, $this
    ->drush_webform_composer_get_json_encode_options()));
}