src/Offer/EventSubscriber/SetOfferDraftEmailMetaSubscriber.php line 44
<?phpdeclare(strict_types=1);/*** Copyright (c) 2021 TECLA Consulting Group oü.* All rights reserved.** This unpublished material is proprietary to TECLA Consulting Group oü.* All rights reserved. The methods and* techniques described herein are considered trade secrets* and/or confidential. Reproduction or distribution, in whole* or in part, is forbidden except by express written permission* of TECLA Consulting Group oü.** @author Matúš Sýkorjak <matus@tecla.no>* @copyright 2021 TECLA Consulting Group oü*/namespace App\Offer\EventSubscriber;use App\Contact\Security\ContactContextInterface;use App\Offer\Event\OfferDraftEmail\CreateEvent;use DateTimeImmutable;use JetBrains\PhpStorm\ArrayShape;use Symfony\Component\EventDispatcher\EventSubscriberInterface;final class SetOfferDraftEmailMetaSubscriber implements EventSubscriberInterface{private ContactContextInterface $context;public function __construct(ContactContextInterface $context){$this->context = $context;}#[ArrayShape([CreateEvent::class => 'array'])]public static function getSubscribedEvents(): array{return [CreateEvent::class => ['onCreate', -1024],];}public function onCreate(CreateEvent $event): void{$createdBy = $this->context->getBase();$createdAt = new DateTimeImmutable();$email = $event->getEmail();$email->setCreatedBy($createdBy);$email->setCreatedAt($createdAt);foreach ($email->getAttachments() as $attachment) {$attachment->setCreatedBy($createdBy);$attachment->setCreatedAt($createdAt);}}}