/** * @param Ticket $ticket * @return void */ private function processDeleteTicket(Ticket $ticket) { $attachments = $ticket->getAttachments(); foreach ($attachments as $attachment) { $this->attachmentManager->deleteAttachment($attachment); } $this->ticketRepository->remove($ticket); $this->dispatchWorkflowEvent($this->doctrineRegistry, $this->dispatcher, $ticket); }
/** * @param Ticket $ticket * @return void */ private function processDeleteTicket(Ticket $ticket) { $attachments = $ticket->getAttachments(); $ticket->delete(); foreach ($attachments as $attachment) { $this->attachmentManager->deleteAttachment($attachment); } $this->dispatchEvents($ticket); $this->ticketRepository->remove($ticket); }
/** * Remove Attachment from Comment * @param RemoveCommentAttachmentCommand $command * @return void * @throws \RuntimeException if Comment does not exists or Comment has no particular attachment */ public function removeAttachmentFromComment(RemoveCommentAttachmentCommand $command) { $comment = $this->loadCommentBy($command->commentId); $this->isGranted('EDIT', $comment); $attachment = $comment->getAttachment($command->attachmentId); if (!$attachment) { throw new \RuntimeException('Attachment loading failed. Comment has no such attachment.'); } $comment->removeAttachment($attachment); $this->commentRepository->store($comment); $this->attachmentManager->deleteAttachment($attachment); }
/** * Remove Attachment from Comment * @param RemoveCommentAttachmentCommand $command * @param boolean $flush * @return void * * @throws ForbiddenException * @throws CommentNotFoundException * @throws AttachmentNotFoundException */ public function removeAttachmentFromComment(RemoveCommentAttachmentCommand $command, $flush = false) { $comment = $this->loadCommentBy($command->commentId); $this->isGranted('EDIT', $comment); $attachment = $comment->getAttachment($command->attachmentId); if (empty($attachment)) { throw new AttachmentNotFoundException(); } $comment->removeAttachment($attachment); $this->registry->getManager()->persist($comment); $this->attachmentManager->deleteAttachment($attachment); if (true === $flush) { $this->registry->getManager()->flush(); } }