handleAlreadyDefinedForRoute() public static method

public static handleAlreadyDefinedForRoute ( RouteMetaData $route )
$route Drest\Mapping\RouteMetaData
示例#1
0
 /**
  * Process the method
  * @param $methods
  * @param Mapping\ClassMetaData $metadata
  * @throws DrestException
  */
 protected function processMethods($methods, Mapping\ClassMetaData $metadata)
 {
     // Set the handle calls
     foreach ($methods as $method) {
         /* @var \ReflectionMethod $method */
         if ($method->isPublic()) {
             foreach ($this->reader->getMethodAnnotations($method) as $methodAnnotation) {
                 if ($methodAnnotation instanceof Annotation\Handle) {
                     // Make sure the for is not empty
                     if (empty($methodAnnotation->for) || !is_string($methodAnnotation->for)) {
                         throw DrestException::handleForCannotBeEmpty();
                     }
                     if (($routeMetaData = $metadata->getRouteMetaData($methodAnnotation->for)) === false) {
                         throw DrestException::handleAnnotationDoesntMatchRouteName($methodAnnotation->for);
                     }
                     if ($routeMetaData->hasHandleCall()) {
                         // There is already a handle set for this route
                         throw DrestException::handleAlreadyDefinedForRoute($routeMetaData);
                     }
                     $routeMetaData->setHandleCall($method->getName());
                 }
             }
         }
     }
 }
示例#2
0
 /**
  * Process the method
  * @param $resource
  * @param Mapping\ClassMetaData $metadata
  * @throws DrestException
  */
 protected function processMethods($resource, Mapping\ClassMetaData $metadata)
 {
     /* @var \ReflectionMethod $method */
     foreach ($resource['routes'] as $route) {
         // Make sure the for is not empty
         if (!isset($route['name']) || !is_string($route['name'])) {
             throw DrestException::handleForCannotBeEmpty();
         }
         if (($routeMetaData = $metadata->getRouteMetaData($route['name'])) === false) {
             throw DrestException::handleAnnotationDoesntMatchRouteName($route['name']);
         }
         if ($routeMetaData->hasHandleCall()) {
             // There is already a handle set for this route
             throw DrestException::handleAlreadyDefinedForRoute($routeMetaData);
         }
         // Set the handle
         if (isset($route['handle_call'])) {
             $routeMetaData->setHandleCall($route['handle_call']);
         }
     }
 }