collection-crud/src/Repository/FlashRepository.php

37 lines
795 B
PHP
Raw Normal View History

2018-02-14 15:08:03 -05:00
<?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());
}
}