/
TruncatedComposerRepository.php
44 lines (36 loc) · 1.51 KB
/
TruncatedComposerRepository.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Flex;
use Composer\Config;
use Composer\EventDispatcher\EventDispatcher;
use Composer\IO\IOInterface;
use Composer\Package\RootPackageInterface;
use Composer\Repository\ComposerRepository as BaseComposerRepository;
use Composer\Util\RemoteFilesystem;
/**
* @author Nicolas Grekas <p@tchwork.com>
*/
class TruncatedComposerRepository extends BaseComposerRepository
{
public function __construct(array $repoConfig, IOInterface $io, Config $config, ?EventDispatcher $eventDispatcher = null, ?RemoteFilesystem $rfs = null)
{
parent::__construct($repoConfig, $io, $config, $eventDispatcher, $rfs);
$this->cache = new Cache($io, $config->get('cache-repo-dir').'/'.preg_replace('{[^a-z0-9.]}i', '-', $this->url), 'a-z0-9.$');
}
public function setSymfonyRequire(string $symfonyRequire, RootPackageInterface $rootPackage, Downloader $downloader, IOInterface $io)
{
$this->cache->setSymfonyRequire($symfonyRequire, $rootPackage, $downloader, $io);
}
protected function fetchFile($filename, $cacheKey = null, $sha256 = null, $storeLastModifiedTime = false)
{
$data = parent::fetchFile($filename, $cacheKey, $sha256, $storeLastModifiedTime);
return \is_array($data) ? $this->cache->removeLegacyTags($data) : $data;
}
}