|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2020 |
|
6
|
|
|
* @package MShop |
|
7
|
|
|
* @subpackage Customer |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
|
|
11
|
|
|
namespace Aimeos\MShop\Customer\Item; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Customer DTO object for the FosUserBundle. |
|
16
|
|
|
* |
|
17
|
|
|
* @package MShop |
|
18
|
|
|
* @subpackage Customer |
|
19
|
|
|
*/ |
|
20
|
|
|
class FosUser extends Standard implements Iface |
|
21
|
|
|
{ |
|
22
|
|
|
private $helper; |
|
23
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Initializes the customer item object |
|
27
|
|
|
* |
|
28
|
|
|
* @param \Aimeos\MShop\Common\Item\Address\Iface $address Payment address item object |
|
29
|
|
|
* @param array $values List of attributes that belong to the customer item |
|
30
|
|
|
* @param \Aimeos\MShop\Common\Lists\Item\Iface[] $listItems List of list items |
|
31
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items |
|
32
|
|
|
* @param \Aimeos\MShop\Common\Item\Address\Iface[] $addrItems List of referenced address items |
|
33
|
|
|
* @param \Aimeos\MShop\Common\Item\Property\Iface[] $propItems List of property items |
|
34
|
|
|
* @param \Aimeos\MShop\Common\Helper\Password\Iface|null $helper Password encryption helper object |
|
35
|
|
|
* @param string|null $salt Password salt |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct( \Aimeos\MShop\Common\Item\Address\Iface $address, array $values = [], |
|
38
|
|
|
array $listItems = [], array $refItems = [], array $addrItems = [], array $propItems = [], |
|
39
|
|
|
\Aimeos\MShop\Common\Helper\Password\Iface $helper = null, string $salt = null ) |
|
40
|
|
|
{ |
|
41
|
|
|
parent::__construct( $address, $values, $listItems, $refItems, $addrItems, $propItems, $helper, $salt ); |
|
42
|
|
|
|
|
43
|
|
|
$this->helper = $helper; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* Sets the password of the customer item. |
|
49
|
|
|
* |
|
50
|
|
|
* @param string $value Password of the customer item |
|
51
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls |
|
52
|
|
|
*/ |
|
53
|
|
|
public function setPassword( string $value ) : \Aimeos\MShop\Customer\Item\Iface |
|
54
|
|
|
{ |
|
55
|
|
|
if( $value !== $this->getPassword() && $this->helper !== null ) { |
|
56
|
|
|
$value = $this->helper->encode( $value, $this->getSalt() ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
return $this->set( 'customer.password', $value ); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Returns the associated user roles |
|
65
|
|
|
* |
|
66
|
|
|
* @return array List of Symfony roles |
|
67
|
|
|
*/ |
|
68
|
|
|
public function getRoles() : array |
|
69
|
|
|
{ |
|
70
|
|
|
return $this->get( 'roles', [] ); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Sets the associated user roles |
|
76
|
|
|
* |
|
77
|
|
|
* @param array $roles List of Symfony roles |
|
78
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setRoles( array $roles ) : \Aimeos\MShop\Customer\Item\Iface |
|
81
|
|
|
{ |
|
82
|
|
|
return $this->set( 'roles', $roles ); |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* Returns the password salt |
|
88
|
|
|
* |
|
89
|
|
|
* @return string Password salt |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getSalt() : string |
|
92
|
|
|
{ |
|
93
|
|
|
return $this->get( 'salt', '' ); |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* Sets the password salt |
|
99
|
|
|
* |
|
100
|
|
|
* @param string $value Password salt |
|
101
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item for chaining method calls |
|
102
|
|
|
*/ |
|
103
|
|
|
public function setSalt( string $value ) : \Aimeos\MShop\Customer\Item\Iface |
|
104
|
|
|
{ |
|
105
|
|
|
return $this->set( 'salt', $value ); |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
|