You are here

protected function ProjectInfoTrait::getComposerJson in Automatic Updates 8

Get the composer.json as a JSON array.

Parameters

string $extension_name: The extension name.

array $info: The extension's info.

Return value

array|null The composer.json as an array or NULL.

1 call to ProjectInfoTrait::getComposerJson()
ProjectInfoTrait::getProjectName in src/ProjectInfoTrait.php
Get the extension's project name.

File

src/ProjectInfoTrait.php, line 142

Class

ProjectInfoTrait
Provide a helper to get project info.

Namespace

Drupal\automatic_updates

Code

protected function getComposerJson($extension_name, array $info) {
  try {
    if ($directory = drupal_get_path($info['type'], $extension_name)) {
      $composer_json = $directory . DIRECTORY_SEPARATOR . 'composer.json';
      if (file_exists($composer_json)) {
        return json_decode(file_get_contents($composer_json), TRUE);
      }
    }
  } catch (\Throwable $exception) {
    \Drupal::logger('automatic_updates')
      ->error('Composer.json could not be located for @extension', [
      '@extension' => $extension_name,
    ]);
  }
  return NULL;
}