Completed
Push — ezp26297-rest_embedding_http_c... ( 123323 )
by
unknown
80:28 queued 54:58
created

URLAliasController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
dl 0
loc 55
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 4

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A loadURLAlias() 0 11 2
A listGlobalURLAliases() 0 4 1
A listLocationURLAliases() 0 12 1
A createURLAlias() 0 4 1
A deleteURLAlias() 0 4 1
1
<?php
2
3
/**
4
 * File containing the URLAlias controller class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 *
9
 * @version //autogentag//
10
 */
11
namespace eZ\Publish\Core\REST\Server\HttpCache\Controller;
12
13
use eZ\Publish\API\Repository\Values\Content\URLAlias as URLAliasValue;
14
use eZ\Publish\Core\REST\Server\Values\CachedValue;
15
use Symfony\Component\HttpFoundation\Request;
16
17
class URLAliasController extends AbstractController
18
{
19
    /**
20
     * @var \eZ\Publish\Core\REST\Server\Controller\URLAlias
21
     */
22
    protected $innerController;
23
24
    /**
25
     * @param \eZ\Publish\Core\REST\Server\Controller\Location $innerController
26
     */
27
    public function __construct($innerController)
28
    {
29
        $this->innerController = $innerController;
0 ignored issues
show
Documentation Bug introduced by
It seems like $innerController of type object<eZ\Publish\Core\R...er\Controller\Location> is incompatible with the declared type object<eZ\Publish\Core\R...er\Controller\URLAlias> of property $innerController.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
    }
31
32
    public function loadURLAlias($urlAliasId)
33
    {
34
        $urlAlias = $this->innerController->loadURLAlias($urlAliasId);
35
36
        return $urlAlias->type === URLAliasValue::LOCATION ? new CachedValue(
37
            $urlAlias,
38
            [
39
                'location' => $urlAlias->destination
40
            ]
41
        ) : $urlAlias;
42
    }
43
44
    public function listGlobalURLAliases()
45
    {
46
        return $this->innerController->listGlobalURLAliases();
47
    }
48
49
    public function listLocationURLAliases($locationPath, Request $request)
50
    {
51
        $aliasesRefList = $this->innerController->listLocationURLAliases($locationPath, $request);
52
        $pathArray = explode('/', trim($locationPath, '/'));
53
54
        return new CachedValue(
55
            $aliasesRefList,
56
            [
57
                'location' => array_pop($pathArray),
58
            ]
59
        );
60
    }
61
62
    public function createURLAlias(Request $request)
63
    {
64
        return $this->innerController->createURLAlias($request);
65
    }
66
67
    public function deleteURLAlias($urlAliasId)
68
    {
69
        return $this->innerController->deleteURLAlias($urlAliasId);
70
    }
71
}
72