2424 */
2525class 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'
5052The %command.name_full% command will search the configured repository and present
5153the 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 ));
0 commit comments