Skip to content

Commit 82a311b

Browse files
committed
Rename class to prevent duplicated class name in different namespaces
Signed-off-by: Vitor Mattos <[email protected]>
1 parent fb70735 commit 82a311b

File tree

8 files changed

+88
-88
lines changed

8 files changed

+88
-88
lines changed

lib/Listener/MailNotifyListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
use OCA\Libresign\Db\SignRequest;
2929
use OCA\Libresign\Db\SignRequestMapper;
3030
use OCA\Libresign\Events\SendSignNotificationEvent;
31-
use OCA\Libresign\Service\IdentifyMethod\IdentifyMethodService;
31+
use OCA\Libresign\Service\IdentifyMethod\IdentifyService;
3232
use OCA\Libresign\Service\IdentifyMethod\IIdentifyMethod;
3333
use OCA\Libresign\Service\MailService;
3434
use OCP\EventDispatcher\Event;
@@ -42,7 +42,7 @@ class MailNotifyListener implements IEventListener {
4242
public function __construct(
4343
protected IUserSession $userSession,
4444
protected IUserManager $userManager,
45-
protected IdentifyMethodService $identifyMethodService,
45+
protected IdentifyService $identifyService,
4646
protected MailService $mail,
4747
private SignRequestMapper $signRequestMapper,
4848
private LoggerInterface $logger,

lib/Service/IdentifyMethod/AbstractIdentifyMethod.php

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ abstract class AbstractIdentifyMethod implements IIdentifyMethod {
4848
*/
4949
protected array $signatureMethods = [];
5050
public function __construct(
51-
protected IdentifyMethodService $identifyMethodService,
51+
protected IdentifyService $identifyService,
5252
) {
5353
$className = (new \ReflectionClass($this))->getShortName();
5454
$this->name = lcfirst($className);
@@ -107,9 +107,9 @@ public function notify(): bool {
107107
if (!$this->willNotify) {
108108
return false;
109109
}
110-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
111-
$libresignFile = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId());
112-
$this->identifyMethodService->getEventDispatcher()->dispatchTyped(new SendSignNotificationEvent(
110+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
111+
$libresignFile = $this->identifyService->getFileMapper()->getById($signRequest->getFileId());
112+
$this->identifyService->getEventDispatcher()->dispatchTyped(new SendSignNotificationEvent(
113113
$signRequest,
114114
$libresignFile,
115115
$this
@@ -131,35 +131,35 @@ public function validateToIdentify(): void {
131131
}
132132

133133
protected function throwIfFileNotFound(): void {
134-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
135-
$fileEntity = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId());
134+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
135+
$fileEntity = $this->identifyService->getFileMapper()->getById($signRequest->getFileId());
136136

137137
$nodeId = $fileEntity->getNodeId();
138138

139-
$mountsContainingFile = $this->identifyMethodService->getUserMountCache()->getMountsForFileId($nodeId);
139+
$mountsContainingFile = $this->identifyService->getUserMountCache()->getMountsForFileId($nodeId);
140140
foreach ($mountsContainingFile as $fileInfo) {
141-
$this->identifyMethodService->getRootFolder()->getByIdInPath($nodeId, $fileInfo->getMountPoint());
141+
$this->identifyService->getRootFolder()->getByIdInPath($nodeId, $fileInfo->getMountPoint());
142142
}
143-
$fileToSign = $this->identifyMethodService->getRootFolder()->getById($nodeId);
143+
$fileToSign = $this->identifyService->getRootFolder()->getById($nodeId);
144144
if (count($fileToSign) < 1) {
145145
throw new LibresignException(json_encode([
146146
'action' => JSActions::ACTION_DO_NOTHING,
147-
'errors' => [$this->identifyMethodService->getL10n()->t('File not found')],
147+
'errors' => [$this->identifyService->getL10n()->t('File not found')],
148148
]));
149149
}
150150
}
151151

152152
protected function throwIfMaximumValidityExpired(): void {
153-
$maximumValidity = (int) $this->identifyMethodService->getAppConfig()->getAppValue('maximum_validity', (string) SessionService::NO_MAXIMUM_VALIDITY);
153+
$maximumValidity = (int) $this->identifyService->getAppConfig()->getAppValue('maximum_validity', (string) SessionService::NO_MAXIMUM_VALIDITY);
154154
if ($maximumValidity <= 0) {
155155
return;
156156
}
157-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
158-
$now = $this->identifyMethodService->getTimeFactory()->getTime();
157+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
158+
$now = $this->identifyService->getTimeFactory()->getTime();
159159
if ($signRequest->getCreatedAt() + $maximumValidity < $now) {
160160
throw new LibresignException(json_encode([
161161
'action' => JSActions::ACTION_DO_NOTHING,
162-
'errors' => [$this->identifyMethodService->getL10n()->t('Link expired.')],
162+
'errors' => [$this->identifyService->getL10n()->t('Link expired.')],
163163
]));
164164
}
165165
}
@@ -168,46 +168,46 @@ protected function throwIfInvalidToken(): void {
168168
if (empty($this->codeSentByUser)) {
169169
return;
170170
}
171-
if (!$this->identifyMethodService->getHasher()->verify($this->codeSentByUser, $this->getEntity()->getCode())) {
172-
throw new LibresignException($this->identifyMethodService->getL10n()->t('Invalid code.'));
171+
if (!$this->identifyService->getHasher()->verify($this->codeSentByUser, $this->getEntity()->getCode())) {
172+
throw new LibresignException($this->identifyService->getL10n()->t('Invalid code.'));
173173
}
174174
}
175175

176176
protected function renewSession(): void {
177-
$this->identifyMethodService->getSessionService()->setIdentifyMethodId($this->getEntity()->getId());
178-
$renewalInterval = (int) $this->identifyMethodService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL);
177+
$this->identifyService->getSessionService()->setIdentifyMethodId($this->getEntity()->getId());
178+
$renewalInterval = (int) $this->identifyService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL);
179179
if ($renewalInterval <= 0) {
180180
return;
181181
}
182-
$this->identifyMethodService->getSessionService()->resetDurationOfSignPage();
182+
$this->identifyService->getSessionService()->resetDurationOfSignPage();
183183
}
184184

185185
protected function updateIdentifiedAt(): void {
186186
if ($this->getEntity()->getCode() && !$this->getEntity()->getIdentifiedAtDate()) {
187187
return;
188188
}
189-
$this->getEntity()->setIdentifiedAtDate($this->identifyMethodService->getTimeFactory()->getDateTime());
189+
$this->getEntity()->setIdentifiedAtDate($this->identifyService->getTimeFactory()->getDateTime());
190190
$this->willNotify = false;
191-
$this->identifyMethodService->save($this->getEntity());
191+
$this->identifyService->save($this->getEntity());
192192
$this->notify();
193193
}
194194

195195
protected function throwIfRenewalIntervalExpired(): void {
196-
$renewalInterval = (int) $this->identifyMethodService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL);
196+
$renewalInterval = (int) $this->identifyService->getAppConfig()->getAppValue('renewal_interval', (string) SessionService::NO_RENEWAL_INTERVAL);
197197
if ($renewalInterval <= 0) {
198198
return;
199199
}
200-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
201-
$startTime = $this->identifyMethodService->getSessionService()->getSignStartTime();
200+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
201+
$startTime = $this->identifyService->getSessionService()->getSignStartTime();
202202
$createdAt = $signRequest->getCreatedAt();
203203
$lastAttempt = $this->getEntity()->getLastAttemptDate()?->format('U');
204204
$lastActionDate = max(
205205
$startTime,
206206
$createdAt,
207207
$lastAttempt,
208208
);
209-
$now = $this->identifyMethodService->getTimeFactory()->getTime();
210-
$this->identifyMethodService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Times', [
209+
$now = $this->identifyService->getTimeFactory()->getTime();
210+
$this->identifyService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Times', [
211211
'renewalInterval' => $renewalInterval,
212212
'startTime' => $startTime,
213213
'createdAt' => $createdAt,
@@ -216,13 +216,13 @@ protected function throwIfRenewalIntervalExpired(): void {
216216
'now' => $now,
217217
]);
218218
if ($lastActionDate + $renewalInterval < $now) {
219-
$this->identifyMethodService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Exception');
219+
$this->identifyService->getLogger()->debug('AbstractIdentifyMethod::throwIfRenewalIntervalExpired Exception');
220220
$blur = new Blur($this->getEntity()->getIdentifierValue());
221221
throw new LibresignException(json_encode([
222222
'action' => $this->getRenewAction(),
223223
// TRANSLATORS title that is displayed at screen to notify the signer that the link to sign the document expired
224-
'title' => $this->identifyMethodService->getL10n()->t('Link expired'),
225-
'body' => $this->identifyMethodService->getL10n()->t(<<<'BODY'
224+
'title' => $this->identifyService->getL10n()->t('Link expired'),
225+
'body' => $this->identifyService->getL10n()->t(<<<'BODY'
226226
The link to sign the document has expired.
227227
We will send a new link to the email %1$s.
228228
Click below to receive the new link and be able to sign the document.
@@ -231,7 +231,7 @@ protected function throwIfRenewalIntervalExpired(): void {
231231
),
232232
'uuid' => $signRequest->getUuid(),
233233
// TRANSLATORS Button to renew the link to sign the document. Renew is the action to generate a new sign link when the link expired.
234-
'renewButton' => $this->identifyMethodService->getL10n()->t('Renew'),
234+
'renewButton' => $this->identifyService->getL10n()->t('Renew'),
235235
]));
236236
}
237237
}
@@ -245,15 +245,15 @@ private function getRenewAction(): int {
245245
}
246246

247247
protected function throwIfAlreadySigned(): void {
248-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
249-
$fileEntity = $this->identifyMethodService->getFileMapper()->getById($signRequest->getFileId());
248+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
249+
$fileEntity = $this->identifyService->getFileMapper()->getById($signRequest->getFileId());
250250
if ($fileEntity->getStatus() === FileEntity::STATUS_SIGNED
251251
|| (!is_null($signRequest) && $signRequest->getSigned())
252252
) {
253253
throw new LibresignException(json_encode([
254254
'action' => JSActions::ACTION_REDIRECT,
255-
'errors' => [$this->identifyMethodService->getL10n()->t('File already signed.')],
256-
'redirect' => $this->identifyMethodService->getUrlGenerator()->linkToRoute(
255+
'errors' => [$this->identifyService->getL10n()->t('File already signed.')],
256+
'redirect' => $this->identifyService->getUrlGenerator()->linkToRoute(
257257
'libresign.page.validationFile',
258258
['uuid' => $signRequest->getUuid()]
259259
),
@@ -287,7 +287,7 @@ private function overrideImmutable(array $immutable): void {
287287
}
288288

289289
private function loadSavedSettings(): void {
290-
$config = $this->identifyMethodService->getSavedSettings();
290+
$config = $this->identifyService->getSavedSettings();
291291
$this->settings = array_reduce($config, function ($carry, $config) {
292292
if ($config['name'] === $this->name) {
293293
return $config;
@@ -319,12 +319,12 @@ private function applyDefault(array $customConfig, array $default): array {
319319
}
320320

321321
public function save(): void {
322-
$this->identifyMethodService->save($this->getEntity());
322+
$this->identifyService->save($this->getEntity());
323323
$this->notify();
324324
}
325325

326326
public function delete(): void {
327-
$this->identifyMethodService->delete($this->getEntity());
327+
$this->identifyService->delete($this->getEntity());
328328
}
329329

330330
private function removeKeysThatDontExists(array $default): void {

lib/Service/IdentifyMethod/Account.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444

4545
class Account extends AbstractIdentifyMethod {
4646
public function __construct(
47-
protected IdentifyMethodService $identifyMethodService,
47+
protected IdentifyService $identifyService,
4848
private IUserManager $userManager,
4949
private IEventDispatcher $eventDispatcher,
5050
private IdentifyMethodMapper $identifyMethodMapper,
@@ -61,21 +61,21 @@ public function __construct(
6161
private EmailToken $emailToken,
6262
) {
6363
// TRANSLATORS Name of possible authenticator method. This signalize that the signer could be identified by Nextcloud acccount
64-
$this->friendlyName = $this->identifyMethodService->getL10n()->t('Account');
64+
$this->friendlyName = $this->identifyService->getL10n()->t('Account');
6565
$this->signatureMethods = [
6666
$this->password->getName() => $this->password,
6767
$this->clickToSign->getName() => $this->clickToSign,
6868
$this->emailToken->getName() => $this->emailToken,
6969
];
7070
parent::__construct(
71-
$identifyMethodService,
71+
$identifyService,
7272
);
7373
}
7474

7575
public function validateToRequest(): void {
7676
$signer = $this->userManager->get($this->entity->getIdentifierValue());
7777
if (!$signer) {
78-
throw new LibresignException($this->identifyMethodService->getL10n()->t('User not found.'));
78+
throw new LibresignException($this->identifyService->getL10n()->t('User not found.'));
7979
}
8080
}
8181

@@ -100,7 +100,7 @@ private function getSigner(): IUser {
100100
if (empty($signer) || count($signer) > 1) {
101101
throw new LibresignException(json_encode([
102102
'action' => JSActions::ACTION_DO_NOTHING,
103-
'errors' => [$this->identifyMethodService->getL10n()->t('Invalid user')],
103+
'errors' => [$this->identifyService->getL10n()->t('Invalid user')],
104104
]));
105105
}
106106
$signer = current($signer);
@@ -112,17 +112,17 @@ private function authenticatedUserIsTheSigner(IUser $signer): void {
112112
if ($this->userSession->getUser() !== $signer) {
113113
throw new LibresignException(json_encode([
114114
'action' => JSActions::ACTION_DO_NOTHING,
115-
'errors' => [$this->identifyMethodService->getL10n()->t('Invalid user')],
115+
'errors' => [$this->identifyService->getL10n()->t('Invalid user')],
116116
]));
117117
}
118118
}
119119

120120
private function throwIfNotAuthenticated(): void {
121121
if (!$this->userSession->getUser() instanceof IUser) {
122-
$signRequest = $this->identifyMethodService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
122+
$signRequest = $this->identifyService->getSignRequestMapper()->getById($this->getEntity()->getSignRequestId());
123123
throw new LibresignException(json_encode([
124124
'action' => JSActions::ACTION_REDIRECT,
125-
'errors' => [$this->identifyMethodService->getL10n()->t('You are not logged in. Please log in.')],
125+
'errors' => [$this->identifyService->getL10n()->t('You are not logged in. Please log in.')],
126126
'redirect' => $this->urlGenerator->linkToRoute('core.login.showLoginForm', [
127127
'redirect_url' => $this->urlGenerator->linkToRoute(
128128
'libresign.page.sign',
@@ -146,7 +146,7 @@ public function getSettings(): array {
146146
}
147147

148148
private function isEnabledByDefault(): bool {
149-
$config = $this->identifyMethodService->getAppConfig()->getAppValue('identify_methods', '[]');
149+
$config = $this->identifyService->getAppConfig()->getAppValue('identify_methods', '[]');
150150
$config = json_decode($config, true);
151151
if (json_last_error() !== JSON_ERROR_NONE || !is_array($config)) {
152152
return true;

0 commit comments

Comments
 (0)