Skip to content

Commit 83e5803

Browse files
committed
temp
1 parent 4ec7000 commit 83e5803

4 files changed

Lines changed: 50 additions & 1 deletion

File tree

src/Controller/ApiController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ public function packageMetadata(string $packageName): Response
8181
throw $this->createNotFoundException();
8282
}
8383

84-
$this->messenger->dispatch(new UpdatePackage($package->getId()));
84+
if ($this->getParameter('dirigent.packages.dynamic_updates')) {
85+
$this->messenger->dispatch(new UpdatePackage($package->getId()));
86+
}
8587

8688
if (!$this->providerManager->exists($packageName)) {
8789
throw $this->createNotFoundException();

src/Doctrine/Entity/Distribution.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace CodedMonkey\Dirigent\Doctrine\Entity;
44

55
use CodedMonkey\Dirigent\Doctrine\Repository\DistributionRepository;
6+
use Doctrine\DBAL\Types\Types;
67
use Doctrine\ORM\Mapping as ORM;
78

89
#[ORM\Entity(repositoryClass: DistributionRepository::class)]
@@ -18,6 +19,12 @@ class Distribution
1819
#[ORM\Column]
1920
private ?string $reference = null;
2021

22+
#[ORM\Column]
23+
private ?string $type = null;
24+
25+
#[ORM\Column(Types::TEXT)]
26+
private ?string $source = null;
27+
2128
public function getId(): ?int
2229
{
2330
return $this->id;
@@ -42,4 +49,14 @@ public function setReference(string $reference): void
4249
{
4350
$this->reference = $reference;
4451
}
52+
53+
public function getType(): ?string
54+
{
55+
return $this->type;
56+
}
57+
58+
public function setType(string $type): void
59+
{
60+
$this->type = $type;
61+
}
4562
}

src/Doctrine/Entity/Version.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ class Version
114114
#[ORM\ManyToOne(targetEntity: Package::class, inversedBy: 'versions')]
115115
private ?Package $package = null;
116116

117+
#[ORM\OneToMany(mappedBy: 'version')]
118+
private Collection $distributions;
119+
117120
#[ORM\OneToOne(mappedBy: 'version', cascade: ['persist', 'detach', 'remove'])]
118121
private VersionInstallations $installations;
119122

src/Package/PackageDistributionResolver.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,28 @@ public function __construct(
4242
$this->distributionStoragePath = "$storagePath/distribution";
4343
}
4444

45+
public function isAvailable(): bool
46+
{
47+
48+
}
49+
50+
/**
51+
* Check if the distribution exists on the filesystem, circumventing the database.
52+
*/
4553
public function exists(string $packageName, string $packageVersion, ?string $reference, ?string $type): bool
4654
{
4755
return null !== $reference && null !== $type && $this->filesystem->exists($this->path($packageName, $packageVersion, $reference, $type));
4856
}
4957

58+
public function findEntity(Version $version, string $reference, string $type): ?Distribution
59+
{
60+
return $this->distributionRepository->findOneBy([
61+
'version' => $version,
62+
'reference' => $reference,
63+
'type' => $type,
64+
]);
65+
}
66+
5067
public function path(string $packageName, string $packageVersion, string $reference, string $type): string
5168
{
5269
return "$this->distributionStoragePath/$packageName/$packageVersion-$reference.$type";
@@ -66,6 +83,14 @@ public function resolve(Version $version, ?string $reference, ?string $type, boo
6683
return false;
6784
}
6885

86+
$distribution = $this->findEntity($version, $reference, $type);
87+
if (!$distribution) {
88+
$distribution = new Distribution();
89+
$distribution->setVersion($version);
90+
$distribution->setReference($reference);
91+
$distribution->setType($type);
92+
}
93+
6994
if ($async) {
7095
// Resolve the distribution asynchronously so it's available in the future now that we know it was requested
7196
$message = Envelope::wrap(new ResolveDistribution($version->getId(), $reference, $type))
@@ -120,6 +145,7 @@ private function build(Version $version, ?string $reference, ?string $type): boo
120145
$distribution = new Distribution();
121146
$distribution->setVersion($version);
122147
$distribution->setReference($reference);
148+
$distribution->setType($type);
123149

124150
$this->distributionRepository->save($distribution, flush: true);
125151

@@ -150,6 +176,7 @@ private function mirror(Version $version, ?string $reference, ?string $type): bo
150176
$distribution = new Distribution();
151177
$distribution->setVersion($version);
152178
$distribution->setReference($reference);
179+
$distribution->setType($type);
153180

154181
$this->distributionRepository->save($distribution, flush: true);
155182

0 commit comments

Comments
 (0)