This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Repository;
|
||||
use App\Entity\Order;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* @extends ServiceEntityRepository<Order>
|
||||
@@ -39,6 +40,22 @@ class OrderRepository extends ServiceEntityRepository
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function update(Order $entity, bool $flush = false): void
|
||||
{
|
||||
$order = $this->getEntityManager()->find(Order::class, $entity->getId());
|
||||
|
||||
if (!$order) {
|
||||
throw $this->createNotFoundException('Order not found: ' . $entity->getId());
|
||||
}
|
||||
|
||||
if ($flush) {
|
||||
$this->getEntityManager()->flush();
|
||||
}
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return Order[] Returns an array of Order objects
|
||||
// */
|
||||
@@ -63,4 +80,11 @@ class OrderRepository extends ServiceEntityRepository
|
||||
// ->getOneOrNullResult()
|
||||
// ;
|
||||
// }
|
||||
}
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
private function createNotFoundException(string $string)
|
||||
{
|
||||
throw new Exception($string);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user