<?php

namespace App\DataFixtures;

use App\Entity\Sponsor;
use App\Entity\TypeEvent;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Bundle\FixturesBundle\Fixture;

class TypeEventFixtures extends Fixture
{
    public function load(ObjectManager $manager): void
    {
        $raw_typeevents = [

            [ "name" => "Spectacle" ],
            [ "name" => "Conférence" ],
            [ "name" => "Projection" ],
            [ "name" => "Atelier" ],
            [ "name" => "Artiste en résidence" ],
            [ "name" => "Spectacle-rencontre" ],

        ];

        $nb_data = count($raw_typeevents);
        // $i_ordre = 1;
        foreach ($raw_typeevents as $r_typeevent) {

            $name = $r_typeevent["name"];
            $is_spectacle = preg_match("/spectacle/", strtolower($name));

            $typeevent = new TypeEvent();
            $typeevent->setName($name)
                    ->setOnHomePage($is_spectacle)
                    ->setOnSpectaclePage($is_spectacle)
                    ->setOnOtherEventPage(!$is_spectacle)
                    ->setActive(true);
                    // ->setOrdre($i_ordre);

            $manager->persist($typeevent);
            // $i_ordre++;
        }

        $manager->flush();
    }
}
