collection-crud/src/Repository/CameraRepository.php

37 lines
798 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): void
{
$currentRecord->setFormerlyOwned(true)
->setReceived(true);
$this->moveRecord($currentRecord, new PreviouslyOwnedCamera());
}
/**
* @param PreviouslyOwnedCamera $currentRecord
* @throws ORMInvalidArgumentException
*/
public function reacquire(PreviouslyOwnedCamera $currentRecord): void
{
$currentRecord->setFormerlyOwned(false);
$this->moveRecord($currentRecord, new Camera());
}
}