public static function ComposerUtility::createForDirectory in Automatic Updates 8.2
Creates a utility object using the files in a given directory.
Parameters
string $dir: The directory that contains composer.json and composer.lock.
Return value
\Drupal\package_manager\ComposerUtility The utility object.
4 calls to ComposerUtility::createForDirectory()
- ReadinessValidationManager::run in src/Validation/ ReadinessValidationManager.php 
- Dispatches the readiness check event and stores the results.
- StagedProjectsValidatorTest::createEvent in tests/src/ Unit/ StagedProjectsValidatorTest.php 
- Creates a pre-commit event object for testing.
- Updater::begin in src/Updater.php 
- Begins the update.
- Updater::commit in src/Updater.php 
- Commits the current update.
File
- package_manager/src/ ComposerUtility.php, line 48 
Class
- ComposerUtility
- Defines a utility object to get information from Composer's API.
Namespace
Drupal\package_managerCode
public static function createForDirectory(string $dir) : self {
  $io = new NullIO();
  $configuration = $dir . DIRECTORY_SEPARATOR . 'composer.json';
  // The Composer factory requires that either the HOME or COMPOSER_HOME
  // environment variables be set, so momentarily set the COMPOSER_HOME
  // variable to the directory we're trying to create a Composer instance for.
  // We have to do this because the Composer factory doesn't give us a way to
  // pass the home directory in.
  // @see \Composer\Factory::getHomeDir()
  $home = getenv('COMPOSER_HOME');
  putenv("COMPOSER_HOME={$dir}");
  $composer = Factory::create($io, $configuration);
  putenv("COMPOSER_HOME={$home}");
  return new static($composer);
}