<?php

/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace App\Command;

use App\Entity\Contrat;
use App\Entity\Equipement;
use App\Entity\EquipementFamilleContrat;
use App\Entity\LockEntites;
use App\Entity\Site;
use App\Entity\User;
use App\Repository\UtilisateurRepository;
use App\Utils\Validator;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

/**
 * A console command that update clientprivilege in database
 *
 * To use this command, open a terminal window, enter into your project
 * directory and execute the following:
 *
 *     $ php bin/console app:delete-user
 *
 * Check out the code of the src/Command/AddUserCommand.php file for
 * the full explanation about Symfony commands.
 *
 * See https://symfony.com/doc/current/console.html
 *
 * @author Oleg Voronkovich <oleg-voronkovich@yandex.ru>
 */
class MajContratCommand extends Command
{
    protected static $defaultName = 'app:maj_expired_contrat';

    /** @var SymfonyStyle */
    private $entityManager;
    private $validator;

    public function __construct(EntityManagerInterface $em, Validator $validator)
    {
        parent::__construct();

        $this->entityManager = $em;
        $this->validator = $validator;
    }

    /**
     * {@inheritdoc}
     */
    protected function configure(): void
    {
        $this
            ->setDescription('Met à jour les contrats en cours');
    }

    protected function initialize(InputInterface $input, OutputInterface $output): void
    {
        // SymfonyStyle is an optional feature that Symfony provides so you can
        // apply a consistent look to the commands of your application.
        // See https://symfony.com/doc/current/console/style.html
        ini_set('memory_limit', '-1');
    }


    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $this->entityManager->getRepository(Contrat::class)->disableOldContrats();

        return Command::SUCCESS;
    }

}
