37 lines
795 B
PHP
37 lines
795 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace CameraBundle\Repository;
|
|
|
|
use CameraBundle\Entity\{Flash, PreviouslyOwnedFlash};
|
|
use Doctrine\ORM\{
|
|
EntityRepository, ORMInvalidArgumentException
|
|
};
|
|
|
|
class FlashRepository extends EntityRepository {
|
|
|
|
use AcquireTrait;
|
|
|
|
/**
|
|
* @param Flash $currentRecord
|
|
* @throws ORMInvalidArgumentException
|
|
*/
|
|
public function deacquire(Flash $currentRecord)
|
|
{
|
|
$currentRecord->setFormerlyOwned(true)
|
|
->setReceived(true);
|
|
|
|
$this->moveRecord($currentRecord, new PreviouslyOwnedFlash());
|
|
}
|
|
|
|
/**
|
|
* @param PreviouslyOwnedFlash $currentRecord
|
|
* @throws ORMInvalidArgumentException
|
|
*/
|
|
public function reacquire(PreviouslyOwnedFlash $currentRecord)
|
|
{
|
|
$currentRecord->setFormerlyOwned(false);
|
|
|
|
$this->moveRecord($currentRecord, new Flash());
|
|
}
|
|
}
|