|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* Copyright 2017 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\Value\AttributeAggregation\AttributeAggregationEnabledAttributes; |
|
22
|
|
|
use OpenConext\Profile\Value\EmailAddress; |
|
23
|
|
|
use OpenConext\ProfileBundle\Security\Guard; |
|
24
|
|
|
use OpenConext\ProfileBundle\Service\AttributeAggregationService; |
|
25
|
|
|
use OpenConext\ProfileBundle\Service\AuthenticatedUserProvider; |
|
26
|
|
|
use Psr\Log\LoggerInterface; |
|
27
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
28
|
|
|
use Symfony\Component\Templating\EngineInterface; |
|
29
|
|
|
|
|
30
|
|
|
class MyConnectionsController |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var EngineInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
private $templateEngine; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var Guard |
|
39
|
|
|
*/ |
|
40
|
|
|
private $guard; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @var LoggerInterface |
|
44
|
|
|
*/ |
|
45
|
|
|
private $logger; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* @var AttributeAggregationService |
|
49
|
|
|
*/ |
|
50
|
|
|
private $service; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* @var AuthenticatedUserProvider |
|
54
|
|
|
*/ |
|
55
|
|
|
private $userProvider; |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @var EmailAddress |
|
59
|
|
|
*/ |
|
60
|
|
|
private $mailTo; |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @param EngineInterface $templateEngine |
|
64
|
|
|
* @param Guard $guard |
|
65
|
|
|
* @param LoggerInterface $logger |
|
66
|
|
|
* @param AttributeAggregationService $service |
|
67
|
|
|
* @param AuthenticatedUserProvider $userProvider |
|
68
|
|
|
*/ |
|
69
|
|
|
public function __construct( |
|
70
|
|
|
EngineInterface $templateEngine, |
|
71
|
|
|
Guard $guard, |
|
72
|
|
|
LoggerInterface $logger, |
|
73
|
|
|
AttributeAggregationService $service, |
|
74
|
|
|
AuthenticatedUserProvider $userProvider, |
|
75
|
|
|
EmailAddress $mailTo |
|
76
|
|
|
) { |
|
77
|
|
|
$this->templateEngine = $templateEngine; |
|
78
|
|
|
$this->guard = $guard; |
|
79
|
|
|
$this->logger = $logger; |
|
80
|
|
|
$this->service = $service; |
|
81
|
|
|
$this->userProvider = $userProvider; |
|
82
|
|
|
$this->mailTo = $mailTo; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* @return Response |
|
87
|
|
|
*/ |
|
88
|
|
|
public function overviewAction() |
|
89
|
|
|
{ |
|
90
|
|
|
$this->guard->userIsLoggedIn(); |
|
91
|
|
|
$this->logger->notice('Showing My Connections page'); |
|
92
|
|
|
|
|
93
|
|
|
|
|
94
|
|
|
$user = $this->userProvider->getCurrentUser(); |
|
95
|
|
|
$attributes = $this->service->findByUser($user); |
|
96
|
|
|
|
|
97
|
|
|
return new Response($this->templateEngine->render( |
|
98
|
|
|
'OpenConextProfileBundle:MyConnections:overview.html.twig', |
|
99
|
|
|
[ |
|
100
|
|
|
'orcid' => $attributes->getAttributes()[0], |
|
101
|
|
|
'mailTo' => $this->mailTo->getEmailAddress(), |
|
102
|
|
|
] |
|
103
|
|
|
)); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
|