Code Duplication    Length = 33-40 lines in 3 locations

src/ElasticaExtraBundle/Command/CreateIndexCommand.php 1 location

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

src/ElasticaExtraBundle/Command/PutIndexSettingsCommand.php 1 location

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

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