ticketMessageFactory = $ticketMessageFactory; parent::__construct($em); } public function getEntityClass() { return TicketInterface::class; } public function create($params = array()) { if (!isset($params['status'])) { $params['status'] = Ticket::TICKET_STATUS_OPEN; } $ticket = parent::create($params); if (!isset($params['ticketMessages'])) { $ticket->addTicketMessage($this->ticketMessageFactory->create()); } return $ticket; } }