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

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
    public function mergeMethodsDefault(Route $optionsRoute, Route $restRoute)
    {
        $mergedRoute = clone $optionsRoute;
        $mergedRoute->setDefault('allowedMethods', implode(',', array_unique(array_merge(explode(',', $optionsRoute->getDefault('allowedMethods')), $restRoute->getMethods()))));
        return $mergedRoute;
    }

Usage Example

 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());
 }
All Usage Examples Of eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\Mapper::mergeMethodsDefault