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

Breadcrumb

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

function ShowCommand::printLicenses

Prints the licenses of a package with metadata

1 call to ShowCommand::printLicenses()
ShowCommand::printMeta in vendor/composer/composer/src/Composer/Command/ShowCommand.php
Prints package metadata.

File

vendor/composer/composer/src/Composer/Command/ShowCommand.php, line 998

Class

ShowCommand
@author Robert Schönthal <seroscho@googlemail.com> @author Jordi Boggiano <j.boggiano@seld.be> @author Jérémy Romey <jeremyFreeAgent> @author Mihai Plasoianu <mihai@plasoianu.de>

Namespace

Composer\Command

Code

protected function printLicenses(CompletePackageInterface $package) : void {
    $spdxLicenses = new SpdxLicenses();
    $licenses = $package->getLicense();
    $io = $this->getIO();
    foreach ($licenses as $licenseId) {
        $license = $spdxLicenses->getLicenseByIdentifier($licenseId);
        // keys: 0 fullname, 1 osi, 2 url
        if (!$license) {
            $out = $licenseId;
        }
        else {
            // is license OSI approved?
            if ($license[1] === true) {
                $out = sprintf('%s (%s) (OSI approved) %s', $license[0], $licenseId, $license[2]);
            }
            else {
                $out = sprintf('%s (%s) %s', $license[0], $licenseId, $license[2]);
            }
        }
        $io->write('<info>license</info>  : ' . $out);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal