Add StoredObjectVersionApiController and corresponding test

Added a new class StoredObjectVersionApiController in ChillDocGeneratorBundle which lists versions of a specified stored object. Corresponding unit test has been added as well. Made modifications in `StoredObject.php` to make the versions selectable. Also updated the API specifications to include a new GET route for retrieving versions.
This commit is contained in:
2024-09-17 11:55:55 +02:00
parent 3697aee584
commit 943a42cd38
4 changed files with 170 additions and 3 deletions

View File

@@ -18,6 +18,7 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
@@ -89,10 +90,10 @@ class StoredObject implements Document, TrackCreationInterface
private string $generationErrors = '';
/**
* @var Collection<int, StoredObjectVersion>
* @var Collection<int, StoredObjectVersion>&Selectable<int, StoredObjectVersion>
*/
#[ORM\OneToMany(mappedBy: 'storedObject', targetEntity: StoredObjectVersion::class, cascade: ['persist'], orphanRemoval: true)]
private Collection $versions;
private Collection&Selectable $versions;
/**
* @param StoredObject::STATUS_* $status
@@ -256,7 +257,7 @@ class StoredObject implements Document, TrackCreationInterface
return $this->template;
}
public function getVersions(): Collection
public function getVersions(): Collection&Selectable
{
return $this->versions;
}