Example #1
0
 /**
  * Select the mapping used to process the selection path for this request.
  *
  * If no mapping can be identified, create an error response and return null.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request The kernel request we are
  * processing
  * @param \Symfony\Component\HttpFoundation\Response $response The kernel response we are
  * creating
  * @param string $path The portion of the request URI for selecting a mapping
  * @return \Phruts\Config\ActionConfig
  */
 protected function processMapping(\Symfony\Component\HttpFoundation\Request $request, \Symfony\Component\HttpFoundation\Response $response, $path)
 {
     // Is there a directly defined mapping for this path?
     $mapping = $this->moduleConfig->findActionConfig($path);
     if (!is_null($mapping)) {
         $request->attributes->set(\Phruts\Util\Globals::MAPPING_KEY, $mapping);
         return $mapping;
     }
     // Locate the mapping for unknown paths (if any)
     $configs = $this->moduleConfig->findActionConfigs();
     foreach ($configs as $config) {
         if ($config->getUnknown()) {
             $request->attributes->set(\Phruts\Util\Globals::MAPPING_KEY, $config);
             return $config;
         }
     }
     // No mapping can be found to process this request
     $internal = $this->getInternal();
     if (!empty($internal)) {
         $msg = $this->getInternal()->getMessage(null, 'processInvalid', $path);
     } else {
         $msg = 'processInvalid';
     }
     if (!empty($this->log)) {
         $this->log->error($msg);
     }
     throw new BadRequestHttpException($msg);
 }