collection-crud/src/Repository/CameraRepository.php

37 lines
798 B
PHP
Raw Normal View History

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