function testFindByLevel()
 {
     $vehicle = $this->createMMY();
     $yearId = $vehicle->getValue('year');
     $finder = new VF_Vehicle_Finder(new VF_Schema());
     $this->getReadAdapter()->getProfiler()->clear();
     $this->getReadAdapter()->getProfiler()->setEnabled(true);
     $finder->findByLevel('year', $yearId);
     $finder->findByLevel('year', $yearId);
     $finder->findByLevel('year', $yearId);
     $finder->findByLevel('year', $yearId);
     $queries = $this->getReadAdapter()->getProfiler()->getQueryProfiles();
     $this->assertTrue(count($queries) <= 2);
 }
Beispiel #2
0
 function getDefinitions()
 {
     VF_Singleton::getInstance()->storeFitInSession();
     if ($this->lastLevelAlreadySelected()) {
         return array();
     }
     $vehicles = array();
     $vehicleFinder = new VF_Vehicle_Finder($this->getSchema());
     foreach ($this->getItems() as $level) {
         $vehicle = $vehicleFinder->findByLevel($level->getType(), $level->getId());
         array_push($vehicles, $vehicle);
     }
     return $vehicles;
 }
Beispiel #3
0
 function doVehicleSelection()
 {
     if ($this->shouldClear()) {
         $this->clearSelection();
         return array();
     }
     $vehicleFinder = new VF_Vehicle_Finder($this->schema);
     // Multi-tree (admin panel) integration
     if ($this->request->getParam('fit')) {
         $id = $this->getId();
         if (!$id) {
             return false;
         }
         return $vehicleFinder->findByLevel($this->getLevel(), $id);
     }
     if (!$this->hasGETRequest() && !$this->hasSESSIONRequest()) {
         return array();
     }
     // front-end lookup
     try {
         $params = $this->vehicleRequestParams();
         if (isset($params['year_start']) && isset($params['year_end'])) {
             $vehicles = $vehicleFinder->findByRangeIds($params);
         } else {
             $vehicles = $vehicleFinder->findByLevelIds($params, VF_Vehicle_Finder::INCLUDE_PARTIALS);
         }
         return $vehicles;
     } catch (VF_Exception_DefinitionNotFound $e) {
         return false;
     }
 }