Exponential 5.x Kernel 7.5.40 Exponential New Stack (Symfony-based) Kernel — PHP Class Reference

Core/Persistence/Legacy/UserPreference/Handler.php
Go to the documentation of this file.
1 <?php
2
7 declare(strict_types=1);
8
9 namespace eZ\Publish\Core\Persistence\Legacy\UserPreference;
10
11 use eZ\Publish\Core\Base\Exceptions\NotFoundException;
12 use eZ\Publish\SPI\Persistence\UserPreference\UserPreferenceSetStruct;
13 use eZ\Publish\SPI\Persistence\UserPreference\Handler as HandlerInterface;
14 use eZ\Publish\SPI\Persistence\UserPreference\UserPreference;
15
16 class Handler implements HandlerInterface
17 {
19 protected $gateway;
20
22 protected $mapper;
23
28 public function __construct(Gateway $gateway, Mapper $mapper)
29 {
30 $this->gateway = $gateway;
31 $this->mapper = $mapper;
32 }
33
39 public function setUserPreference(UserPreferenceSetStruct $setStruct): UserPreference
40 {
41 $this->gateway->setUserPreference($setStruct);
42
43 return $this->getUserPreferenceByUserIdAndName($setStruct->userId, $setStruct->name);
44 }
45
51 public function getUserPreferenceByUserIdAndName(int $userId, string $name): UserPreference
52 {
53 $userPreference = $this->mapper->extractUserPreferencesFromRows(
54 $this->gateway->getUserPreferenceByUserIdAndName($userId, $name)
55 );
56
57 if (count($userPreference) < 1) {
58 throw new NotFoundException('User Preference', $userId . ',' . $name);
59 }
60
61 return reset($userPreference);
62 }
63
67 public function countUserPreferences(int $userId): int
68 {
69 return $this->gateway->countUserPreferences($userId);
70 }
71
75 public function loadUserPreferences(int $userId, int $offset, int $limit): array
76 {
77 return $this->mapper->extractUserPreferencesFromRows(
78 $this->gateway->loadUserPreferences($userId, $offset, $limit)
79 );
80 }
81 }
eZ\Publish\Core\Base\Exceptions\NotFoundException
Not Found Exception implementation.
Definition: Core/Base/Exceptions/NotFoundException.php:21
eZ\Publish\Core\Persistence\Legacy\UserPreference\Gateway
Definition: Persistence/Legacy/UserPreference/Gateway.php:14
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:17
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\loadUserPreferences
loadUserPreferences(int $userId, int $offset, int $limit)
{}
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:75
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\__construct
__construct(Gateway $gateway, Mapper $mapper)
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:28
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\countUserPreferences
countUserPreferences(int $userId)
{}
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:67
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\$mapper
$mapper
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:22
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\getUserPreferenceByUserIdAndName
getUserPreferenceByUserIdAndName(int $userId, string $name)
{}
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:51
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\$gateway
$gateway
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:19
eZ\Publish\Core\Persistence\Legacy\UserPreference\Handler\setUserPreference
setUserPreference(UserPreferenceSetStruct $setStruct)
{}
Definition: Core/Persistence/Legacy/UserPreference/Handler.php:39
eZ\Publish\Core\Persistence\Legacy\UserPreference\Mapper
Definition: Publish/Core/Persistence/Legacy/UserPreference/Mapper.php:14
eZ\Publish\SPI\Persistence\UserPreference\UserPreferenceSetStruct
Definition: SPI/Persistence/UserPreference/UserPreferenceSetStruct.php:14
eZ\Publish\SPI\Persistence\UserPreference\UserPreference
Definition: SPI/Persistence/UserPreference/UserPreference.php:14
eZ\Publish\SPI\Persistence\UserPreference\Handler
Definition: SPI/Persistence/UserPreference/Handler.php:12
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.