You are here

function composer_manager_initialize in Composer Manager 8

Initializes Composer Manager.

This is done by altering the root package to register the module's commands. Executed by init.php because it runs under the current user (and not the web server user like Drupal), giving it a higher chance of success.

Parameters

string $root: The app root.

1 call to composer_manager_initialize()
init.php in scripts/init.php

File

./composer_manager.module, line 55
Allows contributed modules to require external libraries via Composer.

Code

function composer_manager_initialize($root = NULL) {
  $root = $root ?: \Drupal::root();
  $module_path = str_replace($root . '/', '', __DIR__);
  $package = \Drupal\composer_manager\JsonFile::read($root . '/composer.json');
  $package['autoload']['psr-4']['Drupal\\composer_manager\\Composer\\'] = $module_path . '/src/Composer';
  $package['scripts']['drupal-rebuild'] = 'Drupal\\composer_manager\\Composer\\Command::rebuild';
  $package['scripts']['drupal-update'] = 'Drupal\\composer_manager\\Composer\\Command::update';
  \Drupal\composer_manager\JsonFile::write($root . '/composer.json', $package);
}