Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 5eb225a3 authored by Arnaud Bey's avatar Arnaud Bey
Browse files

delete lexicon command interactive

parent f68423d7
......@@ -2,25 +2,25 @@
namespace LexiconBundle\Command;
use LexiconBundle\Manager\ImportManager;
use LexiconBundle\Entity\Language;
use LexiconBundle\Entity\Root;
use LexiconBundle\Entity\Word;
use LexiconBundle\Entity\WordStart;
use MagicWordBundle\Entity\Grid;
use LexiconBundle\Manager\ImportManager;
use MagicWordBundle\Entity\FoundableForm;
use MagicWordBundle\Entity\Game;
use MagicWordBundle\Entity\Grid;
use MagicWordBundle\Entity\Objective;
use MagicWordBundle\Entity\Round;
use MagicWordBundle\Entity\Score;
use MagicWordBundle\Entity\Wordbox\Acquisition;
use MagicWordBundle\Entity\WrongForm;
use MagicWordBundle\Entity\FoundableForm;
use MagicWordBundle\Entity\Objective;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Question\Question;
use Symfony\Component\Filesystem\Filesystem;
class DeleteLexiconCommand extends ContainerAwareCommand
{
......@@ -28,23 +28,29 @@ class DeleteLexiconCommand extends ContainerAwareCommand
{
$this
->setName('lexicon:delete')
->setDescription('Delete lexicon from db & bigram.txt files')
->addArgument('id_lexicon', InputArgument::REQUIRED, 'id of lexicon you want to delete');
->setDescription('Delete lexicon from db & bigram.txt files');
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getEntityManager('default');
$idLexicon = $input->getArgument('id_lexicon');
$helper = $this->getHelper('question');
$question = new Question("Please enter the ID of the lexicon \n");
$languages = $em->getRepository(Language::class)->findAll();
foreach ($languages as $language) {
$output->writeln('<comment>'.$language->getId()." > ".$language->getValue().'</comment>');
}
$idLexicon = $helper->ask($input, $output, $question);
if ($idLexicon) {
$language = $em->getRepository(Language::class)->find($idLexicon);
if ($language) {
$output->writeln('<info>############ SUPPRESSION LANGUE #############</info>');
echo "Suppression ".$language->getValue();
$output->writeln('<comment>Suppression acquisitions</comment>');
echo "Suppression ".$language->getValue()."\n";
$em->getRepository(Acquisition::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression acquisitions</comment>');
......@@ -68,7 +74,6 @@ class DeleteLexiconCommand extends ContainerAwareCommand
$em->getRepository(Game::class)->deleteByLanguage($language);
$output->writeln('<comment>Suppression game ok</comment>');
// delete grid
$rounds = $em->getRepository(Round::class)->findByLanguage($language);
foreach ($rounds as $round) {
......@@ -119,10 +124,6 @@ class DeleteLexiconCommand extends ContainerAwareCommand
$output->writeln('<info>########### SUPPRESSION LANGUE OK ############</info>');
} else {
$output->writeln('<comment>Pas de langue avec cet ID</comment>');
$languages = $em->getRepository(Language::class)->findAll();
foreach ($languages as $language) {
$output->writeln('<comment>'.$language->getId()." > ".$language->getValue().'</comment>');
}
}
} else {
echo 'Argument missing (language id)';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment