Skip to content
Snippets Groups Projects
Commit 16315766 authored by Jonathan Foucher's avatar Jonathan Foucher
Browse files

cs-fix

parent 25d41d43
No related branches found
No related tags found
No related merge requests found
Pipeline #57857 failed
......@@ -4,19 +4,6 @@ namespace App\Domain\AIPD\Command;
use App\Domain\AIPD\Model\ModeleAnalyse;
use App\Domain\AIPD\Model\ModeleScenarioMenace;
use App\Domain\Maturity\Repository\Survey as SurveyRepository;
use App\Domain\Notification\Event\ConformiteTraitementNeedsAIPDEvent;
use App\Domain\Notification\Event\LateActionEvent;
use App\Domain\Notification\Event\LateRequestEvent;
use App\Domain\Notification\Event\LateSurveyEvent;
use App\Domain\Notification\Event\NoLoginEvent;
use App\Domain\Registry\Model\ConformiteTraitement\ConformiteTraitement;
use App\Domain\Registry\Model\Mesurement;
use App\Domain\Registry\Model\TreatmentDataCategory;
use App\Domain\User\Repository\User as UserRepository;
use App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement\ConformiteTraitement as ConformiteTraitementRepository;
use App\Infrastructure\ORM\Registry\Repository\Mesurement as MesurementRepository;
use App\Infrastructure\ORM\Registry\Repository\Request as RequestRepository;
use Doctrine\ORM\EntityManagerInterface;
use JMS\Serializer\SerializerBuilder;
use Symfony\Component\Console\Command\Command;
......@@ -24,7 +11,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class ImportModelCommand extends Command
{
......@@ -34,7 +20,6 @@ class ImportModelCommand extends Command
private SymfonyStyle $io;
private EntityManagerInterface $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
parent::__construct();
......@@ -60,7 +45,7 @@ class ImportModelCommand extends Command
protected function importAIPDModel(string $file): int
{
$this->io->title('Importing AIPD model from '.$file);
$this->io->title('Importing AIPD model from ' . $file);
$content = file_get_contents($file);
$serializer = SerializerBuilder::create()->build();
/** @var ModeleAnalyse $object */
......@@ -70,17 +55,18 @@ class ImportModelCommand extends Command
$existing = $this->entityManager->getRepository(ModeleAnalyse::class)->findBy(['nom' => $object->getNom(), 'description' => $object->getDescription()]);
if (count($existing)) {
$this->io->warning('AIPD model "'.$object->getNom(). '" already exists');
$this->io->warning('AIPD model "' . $object->getNom() . '" already exists');
return 0;
}
$sm = [];
foreach ($object->getScenarioMenaces() as $scenarioMenace) {
$this->io->writeln('Importing scenario menace '.$scenarioMenace->getNom());
$this->io->writeln('Importing scenario menace ' . $scenarioMenace->getNom());
/** @var ModeleScenarioMenace $scenarioMenace */
$mesures = [];
foreach ($scenarioMenace->getMesuresProtections() as $mesureProtection) {
$this->io->writeln('Importing $mesureProtection '.$mesureProtection->getNom());
$this->io->writeln('Importing $mesureProtection ' . $mesureProtection->getNom());
// Check if this mesure already exists
$mm = $this->entityManager->find(\App\Domain\AIPD\Model\ModeleMesureProtection::class, $mesureProtection->getId());
if ($mm) {
......
......@@ -2,22 +2,7 @@
namespace App\Domain\Maturity\Command;
use App\Domain\AIPD\Model\ModeleAnalyse;
use App\Domain\AIPD\Model\ModeleScenarioMenace;
use App\Domain\Maturity\Model\Referentiel;
use App\Domain\Maturity\Repository\Survey as SurveyRepository;
use App\Domain\Notification\Event\ConformiteTraitementNeedsAIPDEvent;
use App\Domain\Notification\Event\LateActionEvent;
use App\Domain\Notification\Event\LateRequestEvent;
use App\Domain\Notification\Event\LateSurveyEvent;
use App\Domain\Notification\Event\NoLoginEvent;
use App\Domain\Registry\Model\ConformiteTraitement\ConformiteTraitement;
use App\Domain\Registry\Model\Mesurement;
use App\Domain\Registry\Model\TreatmentDataCategory;
use App\Domain\User\Repository\User as UserRepository;
use App\Infrastructure\ORM\Registry\Repository\ConformiteTraitement\ConformiteTraitement as ConformiteTraitementRepository;
use App\Infrastructure\ORM\Registry\Repository\Mesurement as MesurementRepository;
use App\Infrastructure\ORM\Registry\Repository\Request as RequestRepository;
use Doctrine\ORM\EntityManagerInterface;
use JMS\Serializer\SerializerBuilder;
use Symfony\Component\Console\Command\Command;
......@@ -25,7 +10,6 @@ use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Finder\Finder;
class ImportReferentielCommand extends Command
......@@ -36,7 +20,6 @@ class ImportReferentielCommand extends Command
private SymfonyStyle $io;
private EntityManagerInterface $entityManager;
public function __construct(EntityManagerInterface $entityManager)
{
parent::__construct();
......@@ -56,7 +39,7 @@ class ImportReferentielCommand extends Command
$this->io = new SymfonyStyle($input, $output);
$finder = new Finder();
$finder->files()->in( $input->getArgument('folder'));
$finder->files()->in($input->getArgument('folder'));
if ($finder->hasResults()) {
foreach ($finder as $file) {
......@@ -64,13 +47,12 @@ class ImportReferentielCommand extends Command
}
}
return Command::SUCCESS;
}
protected function importReferentiel(string $file): int
{
$this->io->title('Importing Référentiel from '.$file);
$this->io->title('Importing Référentiel from ' . $file);
$content = file_get_contents($file);
$serializer = SerializerBuilder::create()->build();
/** @var Referentiel $object */
......@@ -80,14 +62,15 @@ class ImportReferentielCommand extends Command
$existing = $this->entityManager->getRepository(Referentiel::class)->findBy(['name' => $object->getName()]);
if (count($existing)) {
$this->io->warning('Référentiel "'.$object->getName(). '" already exists');
$this->io->warning('Référentiel "' . $object->getName() . '" already exists');
return 0;
}
$object->setCreatedAt(new \DateTimeImmutable());
$this->entityManager->persist($object);
$this->entityManager->flush();
$this->io->success('Référentiel "'.$object->getName(). '" imported');
$this->io->success('Référentiel "' . $object->getName() . '" imported');
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment