getResourceByUri() public method

Get a resource by a uri
public getResourceByUri ( string $uri ) : Raml\Resource
$uri string
return Raml\Resource
コード例 #1
0
 /**
  * @param string $path
  * @return \Raml\Resource
  * @throws ValidatorSchemaException
  */
 private function getResource($path)
 {
     try {
         return $this->apiDefinition->getResourceByUri($path);
     } catch (ResourceNotFoundException $exception) {
         $message = sprintf('Schema for URI %s was not found in API definition', $path);
         throw new ValidatorSchemaException($message, 0, $exception);
     }
 }
コード例 #2
0
ファイル: RAML.php プロジェクト: RETFU/RREST
 /**
  * @param string $path
  *
  * @throw Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  *
  * @return \Raml\Resource|false
  */
 protected function getResourceFromPath($path)
 {
     try {
         $resource = $this->apiDefinition->getResourceByUri($path);
     } catch (ResourceNotFoundException $e) {
         //Try with a trailing slash to accept /resource/ and /ressource
         try {
             $resource = $this->apiDefinition->getResourceByUri($path . '/');
         } catch (ResourceNotFoundException $e) {
             throw new NotFoundHttpException($e->getMessage());
         }
     }
     return $resource;
 }