Open-source event management and ticket selling platform — perfect for concerts, conferences, and everything in between 🎟️ If you find this project helpful, please consider giving us a star ⭐️
PHP attendize-alternativedoor-managementevent-check-inevent-managementevent-registrationevent-ticketingeventbrite-alternativeeventslaravelopen-sourcephpreactself-hostedsell-ticketssell-tickets-onlineticket-sellingticketing-systemtickettailor-alternativetito-alternative
<?php
namespace HiEvents\Services\Application\Handlers\Question;
use HiEvents\DomainObjects\QuestionDomainObject;
use HiEvents\Services\Application\Handlers\Question\DTO\UpsertQuestionDTO;
use HiEvents\Services\Domain\Event\EventSpamCheckDispatchService;
use HiEvents\Services\Domain\Question\CreateQuestionService;
use HiEvents\Services\Infrastructure\HtmlPurifier\HtmlPurifierService;
use Throwable;
class CreateQuestionHandler
{
public function __construct(
private readonly CreateQuestionService $createQuestionService,
private readonly HtmlPurifierService $purifier,
private readonly EventSpamCheckDispatchService $eventSpamCheckDispatchService,
) {}
/**
* @throws Throwable
*/
public function handle(UpsertQuestionDTO $createQuestionDTO): QuestionDomainObject
{
$question = (new QuestionDomainObject)
->setTitle($createQuestionDTO->title)
->setEventId($createQuestionDTO->event_id)
->setBelongsTo($createQuestionDTO->belongs_to->name)
->setType($createQuestionDTO->type->name)
->setRequired($createQuestionDTO->required)
->setOptions($createQuestionDTO->options)
->setIsHidden($createQuestionDTO->is_hidden)
->setDescription($this->purifier->purify($createQuestionDTO->description));
$createdQuestion = $this->createQuestionService->createQuestion(
$question,
$createQuestionDTO->product_ids,
);
$this->eventSpamCheckDispatchService->dispatchForEvent($createQuestionDTO->event_id);
return $createdQuestion;
}
}