1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of Transfer. |
5
|
|
|
* |
6
|
|
|
* For the full copyright and license information, please view the LICENSE file located |
7
|
|
|
* in the root directory. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Transfer\EzPlatform\Repository\Content; |
11
|
|
|
|
12
|
|
|
use eZ\Publish\API\Repository\Values\User\UserCreateStruct; |
13
|
|
|
use eZ\Publish\API\Repository\Values\User\UserUpdateStruct; |
14
|
|
|
use eZ\Publish\Core\Repository\Values\Content\ContentUpdateStruct; |
15
|
|
|
use Transfer\EzPlatform\Data\UserObject; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* User mapper. |
19
|
|
|
* |
20
|
|
|
* @author Harald Tollefsen <[email protected]> |
21
|
|
|
*/ |
22
|
|
|
class UserMapper |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* @var UserObject |
26
|
|
|
*/ |
27
|
|
|
public $userObject; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param UserObject $userObject |
31
|
|
|
*/ |
32
|
6 |
|
public function __construct(UserObject $userObject) |
33
|
|
|
{ |
34
|
6 |
|
$this->userObject = $userObject; |
35
|
6 |
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param UserCreateStruct $userCreateStruct |
39
|
|
|
*/ |
40
|
3 |
|
public function getNewUserCreateStruct(UserCreateStruct $userCreateStruct) |
41
|
|
|
{ |
42
|
3 |
|
$userCreateStruct->enabled = $this->userObject->data['enabled']; |
43
|
|
|
|
44
|
3 |
|
$fields = array_flip($this->userObject->data['fields']); |
45
|
3 |
|
array_walk($fields, array($userCreateStruct, 'setField')); |
46
|
3 |
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param UserUpdateStruct $userUpdateStruct |
50
|
|
|
*/ |
51
|
3 |
|
public function getNewUserUpdateStruct(UserUpdateStruct $userUpdateStruct) |
52
|
|
|
{ |
53
|
3 |
|
$userUpdateStruct->email = $this->userObject->data['email']; |
54
|
3 |
|
$userUpdateStruct->maxLogin = $this->userObject->data['max_login']; |
55
|
3 |
|
$userUpdateStruct->enabled = $this->userObject->data['enabled']; |
56
|
|
|
|
57
|
3 |
|
if (isset($this->userObject->data['fields'])) { |
58
|
3 |
|
$userUpdateStruct->contentUpdateStruct = new ContentUpdateStruct(); |
59
|
3 |
|
$fields = array_flip($this->userObject->data['fields']); |
60
|
3 |
|
array_walk($fields, array($userUpdateStruct->contentUpdateStruct, 'setField')); |
61
|
3 |
|
} |
62
|
3 |
|
} |
63
|
|
|
} |
64
|
|
|
|