<?php

declare(strict_types=1);

namespace App\Command\Import;

use App\Entity\Event;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

#[AsCommand(
    name: 'app:create-events',
    description: 'Creates events'
)]
class CreateEventsCommand extends Command
{

    public function __construct(
        private readonly EntityManagerInterface $entityManager
    ) {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $event = new Event();
        $event->setName('EEZ In');
        $event->setIdentifier('eez');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('EEZ Out');
        $event->setIdentifier('eez');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Watch Start');
        $event->setIdentifier('watch');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Watch Stop');
        $event->setIdentifier('watch');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('3nm In');
        $event->setIdentifier('3nm');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('3nm Out');
        $event->setIdentifier('3nm');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Arrival to port');
        $event->setIdentifier('port');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Departure from port');
        $event->setIdentifier('port');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Anchor Start');
        $event->setIdentifier('anchor');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Anchor Stop');
        $event->setIdentifier('anchor');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Drifting Start');
        $event->setIdentifier('drifting');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Drifting Stop');
        $event->setIdentifier('drifting');
        $event->setSequence(2);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Port canceled');
        $event->setIdentifier('port_canceled');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $event = new Event();
        $event->setName('Port amended');
        $event->setIdentifier('port_amended');
        $event->setSequence(1);
        $this->entityManager->persist($event);

        $this->entityManager->flush();
        return Command::SUCCESS;
    }
}