<?php

declare(strict_types=1);

namespace App\Command;

use App\Entity\Menu;
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: 'opengnsys:load-default-menu', description: 'Load the default menu')]
class LoadDefaultMenuCommand extends Command
{
    public function __construct(
        private readonly EntityManagerInterface $entityManager
    )
    {
        parent::__construct();
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $menu = new Menu();
        $menu->setName('Default menu');
        $menu->setResolution('791');
        $menu->setComments('Default menu comments');
        $menu->setPublicUrl('main');
        $menu->setIsDefault(true);

        $this->entityManager->persist($menu);
        $this->entityManager->flush();

        return Command::SUCCESS;
    }
}
