Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. JsonLoader.php

function JsonLoader::load

Parameters

string|JsonFile $json A filename, json string or JsonFile instance to load the package from:

Return value

CompletePackage|CompleteAliasPackage|RootPackage|RootAliasPackage

File

vendor/composer/composer/src/Composer/Package/Loader/JsonLoader.php, line 39

Class

JsonLoader
@author Konstantin Kudryashiv <ever.zet@gmail.com>

Namespace

Composer\Package\Loader

Code

public function load($json) : BasePackage {
    if ($json instanceof JsonFile) {
        $config = $json->read();
    }
    elseif (file_exists($json)) {
        $config = JsonFile::parseJson(file_get_contents($json), $json);
    }
    elseif (is_string($json)) {
        $config = JsonFile::parseJson($json);
    }
    else {
        throw new \InvalidArgumentException(sprintf("JsonLoader: Unknown \$json parameter %s. Please report at https://github.com/composer/composer/issues/new.", gettype($json)));
    }
    return $this->loader
        ->load($config);
}
RSS feed
Powered by Drupal