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

UserWrapped.php
Go to the documentation of this file.
1 <?php
2
7 namespace eZ\Publish\Core\MVC\Symfony\Security;
8
9 use eZ\Publish\API\Repository\Values\User\User as APIUser;
10 use Symfony\Component\Security\Core\User\AdvancedUserInterface;
11 use Symfony\Component\Security\Core\User\EquatableInterface;
12 use Symfony\Component\Security\Core\User\UserInterface as CoreUserInterface;
13 use InvalidArgumentException;
14
24 class UserWrapped implements UserInterface, EquatableInterface
25 {
27 private $wrappedUser;
28
30 private $apiUser;
31
32 public function __construct(CoreUserInterface $wrappedUser, APIUser $apiUser)
33 {
34 $this->setWrappedUser($wrappedUser);
35 $this->apiUser = $apiUser;
36 }
37
38 public function __toString()
39 {
40 return $this->wrappedUser->getUsername();
41 }
42
43 public function isAccountNonExpired()
44 {
45 return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isAccountNonExpired() : true;
46 }
47
48 public function isAccountNonLocked()
49 {
50 return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isAccountNonLocked() : true;
51 }
52
53 public function isCredentialsNonExpired()
54 {
55 return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isCredentialsNonExpired() : true;
56 }
57
58 public function isEnabled()
59 {
60 return $this->wrappedUser instanceof AdvancedUserInterface ? $this->wrappedUser->isEnabled() : true;
61 }
62
66 public function setAPIUser(APIUser $apiUser)
67 {
68 $this->apiUser = $apiUser;
69 }
70
74 public function getAPIUser()
75 {
76 return $this->apiUser;
77 }
78
84 public function setWrappedUser(CoreUserInterface $wrappedUser)
85 {
86 if ($wrappedUser instanceof self) {
87 throw new InvalidArgumentException('Injecting UserWrapped to itself is not allowed to avoid recursion');
88 } elseif ($wrappedUser instanceof User) {
89 throw new InvalidArgumentException('Injecting User into UserWrapped causes duplication of APIUser, not wanted for session serialization');
90 }
91
92 $this->wrappedUser = $wrappedUser;
93 }
94
98 public function getWrappedUser()
99 {
100 return $this->wrappedUser;
101 }
102
103 public function getRoles()
104 {
105 return $this->wrappedUser->getRoles();
106 }
107
108 public function getPassword()
109 {
110 return $this->wrappedUser->getPassword();
111 }
112
113 public function getSalt()
114 {
115 return $this->wrappedUser->getSalt();
116 }
117
118 public function getUsername()
119 {
120 return $this->wrappedUser->getUsername();
121 }
122
123 public function eraseCredentials()
124 {
125 $this->wrappedUser->eraseCredentials();
126 }
127
128 public function isEqualTo(CoreUserInterface $user)
129 {
130 return $this->wrappedUser instanceof EquatableInterface ? $this->wrappedUser->isEqualTo($user) : true;
131 }
132 }
eZ\Publish\API\Repository\Values\User\User
Definition: Publish/API/Repository/Values/User/User.php:24
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped
This class represents a UserWrapped object.
Definition: UserWrapped.php:25
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\eraseCredentials
eraseCredentials()
Definition: UserWrapped.php:123
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getUsername
getUsername()
Definition: UserWrapped.php:118
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\__toString
__toString()
Definition: UserWrapped.php:38
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\setWrappedUser
setWrappedUser(CoreUserInterface $wrappedUser)
Definition: UserWrapped.php:84
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getPassword
getPassword()
Definition: UserWrapped.php:108
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\__construct
__construct(CoreUserInterface $wrappedUser, APIUser $apiUser)
Definition: UserWrapped.php:32
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\isEqualTo
isEqualTo(CoreUserInterface $user)
Definition: UserWrapped.php:128
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\isEnabled
isEnabled()
Definition: UserWrapped.php:58
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getWrappedUser
getWrappedUser()
Definition: UserWrapped.php:98
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\isCredentialsNonExpired
isCredentialsNonExpired()
Definition: UserWrapped.php:53
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\$wrappedUser
$wrappedUser
Definition: UserWrapped.php:27
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getSalt
getSalt()
Definition: UserWrapped.php:113
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\isAccountNonLocked
isAccountNonLocked()
Definition: UserWrapped.php:48
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\$apiUser
$apiUser
Definition: UserWrapped.php:30
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getRoles
getRoles()
Definition: UserWrapped.php:103
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\getAPIUser
getAPIUser()
Definition: UserWrapped.php:74
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\setAPIUser
setAPIUser(APIUser $apiUser)
Definition: UserWrapped.php:66
eZ\Publish\Core\MVC\Symfony\Security\UserWrapped\isAccountNonExpired
isAccountNonExpired()
Definition: UserWrapped.php:43
eZ\Publish\Core\MVC\Symfony\Security\User
Definition: Publish/Core/MVC/Symfony/Security/User.php:15
eZ\Publish\Core\MVC\Symfony\Security\UserInterface
Interface for Repository based users.
Definition: UserInterface.php:16
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.