Code Duplication    Length = 40-41 lines in 2 locations

src/ElasticaExtraBundle/Command/ReindexCommand.php 1 location

@@ 15-55 (lines=41) @@
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class ReindexCommand extends ElasticaAwareCommand
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('elasticsearch:reindex')
24
            ->setDescription('Reindex an old index to the new one')
25
            ->addArgument('old-index', InputArgument::REQUIRED, 'Old index')
26
            ->addArgument('new-index', InputArgument::REQUIRED, 'New index')
27
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null)
28
        ;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $client = $this->getClient($input->getOption('client'));
37
        $oldIndex = $input->getArgument('old-index');
38
        $newIndex = $input->getArgument('new-index');
39
40
        $output->writeln(sprintf(
41
            '<info>Reindex <comment>%s</comment> to <comment>%s</comment></info>',
42
            $oldIndex,
43
            $newIndex
44
        ));
45
46
        $handler = $this
47
            ->getContainer()
48
            ->get('gbprod.elastica_extra.reindex_handler')
49
        ;
50
51
        $handler->handle($client, $oldIndex, $newIndex);
52
53
        $output->writeln('done');
54
    }
55
}
56

src/ElasticaExtraBundle/Command/RemoveAliasCommand.php 1 location

@@ 15-54 (lines=40) @@
12
 *
13
 * @author gbprod <[email protected]>
14
 */
15
class RemoveAliasCommand extends ElasticaAwareCommand
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        $this
23
            ->setName('elasticsearch:alias:remove')
24
            ->setDescription('Remove alias to an index')
25
            ->addArgument('index', InputArgument::REQUIRED, 'Which index ?')
26
            ->addArgument('alias', InputArgument::REQUIRED, 'Alias name')
27
            ->addOption('client', null, InputOption::VALUE_REQUIRED, 'Client to use (if not default)', null)
28
        ;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    protected function execute(InputInterface $input, OutputInterface $output)
35
    {
36
        $client  = $this->getClient($input->getOption('client'));
37
        $index   = $input->getArgument('index');
38
        $alias   = $input->getArgument('alias');
39
40
        $output->writeln(sprintf(
41
            '<info>Remove alias <comment>%s</comment> for index <comment>%s</comment></info>',
42
            $alias,
43
            $index
44
        ));
45
46
        $this
47
            ->getContainer()
48
            ->get('gbprod.elastica_extra.remove_alias_handler')
49
            ->handle($client, $index, $alias);
50
        ;
51
52
        $output->writeln('done');
53
    }
54
}
55