Add cron job for removing expired stored objects

Introduced `RemoveExpiredStoredObjectCronJob` to automate the deletion of expired stored objects every 7 days. Enhanced associated tests and updated relevant interfaces and classes to support the new cron job functionality.
This commit is contained in:
2024-08-28 11:41:43 +02:00
parent c38f7c1179
commit 0db2652f08
10 changed files with 344 additions and 12 deletions

View File

@@ -33,6 +33,13 @@ class StoredObjectVersion implements TrackCreationInterface
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null;
/**
* The stored object associated with this version.
*/
#[ORM\ManyToOne(targetEntity: StoredObject::class, inversedBy: 'versions')]
#[ORM\JoinColumn(name: 'stored_object_id', nullable: true)]
private ?StoredObject $storedObject;
/**
* filename of the version in the stored object.
*/
@@ -40,12 +47,7 @@ class StoredObjectVersion implements TrackCreationInterface
private string $filename = '';
public function __construct(
/**
* The stored object associated with this version.
*/
#[ORM\ManyToOne(targetEntity: StoredObject::class, inversedBy: 'versions')]
#[ORM\JoinColumn(name: 'stored_object_id', nullable: true)]
private StoredObject $storedObject,
StoredObject $storedObject,
/**
* The incremental version.
@@ -76,6 +78,7 @@ class StoredObjectVersion implements TrackCreationInterface
private string $type = '',
?string $filename = null,
) {
$this->storedObject = $storedObject;
$this->filename = $filename ?? self::generateFilename($this);
}
@@ -124,4 +127,12 @@ class StoredObjectVersion implements TrackCreationInterface
{
return $this->version;
}
/**
* @internal to be used by StoredObject::removeVersion
*/
public function resetStoredObject(): void
{
$this->storedObject = null;
}
}