Skip to content

Commit 9ee1ee7

Browse files
committed
Deprecate symfony:generate-id as it's not used anymore
1 parent 7112b53 commit 9ee1ee7

File tree

3 files changed

+5
-51
lines changed

3 files changed

+5
-51
lines changed

src/Command/GenerateIdCommand.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,20 @@
1414
use Symfony\Component\Console\Command\Command;
1515
use Symfony\Component\Console\Input\InputInterface;
1616
use Symfony\Component\Console\Output\OutputInterface;
17+
use Symfony\Component\Console\Style\SymfonyStyle;
1718

1819
class GenerateIdCommand extends Command
1920
{
20-
private $flex;
21-
22-
public function __construct(/* cannot be type-hinted */ $flex)
23-
{
24-
$this->flex = $flex;
25-
26-
parent::__construct();
27-
}
28-
2921
protected function configure()
3022
{
31-
$this->setName('symfony:generate-id')
32-
->setDescription('Generates a unique ID for this project.')
33-
;
23+
$this->setName('symfony:generate-id');
3424
}
3525

3626
protected function execute(InputInterface $input, OutputInterface $output): int
3727
{
38-
$this->flex->generateFlexId();
28+
$ui = new SymfonyStyle($input, $output);
29+
$ui->error('This command is a noop and should not be used anymore.');
3930

40-
return 0;
31+
return 1;
4132
}
4233
}

src/Downloader.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ class Downloader
3838
private $degradedMode = false;
3939
private $endpoint;
4040
private $caFile;
41-
private $flexId;
4241
private $enabled = true;
4342

4443
public function __construct(Composer $composer, IoInterface $io, $rfs)
@@ -60,11 +59,6 @@ public function getSessionId(): string
6059
return $this->sess;
6160
}
6261

63-
public function setFlexId(string $id = null)
64-
{
65-
$this->flexId = $id;
66-
}
67-
6862
public function isEnabled()
6963
{
7064
return $this->enabled;
@@ -314,10 +308,6 @@ private function getOptions(array $headers): array
314308
{
315309
$options = ['http' => ['header' => $headers]];
316310

317-
if ($this->flexId) {
318-
$options['http']['header'][] = 'Project: '.$this->flexId;
319-
}
320-
321311
if (null !== $this->caFile) {
322312
$options['ssl']['cafile'] = $this->caFile;
323313
}

src/Flex.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
126126
$rfs = Factory::createHttpDownloader($this->io, $this->config);
127127

128128
$this->downloader = $downloader = new Downloader($composer, $io, $rfs);
129-
$this->downloader->setFlexId($this->getFlexId());
130129

131130
if ($symfonyRequire) {
132131
$this->filter = new PackageFilter($io, $symfonyRequire, $this->downloader);
@@ -138,7 +137,6 @@ class_exists(__NAMESPACE__.str_replace('/', '\\', substr($file, \strlen(__DIR__)
138137
$this->rfs = $rfs = new ParallelDownloader($this->io, $this->config, $rfs->getOptions(), $rfs->isTlsDisabled());
139138

140139
$this->downloader = $downloader = new Downloader($composer, $io, $this->rfs);
141-
$this->downloader->setFlexId($this->getFlexId());
142140

143141
$rootPackage = $composer->getPackage();
144142
$manager = RepositoryFactory::manager($this->io, $this->config, $composer->getEventDispatcher(), $this->rfs);
@@ -741,24 +739,6 @@ public function onFileDownload(PreFileDownloadEvent $event)
741739
}
742740
}
743741

744-
public function generateFlexId()
745-
{
746-
if ($this->getFlexId()) {
747-
return;
748-
}
749-
750-
if (!$this->downloader->isEnabled()) {
751-
throw new \LogicException('Cannot generate project id when "symfony/flex" is not found in the root composer.json.');
752-
}
753-
754-
$json = new JsonFile(Factory::getComposerFile());
755-
$manipulator = new JsonManipulator(file_get_contents($json->getPath()));
756-
$manipulator->addSubNode('extra', 'symfony.id', $this->downloader->get('/ulid')->getBody()['ulid']);
757-
file_put_contents($json->getPath(), $manipulator->getContents());
758-
759-
$this->updateComposerLock();
760-
}
761-
762742
public function updateAutoloadFile()
763743
{
764744
if (!$platform = $this->lock->get('php')['version'] ?? null) {
@@ -904,13 +884,6 @@ private function initOptions(): Options
904884
return new Options($options, $this->io);
905885
}
906886

907-
private function getFlexId()
908-
{
909-
$extra = $this->composer->getPackage()->getExtra();
910-
911-
return $extra['symfony']['id'] ?? null;
912-
}
913-
914887
private function formatOrigin(string $origin): string
915888
{
916889
// symfony/translation:3.3@github.com/symfony/recipes:branch

0 commit comments

Comments
 (0)