Completed
Push — 1.8 ( 8d6730...a2d9e7 )
by
unknown
42:28
created

OldOptionsRouteOptionsResolver::resolve()   B

Complexity

Conditions 5
Paths 10

Size

Total Lines 24
Code Lines 15

Duplication

Lines 15
Ratio 62.5 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 15
loc 24
c 1
b 0
f 0
rs 8.5125
cc 5
eloc 15
nc 10
nop 2
1
<?php
2
3
namespace OroCRM\Bundle\MagentoBundle\Routing;
4
5
use Symfony\Component\Routing\Route;
6
7
use Oro\Component\Routing\Resolver\RouteCollectionAccessor;
8
use Oro\Component\Routing\Resolver\RouteOptionsResolverInterface;
9
10
/**
11
 * As FOSRestBundle v1.7.1 generates a plural path for OPTIONS routes,
12
 * we need to add a single path to avoid BC break.
13
 * The single path is marked as deprecated.
14
 *
15
 * @deprecated since 1.8. Will be removed in 2.0
16
 */
17
class OldOptionsRouteOptionsResolver implements RouteOptionsResolverInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function resolve(Route $route, RouteCollectionAccessor $routes)
23
    {
24 View Code Duplication
        if ($route->getPath() === '/magento/order/view/{id}') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
            $singleRoute = $routes->cloneRoute($route);
26
            $singleRoute->setPath('/magentoorder/view/{id}');
27
            $routes->append('orocrm_magentoorder_view', $singleRoute);
28
        }
29
30
        if (!in_array('GET', $route->getMethods(), true)) {
31
            return;
32
        }
33
34 View Code Duplication
        if ($route->getPath() === '/api/rest/{version}/carts/{id}.{_format}') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
            $singleRoute = $routes->cloneRoute($route);
36
            $singleRoute->setPath('/api/rest/{version}/magentocarts/{id}.{_format}');
37
            $routes->append('oro_api_get_magentocarts', $singleRoute);
38
        }
39
40 View Code Duplication
        if ($route->getPath() === '/api/rest/{version}/orders/{id}.{_format}') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
41
            $singleRoute = $routes->cloneRoute($route);
42
            $singleRoute->setPath('/api/rest/{version}/magentoorders/{id}.{_format}');
43
            $routes->append('oro_api_get_magentoorders', $singleRoute);
44
        }
45
    }
46
}
47