Hirak\Prestissimo\Plugin::prefetchComposerRepositories PHP Method

prefetchComposerRepositories() public method

    public function prefetchComposerRepositories()
    {
        if ($this->disabled) {
            return;
        }
        if ($this->cached) {
            return;
        }
        $repos = $this->package->getRepositories();
        foreach ($repos as $label => $repo) {
            if (isset($repo['type']) && $repo['type'] === 'composer') {
                if (isset($repo['force-lazy-providers']) && $repo['force-lazy-providers']) {
                    continue;
                }
                if ('http?://' === substr($repo['url'], 0, 8) && isset($repo['allow_ssl_downgrade']) && $repo['allow_ssl_downgrade']) {
                    $repo = array('type' => $repo['type'], 'url' => str_replace('https?://', 'https://', $repo['url']));
                }
                $r = new ParallelizedComposerRepository($repo, $this->io, $this->config);
                $r->prefetch();
            }
        }
        $this->cached = true;
    }

Usage Example

Example #1
0
 public function testOnPreDependenciesSolving()
 {
     $plugin = new Plugin();
     $plugin->activate($this->composerp->reveal(), $this->iop->reveal());
     $evp = $this->prophesize('Composer\\Installer\\InstallerEvent');
     // on enabled
     $plugin->prefetchComposerRepositories($evp->reveal());
     // on disabled
     $plugin->disable();
     $evp = $this->prophesize('Composer\\Installer\\InstallerEvent');
     $evp->getOperations()->shouldNotBeCalled();
     $plugin->prefetchComposerRepositories($evp->reveal());
 }