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.

TicketFactory.php 1007B

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041
  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 implements TicketFactoryInterface
  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. }