/**
  * Main function, called for both encoding and deconding of URLs.
  * Based on the "mode" key in the $params array it branches out to either decode or encode functions.
  *
  * @param array $params Parameters passed from parent object, "tx_realurl". Some values are passed by reference! (paramKeyValues, pathParts and pObj)
  * @param tx_realurl $parent Copy of parent object. Not used.
  * @return mixed Depends on branching.
  */
 public function main(array $params, tx_realurl $parent)
 {
     // Setting internal variables
     $this->pObj = $parent;
     $this->conf = $params['conf'];
     $this->extConf = $this->pObj->getConfiguration();
     // Branching out based on type
     $result = false;
     switch ((string) $params['mode']) {
         case 'encode':
             $this->IDtoPagePath($params['paramKeyValues'], $params['pathParts']);
             $result = NULL;
             break;
         case 'decode':
             $result = $this->pagePathtoID($params['pathParts']);
             break;
     }
     return $result;
 }