public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $startYear = date("Y", strtotime("-30 year"));
     $endYear = date('Y');
     $rmcHelperObj = new RmcHelpers();
     $builder->add('ad', AdPostType::class, array('label' => ' '))->add('mileage', 'number', array('required' => false))->add('model')->add('commercialVehicleType', null, array('label' => 'Commercial Vehicle Type'))->add('mfgYear', 'choice', array('label' => 'Manufacturing Year', 'choices' => $rmcHelperObj->getYears($startYear, $endYear), 'multiple' => false, 'required' => true, 'expanded' => false))->add('owners')->add('salvage')->add('conditions')->add('color')->add('fuelType')->add('capacity')->add('commercialVehicleEquipment', null, array('label' => 'Commercial Vehicle Equipments', 'expanded' => true))->add('fuelConsumption')->add('vin', 'number', array('required' => false))->add('power');
 }
Пример #2
0
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $startYear = date("Y", strtotime("-30 year"));
     $endYear = date('Y');
     $rmcHelperObj = new RmcHelpers();
     $builder->add('ad', AdPostType::class, array('label' => ' '))->add('mileage', 'number', array('required' => false))->add('engineSize', 'number', array('required' => false))->add('carType')->add('mfgYear', 'choice', array('label' => 'Manufacturing Year', 'choices' => $rmcHelperObj->getYears($startYear, $endYear), 'multiple' => false, 'required' => true, 'expanded' => false))->add('owners')->add('salvage')->add('doors', 'choice', array('label' => 'Doors', 'choices' => $rmcHelperObj->getDoors(), 'multiple' => false, 'required' => true, 'expanded' => false))->add('conditions')->add('seats', 'choice', array('label' => 'Doors', 'choices' => $rmcHelperObj->getSeats(), 'multiple' => false, 'required' => true, 'expanded' => false))->add('color')->add('fuelType')->add('capacity')->add('tuvValidity')->add('carEquipments', null, array('expanded' => true))->add('transmission')->add('gearType')->add('fuelConsumption')->add('displacement')->add('vin', 'number', array('required' => false))->add('power')->add('emission')->add('airConditioner');
 }
 /**
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $params = $request->get('search');
     $vertical = NULL;
     /* SEO */
     $url_parsed = parse_url($request->getUri());
     $url_path = $url_parsed['path'];
     if (isset($url_parsed['query'])) {
         $url_path .= '?' . $url_parsed['query'];
     }
     $post_parameters = $this->getPostParameters($request);
     $adSearchUrl = $this->get('rmc_core.ad_search_url_service');
     $adSearchUrl->parseUrl($url_path, $post_parameters);
     $urlFilters = $adSearchUrl->getFilters();
     $niceUrl = $adSearchUrl->getNiceUrlByFilters($urlFilters);
     $filters = $adSearchUrl->getNiceFilters();
     // redirect to smart url
     if ($adSearchUrl->is302 && $niceUrl != '/') {
         return $this->redirect($this->container->get('kernel')->getEnvironment() == 'dev' ? '/app_dev.php' . $niceUrl : $niceUrl);
     }
     //print_r($filters);exit;
     //echo 'NICE URL '.$adSearchUrl->getNiceUrlAdding(array('category1' => 2), $filters);
     if (isset($filters['vertical'])) {
         $vertical = $em->getRepository('Entity:Vertical')->find($filters['vertical']);
     }
     $searchManager = AdSearchFactory::getSearchManager($this->container, $vertical ? $vertical->getCode() : '');
     // choose based on search parameter otherwise use 'Ad'
     $filters['select'] = array('id');
     $filters['facet'] = true;
     // display the total number of documents found by solr
     $query = $searchManager->getSolrSearchService()->getQueryByCriteria($filters, NULL, true);
     $solrRegistry = $this->get('solarium.client_registry');
     $client = $solrRegistry->getClient('rmcslave');
     $pager = array($client, $query);
     $paginator = $this->get('knp_paginator');
     $resultset = $paginator->paginate($pager, $request->get('page', 1), $request->get('page_range', 10));
     $resultsetFacet = $resultset->getCustomParameter('result');
     $documents = $resultset->getItems();
     $data = $resultset->getPaginationData();
     $facets = $searchManager->getSolrSearchService()->getFacetFields($resultsetFacet);
     $facetBuilder = new AdSearchFacetBulderService($this->getDoctrine()->getManager(), $facets, $adSearchUrl);
     $niceFacets = $facetBuilder->getNiceFacets();
     //print_r($niceFacets);exit;
     //echo $documents->getTotalItemCount();exit;
     //echo 'NumFound: '.$resultset->getNumFound();exit;
     /*
             foreach ($documents as $doc)
             {
                 echo 'ID '.$doc->id."<br />";
             }*/
     $ids = RmcHelpers::getPrimaryKeys($documents);
     $ads = $em->getRepository('Entity:Ad')->findById($ids);
     $noLayout = $request->headers->get('X-PJAX') ? true : false;
     if ($noLayout) {
         return $this->render('RmcCoreAdSearchBundle:Default:pjaxIndex.html.twig', array('ads' => $ads, 'documents' => $documents, 'paginator' => $resultset, 'facetFields' => $niceFacets, 'noLayout' => $noLayout));
     } else {
         return $this->render('RmcCoreAdSearchBundle:Default:index.html.twig', array('ads' => $ads, 'documents' => $documents, 'paginator' => $resultset, 'facetFields' => $niceFacets, 'noLayout' => $noLayout));
     }
 }
 /**
  * update slug into slug table by type
  *
  * @param integer $type slug type
  * @param object  $em   entity manager object
  *
  * @return void
  */
 public function updateSlugByType($type, $em)
 {
     $objects = $em->getRepository('Entity:' . $this->slugableEntity[$type])->findAll();
     $query = $em->getRepository('Entity:' . $this->slugableEntity[$type])->createQueryBuilder('obj')->getQuery();
     $query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker');
     $query->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, 'en_GB');
     $objects = $query->getResult();
     foreach ($objects as $object) {
         $slugObj = $em->getRepository('Entity:Slug')->findOneBy(array('type' => $type, 'objectId' => $object->getId()));
         if (!$slugObj) {
             $slug = new Slug();
             $slug->setType($type);
             $slug->setObjectId($object->getId());
             $this->setSlug($slug, RmcHelpers::slugify($object->getName()), $em);
             $em->persist($slug);
             $em->flush();
             echo 'slug inserted type ' . $type . ' For ' . $object->getName() . "\n";
         } else {
             echo 'slug already exists ' . $object->getName() . "\n";
         }
     }
 }