collection-crud/src/Repository/FlashRepository.php

33 lines
778 B
PHP

<?php declare(strict_types=1);
namespace App\Repository;
use App\Entity\{Flash, PreviouslyOwnedFlash};
use Doctrine\ORM\{EntityRepository, ORMInvalidArgumentException};
class FlashRepository extends EntityRepository
{
use AcquireTrait;
/**
* @throws ORMInvalidArgumentException
*/
public function deacquire(Flash $currentRecord): void
{
$currentRecord->setFormerlyOwned(TRUE)
->setReceived(TRUE);
$this->moveRecord($currentRecord, new PreviouslyOwnedFlash());
}
/**
* @throws ORMInvalidArgumentException
*/
public function reacquire(PreviouslyOwnedFlash $currentRecord): void
{
$currentRecord->setFormerlyOwned(FALSE);
$this->moveRecord($currentRecord, new Flash());
}
}