fork download
  1. <?php
  2.  
  3. namespace test\FilterBundle\Controller;
  4.  
  5. use Symfony\Bundle\FrameworkBundle\Controller\Controller;
  6. use Symfony\Component\HttpFoundation\Request;
  7. use test\FilterBundle\Entity\Production;
  8. use test\FilterBundle\Entity\TM;
  9. use test\FilterBundle\Entity\type;
  10.  
  11. class filter
  12. {
  13. public function buildSql($request)
  14. {
  15. $get = $request->query->all();
  16.  
  17.  
  18. return $get;
  19. }
  20. }
  21.  
  22.  
  23. class FilterController extends Controller
  24. {
  25. public function indexAction(Request $request)
  26. {
  27.  
  28. $get = new filter();
  29. $get = $get->buildSql($request);
  30.  
  31.  
  32. $em = $this->getDoctrine()->getEntityManager();
  33. $qb = $em->createQueryBuilder();
  34.  
  35. $cookies = $request->cookies;
  36. $cookies = $cookies->get('sort');
  37. $qb
  38. ->select('c')
  39. ->from('test\FilterBundle\Entity\Production', 'c');
  40. if (isset($get['TM']) and count($get['TM']) > 1) {
  41. $qb
  42. ->where('c.TM IN (:value)')
  43. ->setParameter('value', $get['TM']);
  44. } elseif (isset($get['TM']) and count($get['TM']) == 1) {
  45. $qb
  46. ->where('c.TM = :value')
  47. ->setParameter('value', $get['TM']);
  48. };
  49. if (isset($get['type']) and count($get['type']) > 1) {
  50. $qb
  51. ->andWhere('c.type IN (:value2)')
  52. ->setParameter('value2', $get['type']);
  53. } elseif (isset($get['type']) and count($get['type']) == 1) {
  54. $qb
  55. ->andWhere('c.type = :value2')
  56. ->setParameter('value2', $get['type']);
  57. };
  58. if (isset($cookies)) {
  59. if ($cookies == 0) {
  60. $cookies = 'ASC';
  61. } elseif ($cookies == 1) {
  62. $cookies = 'desc';
  63. }
  64. $qb
  65. ->addOrderBy('c.price', $cookies);
  66. }
  67. $result = $qb
  68. ->getQuery()
  69. ->getResult();
  70.  
  71. $type = $this->getDoctrine()
  72. ->getRepository('testFilterBundle:type')
  73. ->findAll();
  74.  
  75.  
  76. foreach ($type as $key => $value) {
  77. if (isset($get['type'])) {
  78. foreach ($get['type'] as $key2 => $value2) {
  79. if ($value->id == $value2) {
  80. $value->checked = 'checked';
  81. }
  82. }
  83. }
  84. }
  85.  
  86.  
  87. $TM = $this->getDoctrine()
  88. ->getRepository('testFilterBundle:TM')
  89. ->findAll();
  90. foreach ($TM as $key => $value) {
  91. if (isset($get['TM'])) {
  92. foreach ($get['TM'] as $key2 => $value2) {
  93. if ($value->id == $value2) {
  94. $value->checked = 'checked';
  95. }
  96. }
  97. }
  98. }
  99. $url = $this->get('request_stack')->getMasterRequest();
  100. return $this->render(
  101. 'testFilterBundle:Default:index.html.twig',
  102. 'products' => $result,
  103. 'get' => $get,
  104. 'type' => $type,
  105. 'TM' => $TM,
  106. 'qb' => $qb,
  107. 'cookie' => $cookies,
  108. 'url' => $url)
  109. );
  110. }
  111. }
  112.  
Runtime error #stdin #stdout #stderr 0.02s 24400KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Class 'Symfony\Bundle\FrameworkBundle\Controller\Controller' not found in /home/B3AYpv/prog.php on line 24