MyServicesController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 65
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 1
A overviewAction() 0 16 1
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
namespace OpenConext\ProfileBundle\Controller;
20
21
use OpenConext\Profile\Api\AuthenticatedUserProviderInterface;
22
use OpenConext\ProfileBundle\Service\SpecifiedConsentListService;
23
use OpenConext\ProfileBundle\Security\Guard;
24
use Psr\Log\LoggerInterface;
25
use Symfony\Component\HttpFoundation\Response;
26
use Symfony\Component\Templating\EngineInterface;
27
28
class MyServicesController
29
{
30
    /**
31
     * @var EngineInterface
32
     */
33
    private $templateEngine;
34
35
    /**
36
     * @var SpecifiedConsentListService
37
     */
38
    private $specifiedConsentListService;
39
40
    /**
41
     * @var AuthenticatedUserProviderInterface
42
     */
43
    private $authenticatedUserProvider;
44
45
    /**
46
     * @var Guard
47
     */
48
    private $guard;
49
50
    /**
51
     * @var LoggerInterface
52
     */
53
    private $logger;
54
55
    /**
56
     * @param EngineInterface $templateEngine
57
     * @param AuthenticatedUserProviderInterface $authenticatedUserProvider
58
     * @param SpecifiedConsentListService $specifiedConsentListService
59
     * @param Guard $guard
60
     * @param LoggerInterface $logger
61
     */
62
    public function __construct(
63
        EngineInterface $templateEngine,
64
        AuthenticatedUserProviderInterface $authenticatedUserProvider,
65
        SpecifiedConsentListService $specifiedConsentListService,
66
        Guard $guard,
67
        LoggerInterface $logger
68
    ) {
69
        $this->templateEngine              = $templateEngine;
70
        $this->authenticatedUserProvider   = $authenticatedUserProvider;
71
        $this->specifiedConsentListService = $specifiedConsentListService;
72
        $this->guard                       = $guard;
73
        $this->logger                      = $logger;
74
    }
75
76
    public function overviewAction()
77
    {
78
        $this->guard->userIsLoggedIn();
79
80
        $this->logger->notice('User requested My Services page');
81
82
        $user                 = $this->authenticatedUserProvider->getCurrentUser();
83
        $specifiedConsentList = $this->specifiedConsentListService->getListFor($user);
84
85
        $this->logger->notice(sprintf('Showing %s services on My Services page', count($specifiedConsentList)));
86
87
        return new Response($this->templateEngine->render(
88
            'OpenConextProfileBundle:MyServices:overview.html.twig',
89
            ['specifiedConsentList' => $specifiedConsentList]
90
        ));
91
    }
92
}
93