Example #1
0
 /**
  * @param Request $request
  * @return array
  */
 private function parsePath(Request $request)
 {
     $parts = $this->parsePathParts($request);
     $path = '/' . implode('/', $parts);
     $ramlDoc = $this->docNavigator->getDoc();
     $method = strtolower($request->getMethod());
     if (!$ramlDoc->isDefined($method, $path)) {
         $allowedMethods = $ramlDoc->getAllowedMethods($path, CASE_UPPER);
         $message = sprintf(self::ERROR_ACTION_NOT_ALLOWED, implode(', ', $allowedMethods));
         throw new ActionNotAllowedException($allowedMethods, $message);
     }
     return $path;
 }
 /**
  * @return array
  * @throws ResourceEntityMappingException
  * @todo The configuration doesn't actually allow overridding resource type to entity class mappings as the error message suggests. Oops.
  */
 public function map()
 {
     if ($this->mapCache->isFresh()) {
         return $this->mapCache->read();
     }
     $map = [];
     foreach ($this->docNavigator->getDoc()->getResources() as $type) {
         $resourceClasses = $this->getResourceClasses($type);
         if (1 < count($resourceClasses)) {
             $message = sprintf(self::ERROR_ENTITIES_PER_RESOURCE, $type, implode(', ', $resourceClasses));
             throw new ResourceEntityMappingException($message);
         }
         $map[$type] = reset($resourceClasses);
     }
     $this->mapCache->keep($map);
     return $map;
 }