<?php
namespace App\Application\Internit\ChatbotLeadBundle\Twig;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Tupi\ContentBundle\Controller\MediaController;
use Tupi\ContentBundle\Controller\MenuController;
use Tupi\ContentBundle\Controller\PageController;
use Tupi\ContentBundle\Entity\Menu;
use Tupi\ContentBundle\Entity\Page;
use Tupi\ContentBundle\Types\PageStatusType;
use Tupi\SecurityBundle\Controller\SettingController;
use Twig_Extension;
use Twig_SimpleFilter;
use Twig_SimpleFunction;
use Twig_SimpleTest;
class ChatbotLeadExtension extends Twig_Extension
{
private $container;
private $bundle = 'ApplicationInternitChatbotLeadBundle:Lead';
//private $doctrine;
/**
* Constructor.
*
* @param ContainerInterface $container The service container
*/
public function __construct(ContainerInterface $container)
{
$this->container = $container;
$this->doctrine = $this->container->get('doctrine');
}
public function getFunctions()
{
return array(
new Twig_SimpleFunction('getChatbotLeads', array($this,'getChatbotLeads')),
new Twig_SimpleFunction('countChatbotLeadsPerRealEstate', array($this, 'countChatbotLeadsPerRealEstate')),
new Twig_SimpleFunction('getChatbotLeadsGroup', array($this,'getChatbotLeadsGroup')),
new Twig_SimpleFunction('getChatbotLeadsByGroup', array($this,'getChatbotLeadsByGroup')),
new Twig_SimpleFunction('getChatbotFiltroImobiliaria', array($this,'getChatbotFiltroImobiliaria')),
);
}
public function getChatbotLeads($idProduct)
{
if($idProduct){
$leads = $this->doctrine->getRepository($this->bundle)->findProductGroupedByOrigem($idProduct);
return $leads;
}
return false;
}
public function countChatbotLeadsPerRealEstate($idProduct)
{
if($idProduct){
$leads = $this->doctrine->getRepository($this->bundle)->countLeadsPerRealEstate($idProduct, 4);
return $leads;
}
return false;
}
public function getChatbotLeadsGroup($idProduct,$filter = [])
{
if($idProduct){
$groups = $this->doctrine->getRepository($this->bundle)->findAllGroups($idProduct, $filter);
// dump($groups);exit;
return $groups;
}
return false;
}
public function getChatbotLeadsByGroup($idProduct, $group,$filter = null)
{
if($idProduct && $group){
$groups = $this->doctrine->getRepository($this->bundle)->findLeadByGroup($idProduct, $group, $filter);
// dump($groups);exit;
return $groups;
}
return false;
}
public function getChatbotFiltroImobiliaria($idProduct){
if($idProduct){
$groups = $this->doctrine->getRepository($this->bundle)->findByOrigem($idProduct);
// dump($groups);exit;
return $groups;
}
return false;
}
public function twigInstanceof($object, $class)
{
$reflectionClass = new \ReflectionClass($class);
return $reflectionClass->isInstance($object);
}
public function getName()
{
return 'chatbot_lead_extension';
}
}