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