|
|
|
|
|
|
|
|
use Lc\SovBundle\Component\FormComponent; |
|
|
use Lc\SovBundle\Component\FormComponent; |
|
|
use Lc\SovBundle\Factory\Ticket\TicketFactory; |
|
|
use Lc\SovBundle\Factory\Ticket\TicketFactory; |
|
|
use Lc\SovBundle\Model\Ticket\TicketInterface; |
|
|
use Lc\SovBundle\Model\Ticket\TicketInterface; |
|
|
use Lc\SovBundle\Model\Ticket\TicketMessageInterface; |
|
|
|
|
|
use Lc\SovBundle\Model\Ticket\TicketModel; |
|
|
use Lc\SovBundle\Model\Ticket\TicketModel; |
|
|
use Lc\SovBundle\Repository\User\UserStore; |
|
|
use Lc\SovBundle\Repository\User\UserStore; |
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
|
|
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; |
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
|
|
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; |
|
|
|
|
|
use Symfony\Component\Security\Core\Security; |
|
|
|
|
|
|
|
|
class TicketBuilder |
|
|
class TicketBuilder |
|
|
{ |
|
|
{ |
|
|
|
|
|
protected Security $security; |
|
|
protected EntityManagerInterface $entityManager; |
|
|
protected EntityManagerInterface $entityManager; |
|
|
protected MailMailjetNotification $mailMailjetNotification; |
|
|
protected MailMailjetNotification $mailMailjetNotification; |
|
|
protected FormComponent $formComponent; |
|
|
protected FormComponent $formComponent; |
|
|
|
|
|
|
|
|
protected UserStore $userStore; |
|
|
protected UserStore $userStore; |
|
|
|
|
|
|
|
|
public function __construct( |
|
|
public function __construct( |
|
|
|
|
|
Security $security, |
|
|
EntityManagerInterface $entityManager, |
|
|
EntityManagerInterface $entityManager, |
|
|
MailMailjetNotification $mailMailjetNotification, |
|
|
MailMailjetNotification $mailMailjetNotification, |
|
|
FormComponent $formComponent, |
|
|
FormComponent $formComponent, |
|
|
|
|
|
|
|
|
TicketFactory $ticketFactory, |
|
|
TicketFactory $ticketFactory, |
|
|
UserStore $userStore |
|
|
UserStore $userStore |
|
|
) { |
|
|
) { |
|
|
|
|
|
$this->security = $security; |
|
|
$this->entityManager = $entityManager; |
|
|
$this->entityManager = $entityManager; |
|
|
$this->mailMailjetNotification = $mailMailjetNotification; |
|
|
$this->mailMailjetNotification = $mailMailjetNotification; |
|
|
$this->formComponent = $formComponent; |
|
|
$this->formComponent = $formComponent; |
|
|
$this->parameterBag = $parameterBag; |
|
|
$this->parameterBag = $parameterBag; |
|
|
$this->ticketFactory = $ticketFactory; |
|
|
$this->ticketFactory = $ticketFactory; |
|
|
$this->userStore = $userStore; |
|
|
$this->userStore = $userStore; |
|
|
|
|
|
$this->authorizationChecker = $authorizationChecker; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public function create(array $params = []): TicketInterface |
|
|
public function create(array $params = []): TicketInterface |
|
|
|
|
|
|
|
|
$firstname = $params['visitorFirstname']; |
|
|
$firstname = $params['visitorFirstname']; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->entityManager->create($ticket); |
|
|
|
|
|
$this->entityManager->flush(); |
|
|
|
|
|
|
|
|
if (isset($params['createByAdmin']) && $params['createByAdmin']) { |
|
|
if (isset($params['createByAdmin']) && $params['createByAdmin']) { |
|
|
// envoi email au client |
|
|
// envoi email au client |
|
|
$this->mailMailjetNotification->send( |
|
|
$this->mailMailjetNotification->send( |
|
|
|
|
|
|
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
$this->entityManager->persist($ticket); |
|
|
|
|
|
$this->entityManager->flush(); |
|
|
|
|
|
|
|
|
|
|
|
// notifyAdmin |
|
|
// notifyAdmin |
|
|
$usersToNotify = $this->userStore->getByTicketTypesNotification($ticket->getType()); |
|
|
$usersToNotify = $this->userStore->getByTicketTypesNotification($ticket->getType()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MailMailjetNotification::CONTENT_DATA => [ |
|
|
MailMailjetNotification::CONTENT_DATA => [ |
|
|
'firstname' => $userToNotify->getFirstname(), |
|
|
'firstname' => $userToNotify->getFirstname(), |
|
|
'ticket' => $ticket, |
|
|
'ticket' => $ticket, |
|
|
'ticketMessage' => $ticket->getTicketMessage(), |
|
|
|
|
|
|
|
|
'ticketMessage' => $ticket->getTicketMessages()[0], |
|
|
], |
|
|
], |
|
|
] |
|
|
] |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function init(TicketInterface $ticket, array $params = []): void |
|
|
public function init(TicketInterface $ticket, array $params = []): void |
|
|
{ |
|
|
{ |
|
|
|
|
|
$user = $this->security->getUser(); |
|
|
|
|
|
if($user) { |
|
|
|
|
|
$ticket->setCreatedBy($user); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (isset($params['user'])) { |
|
|
if (isset($params['user'])) { |
|
|
$ticket->setUser($params['user']); |
|
|
$ticket->setUser($params['user']); |
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
$ticket->setVisitorFirstname($params['visitorFirstname']); |
|
|
$ticket->setVisitorFirstname($params['visitorFirstname']); |
|
|
$ticket->setVisitorLastname($params['visitorLastname']); |
|
|
$ticket->setVisitorLastname($params['visitorLastname']); |
|
|
|
|
|
|
|
|
->setType($params['type']) |
|
|
->setType($params['type']) |
|
|
->setSubject($params['subject']); |
|
|
->setSubject($params['subject']); |
|
|
|
|
|
|
|
|
$ticketMessage = $ticket->getTicketMessage(); |
|
|
|
|
|
$ticketMessage->setStatus(1); |
|
|
|
|
|
|
|
|
$ticketMessageArray = $ticket->getTicketMessages(); |
|
|
|
|
|
$ticketMessage = $ticketMessageArray[0]; |
|
|
$ticketMessage->setMessage($params['message']); |
|
|
$ticketMessage->setMessage($params['message']); |
|
|
|
|
|
|
|
|
if (isset($params['imageFilename']) && $params['imageFilename']) { |
|
|
if (isset($params['imageFilename']) && $params['imageFilename']) { |