src/EventListener/Forecast/GenerateDeclarationOnForecastValidationListener.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\EventListener\Forecast;
  3. use App\Entity\Forecast\EstablishmentDiploma\Staff\ForecastStaff;
  4. use App\Event\ValidationRequest\ValidationRequestValidateEvent;
  5. use App\Service\Entity\Declaration\DeclarationStaffManager;
  6. class GenerateDeclarationOnForecastValidationListener
  7. {
  8.     public function __construct(
  9.         private DeclarationStaffManager $manageDeclaration
  10.     )
  11.     {
  12.     }
  13.     public function onForecastValidation(ValidationRequestValidateEvent $event)
  14.     {
  15.         $validationRequest $event->getValidationRequest();
  16.         $forecast $validationRequest->getForecast();
  17.         if (
  18.             !empty($forecast) &&
  19.             $forecast instanceof ForecastStaff
  20.         ) {
  21.             $this->manageDeclaration->generateDeclarationFromForecast($forecast);
  22.         }
  23.     }
  24. }