You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 satır
973B

  1. <?php
  2. namespace Lc\SovBundle\Factory\Ticket;
  3. use App\Entity\Ticket\Ticket;
  4. use Doctrine\ORM\EntityManagerInterface;
  5. use Lc\SovBundle\Factory\AbstractFactory;
  6. use Lc\SovBundle\Model\Ticket\TicketInterface;
  7. class TicketFactory extends AbstractFactory
  8. {
  9. protected $ticketMessageFactory;
  10. public function __construct(EntityManagerInterface $em, TicketMessageFactory $ticketMessageFactory)
  11. {
  12. $this->ticketMessageFactory = $ticketMessageFactory;
  13. parent::__construct($em);
  14. }
  15. public function getEntityClass()
  16. {
  17. return TicketInterface::class;
  18. }
  19. public function create($params = array())
  20. {
  21. if (!isset($params['status'])) {
  22. $params['status'] = Ticket::TICKET_STATUS_OPEN;
  23. }
  24. $ticket = parent::create($params);
  25. if (!isset($params['ticketMessages'])) {
  26. $ticket->addTicketMessage($this->ticketMessageFactory->create());
  27. }
  28. return $ticket;
  29. }
  30. }