EPESI BIM • Business Information Manager • Cloud CRM/ERP http://epe.si/ https://epe.si
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SearchClearCommand.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Epesi\Console;
  3. use Symfony\Component\Console\Command\Command;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. use Symfony\Component\Console\Style\SymfonyStyle;
  8. class SearchClearCommand extends Command
  9. {
  10. protected function configure()
  11. {
  12. $this
  13. ->setName('search:clear')
  14. ->setDescription('Clear search index')
  15. ->addArgument(
  16. 'recordset',
  17. InputArgument::OPTIONAL,
  18. 'Recordset name'
  19. );
  20. }
  21. protected function execute(InputInterface $input, OutputInterface $output)
  22. {
  23. $st = new SymfonyStyle($input, $output);
  24. $recordset = $input->getArgument('recordset');
  25. $recordsets = \DB::GetAssoc('SELECT tab, tab FROM recordbrowser_table_properties WHERE search_include>0');
  26. if ($recordset && !isset($recordsets[$recordset])) {
  27. $st->error('Invalid recordset.');
  28. $st->writeln('Use one of the following:');
  29. $st->listing($recordsets);
  30. return;
  31. }
  32. $st->writeln("Clearing search index...");
  33. if ($recordset) {
  34. \Utils_RecordBrowserCommon::clear_search_index($recordset);
  35. } else {
  36. $st->progressStart(count($recordsets));
  37. foreach ($recordsets as $tab) {
  38. \Utils_RecordBrowserCommon::clear_search_index($tab);
  39. $st->progressAdvance();
  40. }
  41. $st->progressFinish();
  42. }
  43. $st->writeln("done!");
  44. }
  45. }