Skip to content

Commit f587389

Browse files
committed
Clean up package-related Doctrine entity classes
Signed-off-by: Tim Goudriaan <tim@codedmonkey.com>
1 parent d8f3f94 commit f587389

File tree

3 files changed

+1
-32
lines changed

3 files changed

+1
-32
lines changed

src/Doctrine/Entity/Metadata.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Metadata extends TrackedEntity implements \Stringable
8888
#[ORM\Column(nullable: true)]
8989
private ?\DateTimeImmutable $releasedAt = null;
9090

91-
#[ORM\ManyToOne(targetEntity: Version::class, inversedBy: 'metadata')]
91+
#[ORM\ManyToOne(targetEntity: Version::class)]
9292
#[ORM\JoinColumn(nullable: false, onDelete: 'CASCADE')]
9393
private Version $version;
9494

src/Doctrine/Entity/Package.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ class Package extends TrackedEntity
8585
#[ORM\Column(nullable: true)]
8686
private ?\DateTimeImmutable $dumpedAt = null;
8787

88-
/**
89-
* @var array<string, Version> lookup table for versions
90-
*/
91-
private array $cachedVersions;
92-
9388
private array $sortedVersions;
9489

9590
public function __construct()
@@ -271,18 +266,6 @@ public function getVersions(): Collection
271266
return $this->versions;
272267
}
273268

274-
public function getVersion(string $normalizedVersion): ?Version
275-
{
276-
if (!isset($this->cachedVersions)) {
277-
$this->cachedVersions = [];
278-
foreach ($this->getVersions() as $version) {
279-
$this->cachedVersions[strtolower($version->getNormalizedName())] = $version;
280-
}
281-
}
282-
283-
return $this->cachedVersions[strtolower($normalizedVersion)] ?? null;
284-
}
285-
286269
#[\Override]
287270
public function getCreatedAt(): \DateTimeImmutable
288271
{

src/Doctrine/Entity/Version.php

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

55
use CodedMonkey\Dirigent\Doctrine\Repository\VersionRepository;
6-
use Doctrine\Common\Collections\ArrayCollection;
7-
use Doctrine\Common\Collections\Collection;
86
use Doctrine\ORM\Mapping as ORM;
97

108
#[ORM\Entity(repositoryClass: VersionRepository::class)]
@@ -41,15 +39,11 @@ class Version extends TrackedEntity implements \Stringable
4139
#[ORM\OneToOne(mappedBy: 'version', cascade: ['persist', 'detach', 'remove'])]
4240
private VersionInstallations $installations;
4341

44-
#[ORM\OneToMany(targetEntity: Metadata::class, mappedBy: 'version', cascade: ['persist', 'detach', 'remove'])]
45-
private Collection $metadata;
46-
4742
public function __construct(Package $package)
4843
{
4944
$this->package = $package;
5045

5146
$this->installations = new VersionInstallations($this);
52-
$this->metadata = new ArrayCollection();
5347
}
5448

5549
public function __toString(): string
@@ -134,14 +128,6 @@ public function getInstallations(): VersionInstallations
134128
return $this->installations;
135129
}
136130

137-
/**
138-
* @return Collection<int, Metadata>
139-
*/
140-
public function getMetadata(): Collection
141-
{
142-
return $this->metadata;
143-
}
144-
145131
public function getExtendedName(): string
146132
{
147133
return $this->name . ($this->getCurrentMetadata()->hasVersionAlias() ? ' / ' . $this->getCurrentMetadata()->getVersionAlias() : '');

0 commit comments

Comments
 (0)