Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

RouteCollectionMapper.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader;
8
9 use Symfony\Component\Routing\RouteCollection;
10
16 class RouteCollectionMapper
17 {
19 protected $mapper;
20
21 public function __construct(Mapper $mapper)
22 {
23 $this->mapper = $mapper;
24 }
25
33 public function mapCollection(RouteCollection $restRouteCollection)
34 {
35 $optionsRouteCollection = new RouteCollection();
36
37 foreach ($restRouteCollection->all() as $restRoute) {
38 $optionsRouteName = $this->mapper->getOptionsRouteName($restRoute);
39
40 $optionsRoute = $optionsRouteCollection->get($optionsRouteName);
41 if ($optionsRoute === null) {
42 $optionsRoute = $this->mapper->mapRoute($restRoute);
43 } else {
44 $optionsRoute = $this->mapper->mergeMethodsDefault($optionsRoute, $restRoute);
45 }
46
47 $optionsRouteCollection->add($optionsRouteName, $optionsRoute);
48 }
49
50 return $optionsRouteCollection;
51 }
52 }
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\Mapper
Maps a standard REST route to its OPTIONS equivalent.
Definition: Bundle/EzPublishRestBundle/Routing/OptionsLoader/Mapper.php:15
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\RouteCollectionMapper
Maps a REST routes collection to the corresponding set of REST OPTIONS routes.
Definition: RouteCollectionMapper.php:17
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\RouteCollectionMapper\__construct
__construct(Mapper $mapper)
Definition: RouteCollectionMapper.php:21
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\RouteCollectionMapper\$mapper
$mapper
Definition: RouteCollectionMapper.php:19
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader\RouteCollectionMapper\mapCollection
mapCollection(RouteCollection $restRouteCollection)
Iterates over $restRouteCollection, and returns the corresponding RouteCollection of OPTIONS REST rou...
Definition: RouteCollectionMapper.php:33
eZ\Bundle\EzPublishRestBundle\Routing\OptionsLoader
Definition: Bundle/EzPublishRestBundle/Routing/OptionsLoader/Mapper.php:7
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.