예제 #1
0
 public function dispatch($params)
 {
     self::$_params = $params;
     $action = isset($params['action']) ? strtolower($params['action']) : 'none';
     unset($params['action']);
     // we don't need this to be sent to the API
     unset($params['_']);
     // the jQuery parameter preventing caching
     unset($params['debug']);
     // we don't need this to be sent to the API
     $result = array();
     switch ($action) {
         case 'vehicle':
         case 'year':
         case 'model':
         case 'assembly':
             $result = $this->processAssembly($params, $action);
             break;
         case 'part':
             $result = $this->processPart($params);
             break;
         case 'image':
             // site.url/arioem/index.php?action=image&brandCode=YAM&parentId=232390&assemblyId=204079&width=175&resizeBy=small
             $url = $this->processImage($params);
             if (@self::$_params['debug']) {
                 vd($url);
             }
             if ($url) {
                 header('Location: ' . $url);
                 die;
             } else {
                 header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
                 die;
             }
             break;
         case 'hash':
             $result = $this->processHash($params);
             break;
         case 'state':
             $result = $this->processState($params);
             break;
         case 'search':
             $result = $this->processSearch($params);
             $result['_request'] = self::$_params;
             break;
         case 'part-model-assemblies':
             $result = $this->processPartModelAssemblies($params);
             break;
         case 'part-models':
             $result = $this->processPartModels($params);
             break;
         case 'autocomplete':
             $result = $this->processAutocomplete($params);
             break;
             //			case 'test':
             //				$this->initSession();
             //				vd($_SESSION);
         //			case 'test':
         //				$this->initSession();
         //				vd($_SESSION);
         default:
             return false;
     }
     if (count($this->_warnings)) {
         $result['warnings'] = $this->_warnings;
     }
     if (@self::$_params['debug'] || @self::$_params['result']) {
         vd($result);
     }
     return $result;
 }