Skip to content

Commit 18727bc

Browse files
authored
Merge pull request #130 from massiveart/enhancement/command-default-name
Add command default names
2 parents debf625 + 11cbf3d commit 18727bc

File tree

7 files changed

+44
-29
lines changed

7 files changed

+44
-29
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
CHANGELOG
22
=========
33

4+
* 0.17.3 (2019-08-22)
5+
* ENHANCEMENT #130 Add command default names
6+
47
* 0.17.2 (2019-08-20)
58
* ENHANCEMENT #129 Added dispatching of pre-deindex event
69
* ENHANCEMENT #127 Custom repository method bugfix

Command/IndexRebuildCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
*/
2121
class IndexRebuildCommand extends ReindexCommand
2222
{
23-
/**
24-
* {@inheritdoc}
25-
*/
23+
protected static $defaultName = 'massive:search:index:rebuild';
24+
2625
public function configure()
2726
{
2827
parent::configure();
29-
$this->setName('massive:search:index:rebuild');
28+
29+
$this->setName(self::$defaultName);
3030
}
3131

3232
/**

Command/InitCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@
2121
*/
2222
class InitCommand extends Command
2323
{
24+
protected static $defaultName = 'massive:search:init';
25+
2426
/**
2527
* @var AdapterInterface
2628
*/
2729
private $adapter;
2830

2931
public function __construct(AdapterInterface $adapter)
3032
{
31-
parent::__construct();
33+
parent::__construct(self::$defaultName);
34+
3235
$this->adapter = $adapter;
3336
}
3437

3538
public function configure()
3639
{
37-
$this->setName('massive:search:init');
3840
$this->setDescription('Initializes the search bundle');
3941
$this->setHelp('This command will simply call the initialize method of the currently active search adapter.');
4042
}

Command/PurgeCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
class PurgeCommand extends Command
2626
{
27+
protected static $defaultName = 'massive:search:purge';
28+
2729
/**
2830
* @var SearchManagerInterface
2931
*/
@@ -38,14 +40,14 @@ public function __construct(
3840
SearchManagerInterface $searchManager,
3941
QuestionHelper $questionHelper = null
4042
) {
41-
parent::__construct();
43+
parent::__construct(self::$defaultName);
44+
4245
$this->searchManager = $searchManager;
4346
$this->questionHelper = $questionHelper ?: new QuestionHelper();
4447
}
4548

4649
public function configure()
4750
{
48-
$this->setName('massive:search:purge');
4951
$this->setDescription('Purge one, many or all indexes.');
5052
$this->setHelp(<<<'EOT'
5153
Purge one, many or all indexes:

Command/QueryCommand.php

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@
2424
*/
2525
class QueryCommand extends Command
2626
{
27+
protected static $defaultName = 'massive:search:query';
28+
2729
/**
2830
* @var SearchManagerInterface
2931
*/
3032
private $searchManager;
3133

32-
public function __construct(
33-
SearchManagerInterface $searchManager
34-
) {
35-
parent::__construct();
34+
public function __construct(SearchManagerInterface $searchManager)
35+
{
36+
parent::__construct(self::$defaultName);
37+
3638
$this->searchManager = $searchManager;
3739
}
3840

@@ -41,12 +43,12 @@ public function __construct(
4143
*/
4244
public function configure()
4345
{
44-
$this->setName('massive:search:query');
4546
$this->addArgument('query', InputArgument::REQUIRED, 'Search query');
4647
$this->addOption('index', 'I', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Index to search');
4748
$this->addOption('locale', 'l', InputOption::VALUE_REQUIRED, 'Index to search');
4849
$this->setDescription('Search the using a given query');
49-
$this->setHelp(<<<'EOT'
50+
$this->setHelp(
51+
<<<'EOT'
5052
The %command.name_full% command will search the configured repository and present
5153
the results.
5254
@@ -72,15 +74,17 @@ public function execute(InputInterface $input, OutputInterface $output)
7274
$table->setHeaders(['Score', 'ID', 'Title', 'Description', 'Url', 'Image', 'Class']);
7375
foreach ($hits as $hit) {
7476
$document = $hit->getDocument();
75-
$table->addRow([
76-
$hit->getScore(),
77-
$document->getId(),
78-
$document->getTitle(),
79-
$this->truncate($document->getDescription(), 50),
80-
$document->getUrl(),
81-
$document->getImageUrl(),
82-
$document->getClass(),
83-
]);
77+
$table->addRow(
78+
[
79+
$hit->getScore(),
80+
$document->getId(),
81+
$document->getTitle(),
82+
$this->truncate($document->getDescription(), 50),
83+
$document->getUrl(),
84+
$document->getImageUrl(),
85+
$document->getClass(),
86+
]
87+
);
8488
}
8589
$table->render();
8690
$output->writeln(sprintf('%s result(s) in %fs', count($hits), $timeElapsed));

Command/ReindexCommand.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
class ReindexCommand extends Command
3434
{
35+
protected static $defaultName = 'massive:search:reindex';
36+
3537
/**
3638
* @var string
3739
*/
@@ -64,7 +66,8 @@ public function __construct(
6466
$env,
6567
QuestionHelper $questionHelper = null
6668
) {
67-
parent::__construct();
69+
parent::__construct(self::$defaultName);
70+
6871
$this->resumeManager = $resumeManager;
6972
$this->searchManager = $searchManager;
7073
$this->providerRegistry = $providerRegistry;
@@ -77,7 +80,6 @@ public function __construct(
7780
*/
7881
public function configure()
7982
{
80-
$this->setName('massive:search:reindex');
8183
$this->setDescription('Rebuild search index');
8284
$this->setHelp(<<<'EOT'
8385
This command will launch an event will trigger the search index to be rebuilt

Command/StatusCommand.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
use Massive\Bundle\SearchBundle\Search\SearchManager;
1515
use Massive\Bundle\SearchBundle\Search\SearchManagerInterface;
16-
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
16+
use Symfony\Component\Console\Command\Command;
1717
use Symfony\Component\Console\Helper\Table;
1818
use Symfony\Component\Console\Input\InputInterface;
1919
use Symfony\Component\Console\Output\OutputInterface;
@@ -22,22 +22,24 @@
2222
* This command returns some vendor specific information about
2323
* the currently configured search implementation.
2424
*/
25-
class StatusCommand extends ContainerAwareCommand
25+
class StatusCommand extends Command
2626
{
27+
protected static $defaultName = 'massive:search:status';
28+
2729
/**
2830
* @var SearchManager
2931
*/
3032
private $searchManager;
3133

3234
public function __construct(SearchManagerInterface $searchManager)
3335
{
34-
parent::__construct();
36+
parent::__construct(self::$defaultName);
37+
3538
$this->searchManager = $searchManager;
3639
}
3740

3841
public function configure()
3942
{
40-
$this->setName('massive:search:status');
4143
$this->setDescription('Return the status of the configured search engine');
4244
$this->setHelp(<<<'EOT'
4345
Return detailed information about the current search implementation

0 commit comments

Comments
 (0)