function InstalledPackagesList::getCorePackages

Returns a list of installed core packages.

Packages returned by ::getCorePackageList() are considered core packages.

Parameters

bool $include_dev: (optional) Whether to include core packages intended for development. Defaults to TRUE.

Return value

static A list of the installed core packages.

File

core/modules/package_manager/src/InstalledPackagesList.php, line 159

Class

InstalledPackagesList
Defines a class to list installed Composer packages.

Namespace

Drupal\package_manager

Code

public function getCorePackages(bool $include_dev = TRUE) : static {
    $core_packages = array_intersect_key($this->getArrayCopy(), array_flip(static::getCorePackageList()));
    // If drupal/core-recommended is present, it supersedes drupal/core, since
    // drupal/core will always be one of its direct dependencies.
    if (array_key_exists('drupal/core-recommended', $core_packages)) {
        unset($core_packages['drupal/core']);
    }
    if (!$include_dev) {
        unset($core_packages['drupal/core-dev']);
        unset($core_packages['drupal/core-dev-pinned']);
    }
    return new static($core_packages);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.