function InstalledPackage::createFromArray
Create an installed package object from an array.
Parameters
array $data: The package data.
Return value
static
7 calls to InstalledPackage::createFromArray()
- ComposerInspector::getInstalledPackagesList in core/
modules/ package_manager/ src/ ComposerInspector.php  - Returns the installed packages list.
 - ComposerInspectorTest::testGetInstalledPackagesList in core/
modules/ package_manager/ tests/ src/ Kernel/ ComposerInspectorTest.php  - Tests get installed packages list.
 - InstalledPackagesListTest::testCorePackages in core/
modules/ package_manager/ tests/ src/ Unit/ InstalledPackagesListTest.php  - Tests core packages.
 - InstalledPackagesListTest::testPackageByDrupalProjectName in core/
modules/ package_manager/ tests/ src/ Kernel/ InstalledPackagesListTest.php  - Tests package by drupal project name.
 - InstalledPackagesListTest::testPackageComparison in core/
modules/ package_manager/ tests/ src/ Unit/ InstalledPackagesListTest.php  - Tests package comparison.
 
File
- 
              core/
modules/ package_manager/ src/ InstalledPackage.php, line 41  
Class
- InstalledPackage
 - A value object that represents an installed Composer package.
 
Namespace
Drupal\package_managerCode
public static function createFromArray(array $data) : static {
  $path = isset($data['path']) ? realpath($data['path']) : NULL;
  // Fall back to `library`.
  // @see https://getcomposer.org/doc/04-schema.md#type
  $type = $data['type'] ?? 'library';
  assert(($type === 'metapackage') === is_null($path), 'Metapackage install path must be NULL.');
  return new static($data['name'], $data['version'], $path, $type);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.