2018-02-14 15:08:03 -05:00
|
|
|
<?php declare(strict_types=1);
|
2018-01-03 16:35:10 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
namespace App\Repository;
|
2018-01-03 16:35:10 -05:00
|
|
|
|
2018-02-14 16:42:39 -05:00
|
|
|
use App\Entity\{Camera, PreviouslyOwnedCamera};
|
2018-02-14 15:08:03 -05:00
|
|
|
use Doctrine\ORM\{
|
|
|
|
EntityRepository, ORMInvalidArgumentException
|
|
|
|
};
|
|
|
|
|
|
|
|
class CameraRepository extends EntityRepository {
|
|
|
|
|
|
|
|
use AcquireTrait;
|
2018-01-03 16:35:10 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Camera $currentRecord
|
2018-02-14 15:08:03 -05:00
|
|
|
* @throws ORMInvalidArgumentException
|
2018-01-03 16:35:10 -05:00
|
|
|
*/
|
|
|
|
public function deacquire(Camera $currentRecord)
|
|
|
|
{
|
2018-02-14 15:08:03 -05:00
|
|
|
$currentRecord->setFormerlyOwned(true)
|
|
|
|
->setReceived(true);
|
2018-01-03 16:35:10 -05:00
|
|
|
|
2018-02-14 15:08:03 -05:00
|
|
|
$this->moveRecord($currentRecord, new PreviouslyOwnedCamera());
|
|
|
|
}
|
2018-01-03 16:35:10 -05:00
|
|
|
|
2018-02-14 15:08:03 -05:00
|
|
|
/**
|
|
|
|
* @param PreviouslyOwnedCamera $currentRecord
|
|
|
|
* @throws ORMInvalidArgumentException
|
|
|
|
*/
|
|
|
|
public function reacquire(PreviouslyOwnedCamera $currentRecord)
|
|
|
|
{
|
|
|
|
$currentRecord->setFormerlyOwned(false);
|
2018-01-03 16:35:10 -05:00
|
|
|
|
2018-02-14 15:08:03 -05:00
|
|
|
$this->moveRecord($currentRecord, new Camera());
|
2018-01-03 16:35:10 -05:00
|
|
|
}
|
|
|
|
}
|