예제 #1
0
파일: RAML.php 프로젝트: RETFU/RREST
 /**
  * @param Raml\Resource $resource
  * @param string        $httpMethod
  *
  * @throw Symfony\Component\HttpKernel\Exception\MethodNotAllowedHttpException
  *
  * @return Raml\Method
  */
 protected function getMethodFromResource(Resource $resource, $httpMethod)
 {
     try {
         $httpMethod = strtoupper($httpMethod);
         $method = $resource->getMethod($httpMethod);
     } catch (\Exception $e) {
         $methods = [];
         foreach ($resource->getMethods() as $method) {
             $methods[] = $method->getType();
         }
         if ($httpMethod !== 'OPTIONS') {
             throw new MethodNotAllowedHttpException($methods, $e->getMessage());
         }
     }
     return $method;
 }