From 6ee0974b8b3b76646911074cc40a3ba02c27fecf Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Sun, 13 Oct 2024 23:13:38 +0200 Subject: [PATCH] ref: Not more useful --- .../AbstractFileStructureCommand.php | 68 ------------------- 1 file changed, 68 deletions(-) delete mode 100644 EMS/common-bundle/src/Command/FileStructure/AbstractFileStructureCommand.php diff --git a/EMS/common-bundle/src/Command/FileStructure/AbstractFileStructureCommand.php b/EMS/common-bundle/src/Command/FileStructure/AbstractFileStructureCommand.php deleted file mode 100644 index 70746e9d6..000000000 --- a/EMS/common-bundle/src/Command/FileStructure/AbstractFileStructureCommand.php +++ /dev/null @@ -1,68 +0,0 @@ -addArgument(self::ARGUMENT_IDENTIFIER, InputArgument::REQUIRED, 'Document identifier'); - $this - ->addOption(self::OPTION_TERM_FIELD, null, InputOption::VALUE_OPTIONAL, 'Term field used to get the document', '_id') - ->addOption(self::OPTION_STRUCTURE_FIELD, null, InputOption::VALUE_OPTIONAL, 'Document field path containing the JSON menu nested structure', 'structure') - ; - } - - protected function initialize(InputInterface $input, OutputInterface $output): void - { - parent::initialize($input, $output); - - $this->identifier = $this->getArgumentString(self::ARGUMENT_IDENTIFIER); - $this->termField = $this->getOptionString(self::OPTION_TERM_FIELD); - $this->structureField = $this->getOptionString(self::OPTION_STRUCTURE_FIELD); - } - - protected function getDocument(string $index): ?Result - { - $query = $this->elasticaService->getTermsQuery($this->termField, [$this->identifier]); - $search = $this->elasticaService->generateSearch([$index], $query); - $search->setSources([$this->structureField]); - $result = $this->elasticaService->search($search); - $result = $result->getResults(); - if (0 === \count($result)) { - $this->io->warning(\sprintf('Document %s=%s not found in index %s', $this->termField, $this->identifier, $index)); - - return null; - } - - if (\count($result) > 1) { - $this->io->warning(\sprintf('%d documents found for %s=%s in index %s', \count($result), $this->termField, $this->identifier, $index)); - - return null; - } - - return $result[0]; - } -}