eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\Mapper::getOptionsRouteName PHP Method

getOptionsRouteName() public method

Returns the OPTIONS name of a REST route.
public getOptionsRouteName ( Symfony\Component\Routing\Route $route ) : string
$route Symfony\Component\Routing\Route Route
return string
    public function getOptionsRouteName(Route $route)
    {
        $name = str_replace('/', '_', $route->getPath());
        return 'ezpublish_rest_options_' . trim($name, '_');
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\Mapper::getOptionsRouteName