<?php

declare(strict_types=1);

namespace App\DataFixtures;

use App\Entity\AbsenceType;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;

final class AbsenceTypeFixtures extends Fixture
{
    public function load(ObjectManager $manager): void
    {
        $definitions = [
            [FixtureReferences::ABSENCE_TYPE_RTT, 'R', 'RTT', '#feba01', false],
            [FixtureReferences::ABSENCE_TYPE_CONGE, 'C', 'CONGÉ', '#008000', true],
            [FixtureReferences::ABSENCE_TYPE_MALADIE, 'M', 'MALADIE', '#ed07da', true],
            [FixtureReferences::ABSENCE_TYPE_AT, 'AT', 'ACCIDENT DE TRAVAIL', '#e41111', true],
            [FixtureReferences::ABSENCE_TYPE_FORMATION, 'F', 'FORMATION', '#6c72e0', true],
            [FixtureReferences::ABSENCE_TYPE_EXCEPTIONNEL, 'EX', 'CONGE EXCEPTIONNEL', '#8834ae', true],
            [FixtureReferences::ABSENCE_TYPE_ABSENT, 'ABS', 'ABSENT', '#823a21', false],
            [FixtureReferences::ABSENCE_TYPE_AUTRE, 'AUT', 'AUTRE', '#f07d60', true],
        ];

        foreach ($definitions as [$reference, $code, $label, $color, $countAsWorkedHours]) {
            $absenceType = new AbsenceType()
                ->setCode($code)
                ->setLabel($label)
                ->setColor($color)
                ->setCountAsWorkedHours($countAsWorkedHours)
            ;
            $manager->persist($absenceType);
            $this->addReference($reference, $absenceType);
        }

        $manager->flush();
    }
}
