src/Application/Internit/ChatbotLeadBundle/Twig/ChatbotLeadExtension.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Application\Internit\ChatbotLeadBundle\Twig;
  3. use Symfony\Component\DependencyInjection\ContainerInterface;
  4. use Tupi\ContentBundle\Controller\MediaController;
  5. use Tupi\ContentBundle\Controller\MenuController;
  6. use Tupi\ContentBundle\Controller\PageController;
  7. use Tupi\ContentBundle\Entity\Menu;
  8. use Tupi\ContentBundle\Entity\Page;
  9. use Tupi\ContentBundle\Types\PageStatusType;
  10. use Tupi\SecurityBundle\Controller\SettingController;
  11. use Twig_Extension;
  12. use Twig_SimpleFilter;
  13. use Twig_SimpleFunction;
  14. use Twig_SimpleTest;
  15. class ChatbotLeadExtension extends Twig_Extension
  16. {
  17.     private $container;
  18.     private $bundle 'ApplicationInternitChatbotLeadBundle:Lead';
  19.     //private $doctrine;
  20.     /**
  21.      * Constructor.
  22.      *
  23.      * @param ContainerInterface $container The service container
  24.      */
  25.     public function __construct(ContainerInterface $container)
  26.     {
  27.         $this->container $container;
  28.         $this->doctrine $this->container->get('doctrine');
  29.     }
  30.     public function getFunctions()
  31.     {
  32.         return array(            
  33.             new Twig_SimpleFunction('getChatbotLeads', array($this,'getChatbotLeads')),
  34.             new Twig_SimpleFunction('countChatbotLeadsPerRealEstate', array($this'countChatbotLeadsPerRealEstate')),
  35.             new Twig_SimpleFunction('getChatbotLeadsGroup', array($this,'getChatbotLeadsGroup')),
  36.             new Twig_SimpleFunction('getChatbotLeadsByGroup', array($this,'getChatbotLeadsByGroup')),
  37.             new Twig_SimpleFunction('getChatbotFiltroImobiliaria', array($this,'getChatbotFiltroImobiliaria')),
  38.         );
  39.     }
  40.     public function getChatbotLeads($idProduct)
  41.     {
  42.         if($idProduct){
  43.             $leads $this->doctrine->getRepository($this->bundle)->findProductGroupedByOrigem($idProduct);
  44.             
  45.             return $leads;
  46.         }
  47.         return false;
  48.     }
  49.     public function countChatbotLeadsPerRealEstate($idProduct)
  50.     {
  51.         if($idProduct){
  52.             $leads $this->doctrine->getRepository($this->bundle)->countLeadsPerRealEstate($idProduct4);
  53.             
  54.             return $leads;
  55.         }
  56.         return false;
  57.     }
  58.     public function getChatbotLeadsGroup($idProduct,$filter = [])
  59.     {
  60.         if($idProduct){
  61.             $groups $this->doctrine->getRepository($this->bundle)->findAllGroups($idProduct$filter);
  62.             // dump($groups);exit;
  63.             return $groups;
  64.         }
  65.         return false;
  66.     }
  67.     
  68.     public function getChatbotLeadsByGroup($idProduct$group,$filter null)
  69.     {
  70.         if($idProduct && $group){
  71.             $groups $this->doctrine->getRepository($this->bundle)->findLeadByGroup($idProduct$group$filter);
  72.             // dump($groups);exit;
  73.             return $groups;
  74.         }
  75.         return false;
  76.     }
  77.     public function getChatbotFiltroImobiliaria($idProduct){
  78.         if($idProduct){
  79.             $groups $this->doctrine->getRepository($this->bundle)->findByOrigem($idProduct);
  80.             // dump($groups);exit;
  81.             return $groups;
  82.         }
  83.         return false;
  84.     }
  85.     public function twigInstanceof($object$class)
  86.     {
  87.         $reflectionClass = new \ReflectionClass($class);
  88.         return $reflectionClass->isInstance($object);
  89.     }
  90.     public function getName()
  91.     {
  92.         return 'chatbot_lead_extension';
  93.     }
  94. }