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

Breadcrumb

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

function ShowCommand::displayPackageTree

Display the tree

Parameters

array<int, array<string, string|mixed[]>> $arrayTree:

1 call to ShowCommand::displayPackageTree()
ShowCommand::execute in vendor/composer/composer/src/Composer/Command/ShowCommand.php
Executes the current command.

File

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

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 displayPackageTree(array $arrayTree) : void {
    $io = $this->getIO();
    foreach ($arrayTree as $package) {
        $io->write(sprintf('<info>%s</info>', $package['name']), false);
        $io->write(' ' . $package['version'], false);
        if (isset($package['description'])) {
            $io->write(' ' . strtok($package['description'], "\r\n"));
        }
        else {
            // output newline
            $io->write('');
        }
        if (isset($package['requires'])) {
            $requires = $package['requires'];
            $treeBar = '├';
            $j = 0;
            $total = count($requires);
            foreach ($requires as $require) {
                $requireName = $require['name'];
                $j++;
                if ($j === $total) {
                    $treeBar = '└';
                }
                $level = 1;
                $color = $this->colors[$level];
                $info = sprintf('%s──<%s>%s</%s> %s', $treeBar, $color, $requireName, $color, $require['version']);
                $this->writeTreeLine($info);
                $treeBar = str_replace('└', ' ', $treeBar);
                $packagesInTree = [
                    $package['name'],
                    $requireName,
                ];
                $this->displayTree($require, $packagesInTree, $treeBar, $level + 1);
            }
        }
    }
}

API Navigation

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