MineTagsDataCommand.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace Muzich\CoreBundle\Command;
  3. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  4. use Symfony\Component\Console\Input\InputInterface;
  5. use Symfony\Component\Console\Output\OutputInterface;
  6. use Muzich\CoreBundle\Mining\Tag\TagMiner;
  7. class MineTagsDataCommand extends ContainerAwareCommand
  8. {
  9. protected $sitemap_content;
  10. protected $sitemap_urls;
  11. protected $router;
  12. protected $locales;
  13. protected $siteurl_prefix;
  14. protected $em;
  15. protected function configure()
  16. {
  17. $this
  18. ->setName('mining:tags')
  19. ->setDescription('Mine tags data')
  20. ;
  21. }
  22. /** @return TagMiner */
  23. protected function getTagMiner()
  24. {
  25. return $this->getContainer()->get('muzich.mining.tag.miner');
  26. }
  27. /** @return \Doctrine\ORM\EntityManager */
  28. protected function getEntityManager()
  29. {
  30. return $this->em;
  31. }
  32. protected function init()
  33. {
  34. $this->em = $this->getContainer()->get('doctrine')->getEntityManager();
  35. }
  36. protected function execute(InputInterface $input, OutputInterface $output)
  37. {
  38. $this->init();
  39. $tag_miner = $this->getTagMiner();
  40. $user_query_builder = $this->getEntityManager()->createQueryBuilder()->from('MuzichCoreBundle:User', 'user');
  41. $tag_miner->adaptQueryBuilderSelectorsForUser($user_query_builder, 'user');
  42. // $user_query_builder->where en fonction des inputes etc
  43. $this->getTagMiner()->mineTagsForUsers($user_query_builder->getQuery()->getResult());
  44. $output->writeln('<info>Terminé !</info>');
  45. }
  46. }