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

Breadcrumb

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

function InstalledPackage::createFromArray

Create an installed package object from an array.

Parameters

array $data: The package data.

Return value

static

1 call to InstalledPackage::createFromArray()
ComposerInspector::getInstalledPackagesList in core/modules/package_manager/src/ComposerInspector.php
Returns the installed packages list.

File

core/modules/package_manager/src/InstalledPackage.php, line 41

Class

InstalledPackage
A value object that represents an installed Composer package.

Namespace

Drupal\package_manager

Code

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);
}
RSS feed
Powered by Drupal