src/StartPlatz/Bundle/GruendungsstipendiumBundle/EventSubscriber/GsEvidenceSubscriber.php line 63

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace App\StartPlatz\Bundle\GruendungsstipendiumBundle\EventSubscriber;
  3. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsApplicationApprovedEvent;
  4. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsApplicationDeletedEvent;
  5. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsApplicationFinalizedEvent;
  6. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsApplicationRejectedEvent;
  7. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsApplicationStatusResetEvent;
  8. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsJuryAdmittedEvent;
  9. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsJuryRecommendedEvent;
  10. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsJuryRejectedEvent;
  11. use App\StartPlatz\Bundle\GruendungsstipendiumBundle\Event\GsJurySessionStatusChangedEvent;
  12. use App\StartPlatz\Ecosystem\Evidence\SystemEvidenceRecorder;
  13. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  14. class GsEvidenceSubscriber implements EventSubscriberInterface
  15. {
  16.     public function __construct(
  17.         private readonly SystemEvidenceRecorder $evidenceRecorder
  18.     ) {}
  19.     public static function getSubscribedEvents(): array
  20.     {
  21.         return [
  22.             GsApplicationApprovedEvent::class => 'onApplicationApproved',
  23.             GsApplicationRejectedEvent::class => 'onApplicationRejected',
  24.             GsJuryAdmittedEvent::class => 'onJuryAdmitted',
  25.             GsJuryRecommendedEvent::class => 'onJuryRecommended',
  26.             GsJuryRejectedEvent::class => 'onJuryRejected',
  27.             GsApplicationFinalizedEvent::class => 'onApplicationFinalized',
  28.             GsApplicationDeletedEvent::class => 'onApplicationDeleted',
  29.             GsApplicationStatusResetEvent::class => 'onApplicationStatusReset',
  30.             GsJurySessionStatusChangedEvent::class => 'onJurySessionStatusChanged',
  31.         ];
  32.     }
  33.     public function onApplicationApproved(GsApplicationApprovedEvent $event): void
  34.     {
  35.         $app $event->application;
  36.         $this->evidenceRecorder->documentApplicationApproval(
  37.             $app->getId(),
  38.             $app->getBatchId(),
  39.             ['startup_name' => $app->getStartupName()],
  40.             $event->documentedBy
  41.         );
  42.     }
  43.     public function onApplicationRejected(GsApplicationRejectedEvent $event): void
  44.     {
  45.         $app $event->application;
  46.         $this->evidenceRecorder->documentApplicationRejection(
  47.             $app->getId(),
  48.             $app->getBatchId(),
  49.             array_filter([
  50.                 'startup_name' => $app->getStartupName(),
  51.                 'reason' => $event->reason,
  52.             ]),
  53.             $event->documentedBy
  54.         );
  55.     }
  56.     public function onJuryAdmitted(GsJuryAdmittedEvent $event): void
  57.     {
  58.         $app $event->application;
  59.         $session $event->session;
  60.         $this->evidenceRecorder->documentJuryAdmission(
  61.             $app->getId(),
  62.             $session->getId(),
  63.             [
  64.                 'startup_name' => $app->getStartupName(),
  65.                 'session_name' => $session->getName(),
  66.                 'jury_date' => $session->getJuryDate()?->format('Y-m-d'),
  67.             ],
  68.             $event->documentedBy
  69.         );
  70.     }
  71.     public function onJuryRecommended(GsJuryRecommendedEvent $event): void
  72.     {
  73.         $app $event->application;
  74.         $this->evidenceRecorder->documentJuryRecommendation(
  75.             $app->getId(),
  76.             $event->session->getId(),
  77.             [
  78.                 'startup_name' => $app->getStartupName(),
  79.                 'score' => $app->getRatingAverage(),
  80.             ],
  81.             $event->documentedBy
  82.         );
  83.     }
  84.     public function onJuryRejected(GsJuryRejectedEvent $event): void
  85.     {
  86.         $app $event->application;
  87.         $this->evidenceRecorder->documentJuryRejection(
  88.             $app->getId(),
  89.             $event->session->getId(),
  90.             [
  91.                 'startup_name' => $app->getStartupName(),
  92.                 'score' => $app->getRatingAverage(),
  93.             ],
  94.             $event->documentedBy
  95.         );
  96.     }
  97.     public function onApplicationFinalized(GsApplicationFinalizedEvent $event): void
  98.     {
  99.         $app $event->application;
  100.         $result $event->result;
  101.         $this->evidenceRecorder->documentFinalization(
  102.             $app->getId(),
  103.             $app->getBatchId(),
  104.             [
  105.                 'member_created' => $result->memberCreated,
  106.                 'team_created' => $result->teamCreated,
  107.                 'member_id' => $result->member->getId(),
  108.                 'team_id' => $result->team->getId(),
  109.             ],
  110.             $event->documentedBy
  111.         );
  112.     }
  113.     public function onApplicationDeleted(GsApplicationDeletedEvent $event): void
  114.     {
  115.         $this->evidenceRecorder->documentApplicationDeletion(
  116.             $event->applicationId,
  117.             $event->batchId,
  118.             [
  119.                 'startup_name' => $event->startupName,
  120.                 'email' => $event->email,
  121.             ],
  122.             $event->documentedBy
  123.         );
  124.     }
  125.     public function onApplicationStatusReset(GsApplicationStatusResetEvent $event): void
  126.     {
  127.         $app $event->application;
  128.         $this->evidenceRecorder->documentApplicationStatusReset(
  129.             $app->getId(),
  130.             $app->getBatchId(),
  131.             [
  132.                 'old_status' => $event->oldStatus,
  133.                 'new_status' => 'applied',
  134.                 'startup_name' => $app->getStartupName(),
  135.             ],
  136.             $event->documentedBy
  137.         );
  138.     }
  139.     public function onJurySessionStatusChanged(GsJurySessionStatusChangedEvent $event): void
  140.     {
  141.         $this->evidenceRecorder->documentJurySessionStatusChange(
  142.             $event->session->getId(),
  143.             [
  144.                 'old_status' => $event->oldStatus,
  145.                 'new_status' => $event->newStatus,
  146.                 'session_name' => $event->session->getName(),
  147.             ],
  148.             $event->documentedBy
  149.         );
  150.     }
  151. }