Example #1
0
 /**
  * Matches a user submitted path with parts defined by a map. Assigns and
  * returns an array of variables on a successful match.
  *
  * @param  string      $path Path used to match against this routing map
  * @return array|false An array of assigned values or a false on a mismatch
  */
 public function match($request, $partial = false)
 {
     if (!$request instanceof \Zend_Controller_Request_Http) {
         throw new \Zend_Controller_Router_Exception("Route needs a http request");
     }
     $return = parent::match($request->getPathInfo(), $partial);
     if (!$return) {
         return $return;
     }
     if (!($token = $return[$this->_tokenVariable])) {
         throw new \Zend_Controller_Router_Exception("Token not defined", 400);
     }
     if (!($tokenData = \Download\Service\DownloadTokenService::getInstance()->popToken($token))) {
         throw new \Zend_Controller_Router_Exception("Token does not exist or has expired", 400);
     }
     $return = array_merge($return, $tokenData->exportData());
     $return['downloadToken'] = $tokenData;
     $return['module'] = 'download';
     //Data defined inside token
     $return['controller'] = $tokenData->controller;
     $return['action'] = $tokenData->action;
     if (is_array($tokenData->params)) {
         $return += $tokenData->params;
     }
     return $return;
 }
 public function init()
 {
     $this->_downloadTokenSrv = Download\Service\DownloadTokenService::getInstance();
     $this->_reportSrv = ReportService::getInstance();
 }