protected function checkOwnInvoice(Invoice $invoice, Request $request, $em) { $paymentHelper = new PaymentHelper(); $id = $this->getCurrentCustomId($paymentHelper); if (!$invoice->isOwnInvoice($id)) { throw new AccessDeniedHttpException('Not your own invoice'); } return true; }