src/EventSubscriber/Import/Brugis.php line 23

Open in your IDE?
  1. <?php
  2. namespace App\EventSubscriber\Import;
  3. use App\Service\Import\CustomRowEvent;
  4. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  5. class Brugis implements EventSubscriberInterface
  6. {
  7.     /**
  8.      * @return array<string, mixed> The event names to listen to
  9.      */
  10.     public static function getSubscribedEvents()
  11.     {
  12.         return [
  13.             CustomRowEvent::NAME => ['customRow'],
  14.         ];
  15.     }
  16.     /**
  17.      * @return void
  18.      */
  19.     public function customRow(CustomRowEvent $event)
  20.     {
  21.         if ($event->getEntity() != \App\Entity\Brugis::class) {
  22.             return;
  23.         }
  24.         $row $event->getData();
  25.         foreach ($row as $k => $v) {
  26.             if ($v == 'N') {
  27.                 $row[$k] = 0;
  28.             }
  29.             if ($v == 'O') {
  30.                 $row[$k] = 1;
  31.             }
  32.         }
  33.         $event->setData($row);
  34.     }
  35. }