forked from ezsystems/ezpublish-kernel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
UserPreferenceService.php
76 lines (65 loc) · 2.23 KB
/
UserPreferenceService.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
/**
* @copyright Copyright (C) eZ Systems AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
declare(strict_types=1);
namespace eZ\Publish\Core\SignalSlot;
use eZ\Publish\API\Repository\UserPreferenceService as UserPreferenceServiceInterface;
use eZ\Publish\API\Repository\Values\UserPreference\UserPreference;
use eZ\Publish\API\Repository\Values\UserPreference\UserPreferenceList;
use eZ\Publish\Core\SignalSlot\Signal\UserPreferenceService\UserPreferenceSetSignal;
class UserPreferenceService implements UserPreferenceServiceInterface
{
/**
* @var \eZ\Publish\API\Repository\UserPreferenceService
*/
protected $service;
/**
* @var \eZ\Publish\Core\SignalSlot\SignalDispatcher
*/
protected $signalDispatcher;
/**
* @param \eZ\Publish\API\Repository\UserPreferenceService $service
* @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
*/
public function __construct(UserPreferenceServiceInterface $service, SignalDispatcher $signalDispatcher)
{
$this->service = $service;
$this->signalDispatcher = $signalDispatcher;
}
/**
* {@inheritdoc}
*/
public function setUserPreference(array $userPreferenceSetStructs): void
{
$this->service->setUserPreference($userPreferenceSetStructs);
foreach ($userPreferenceSetStructs as $userPreferenceSetStruct) {
$this->signalDispatcher->emit(new UserPreferenceSetSignal([
'name' => $userPreferenceSetStruct->name,
'value' => $userPreferenceSetStruct->value,
]));
}
}
/**
* {@inheritdoc}
*/
public function getUserPreference(string $userPreferenceName): UserPreference
{
return $this->service->getUserPreference($userPreferenceName);
}
/**
* {@inheritdoc}
*/
public function loadUserPreferences(int $offset = 0, int $limit = 25): UserPreferenceList
{
return $this->service->loadUserPreferences($offset, $limit);
}
/**
* {@inheritdoc}
*/
public function getUserPreferenceCount(): int
{
return $this->service->getUserPreferenceCount();
}
}