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

Breadcrumb

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

function InstallationManager::notifyInstalls

File

vendor/composer/composer/src/Composer/Installer/InstallationManager.php, line 572

Class

InstallationManager
Package operation manager.

Namespace

Composer\Installer

Code

public function notifyInstalls(IOInterface $io) : void {
    $promises = [];
    try {
        foreach ($this->notifiablePackages as $repoUrl => $packages) {
            // non-batch API, deprecated
            if (str_contains($repoUrl, '%package%')) {
                foreach ($packages as $package) {
                    $url = str_replace('%package%', $package->getPrettyName(), $repoUrl);
                    $params = [
                        'version' => $package->getPrettyVersion(),
                        'version_normalized' => $package->getVersion(),
                    ];
                    $opts = [
                        'retry-auth-failure' => false,
                        'http' => [
                            'method' => 'POST',
                            'header' => [
                                'Content-type: application/x-www-form-urlencoded',
                            ],
                            'content' => http_build_query($params, '', '&'),
                            'timeout' => 3,
                        ],
                    ];
                    $promises[] = $this->loop
                        ->getHttpDownloader()
                        ->add($url, $opts);
                }
                continue;
            }
            $postData = [
                'downloads' => [],
            ];
            foreach ($packages as $package) {
                $packageNotification = [
                    'name' => $package->getPrettyName(),
                    'version' => $package->getVersion(),
                ];
                if (strpos($repoUrl, 'packagist.org/') !== false) {
                    if (isset(FileDownloader::$downloadMetadata[$package->getName()])) {
                        $packageNotification['downloaded'] = FileDownloader::$downloadMetadata[$package->getName()];
                    }
                    else {
                        $packageNotification['downloaded'] = false;
                    }
                }
                $postData['downloads'][] = $packageNotification;
            }
            $opts = [
                'retry-auth-failure' => false,
                'http' => [
                    'method' => 'POST',
                    'header' => [
                        'Content-Type: application/json',
                    ],
                    'content' => json_encode($postData),
                    'timeout' => 6,
                ],
            ];
            $promises[] = $this->loop
                ->getHttpDownloader()
                ->add($repoUrl, $opts);
        }
        $this->loop
            ->wait($promises);
    } catch (\Exception $e) {
    }
    $this->reset();
}

API Navigation

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