mergeMethodsDefault() public method

Merges the methods from $restRoute into the _method default of $optionsRoute.
public mergeMethodsDefault ( Symfony\Component\Routing\Route $optionsRoute, Symfony\Component\Routing\Route $restRoute ) : Symfony\Component\Routing\Route
$optionsRoute Symfony\Component\Routing\Route
$restRoute Symfony\Component\Routing\Route
return Symfony\Component\Routing\Route $optionsRoute with the methods from $restRoute in the _methods default
示例#1
0
 public function testMergeMethodsDefault()
 {
     $optionsRoute = new Route('', array('allowedMethods' => 'PUT,DELETE'));
     $restRoute = new Route('', array(), array(), array(), '', array(), array('GET', 'POST'));
     $mergedOptionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
     self::assertEquals('PUT,DELETE,GET,POST', $mergedOptionsRoute->getDefault('allowedMethods'));
     self::assertEquals($optionsRoute->getMethods(), $mergedOptionsRoute->getMethods());
 }
 /**
  * Iterates over $restRouteCollection, and returns the corresponding RouteCollection of OPTIONS REST routes
  *
  * @param RouteCollection $restRouteCollection
  * @return RouteCollection
  */
 public function mapCollection(RouteCollection $restRouteCollection)
 {
     $optionsRouteCollection = new RouteCollection();
     foreach ($restRouteCollection->all() as $restRoute) {
         $optionsRouteName = $this->mapper->getOptionsRouteName($restRoute);
         $optionsRoute = $optionsRouteCollection->get($optionsRouteName);
         if ($optionsRoute === null) {
             $optionsRoute = $this->mapper->mapRoute($restRoute);
         } else {
             $optionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
         }
         $optionsRouteCollection->add($optionsRouteName, $optionsRoute);
     }
     return $optionsRouteCollection;
 }