/** * @param Ticket $ticket * * @return Message */ public function createMessage(Ticket $ticket) { $message = new Message(); $message->setUser($this->tokenStorage->getToken()->getUser())->setTicket($ticket); $message->setPriority($ticket->getPriority()); $this->om->persist($message); return $message; }
/** * @param Ticket $ticket * @param bool $isCloseTicket * @param Message $message */ public function updateTicket(Ticket $ticket, bool $isCloseTicket, Message $message) { if ($isCloseTicket) { $ticket->setStatus('closed'); } else { $ticket->setStatus('open'); } $ticket->setPriority($message->getPriority()); $ticket->setLastUser($this->getUser()); $ticket->setIsRead(false); $ticket->setLastMessageAt($message->getCreatedAt()); $this->om->flush(); }
/** * @param FormBuilderInterface $builder * @param array $options */ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('message', TextareaType::class, ['label' => 'ticket.label.form.message', 'attr' => ['placeholder' => 'ticket.placeholder.form.message'], 'required' => false])->add('media', FileMediaType::class, ['provider' => 'sonata.media.provider.ticket_image', 'context' => 'ticket', 'label' => 'ticket.label.form.image', 'translation_domain' => 'messages', 'required' => false])->add('priority', ChoiceType::class, ['label' => 'ticket.label.form.priority', 'choices' => Message::getPriorities()]); // if existing ticket add status if (!$this->isNewTicket) { $builder->add('closeTicket', SubmitType::class, ['label' => 'ticket.button.close_ticket', 'translation_domain' => 'messages', 'attr' => ['value' => 'closeTicket', 'class' => 'btn btn-danger'], 'validation_groups' => false])->add('changePriority', SubmitType::class, ['label' => 'ticket.button.change.priority', 'validation_groups' => false, 'attr' => ['value' => 'changePriority', 'class' => 'btn btn-warning']])->add('submit', SubmitType::class, ['label' => 'ticket.button.reply', 'attr' => ['class' => 'btn btn-primary']]); } }
/** * @param Message $message * @param array $item */ public function setMessageImage(Message $message, array $item) { $imageFile = new File(__DIR__ . '/../Data/images/' . $item['mediaFile']); $mediaManager = $this->container->get('sonata.media.manager.media'); /** @var Media $image */ $image = $mediaManager->create(); $image->setBinaryContent($imageFile); $image->setEnabled(true); $image->setName($item['mediaName']); $image->setContext('ticket'); $image->setProviderName('sonata.media.provider.ticket_image'); $mediaManager->save($image); $message->setMedia($image); }
/** * @param DatagridMapper $datagridMapper */ protected function configureDatagridFilters(DatagridMapper $datagridMapper) { $datagridMapper->add('id')->add('lastMessageAt')->add('subject')->add('status', null, [], 'choice', ['choices' => Message::getStatuses('ticket.status_')])->add('priority', null, [], 'choice', ['choices' => Message::getPriorities()])->add('createdAt')->add('isRead'); }
/** * Add messages * * @param Message $message * * @return Ticket */ public function addMessage(Message $message) { $message->setTicket($this); $this->messages[] = $message; return $this; }
/** * @param FormMapper $formMapper */ protected function configureFormFields(FormMapper $formMapper) { $formMapper->add('message', TextareaType::class, ['required' => false])->add('status', 'choice', ['choices' => Message::getStatuses('ticket.status_')])->add('priority', 'choice', ['choices' => Message::getPriorities()])->add('media', FileMediaType::class, ['provider' => 'sonata.media.provider.ticket_image', 'context' => 'ticket', 'required' => false]); }