-
-
Notifications
You must be signed in to change notification settings - Fork 221
/
User.php
91 lines (83 loc) · 1.88 KB
/
User.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
namespace Neos\Neos\Domain\Model;
/*
* This file is part of the Neos.Neos package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Security\Account;
use Neos\Party\Domain\Model\Person;
use Doctrine\ORM\Mapping as ORM;
use Neos\Flow\Annotations as Flow;
use Neos\ContentRepository\Domain\Model\UserInterface;
/**
* Domain Model of a User
*
* @Flow\Entity
* @Flow\Scope("prototype")
* @api
*/
class User extends Person implements UserInterface
{
/**
* Preferences of this user
*
* @var UserPreferences
* @ORM\OneToOne
*/
protected $preferences;
/**
* Constructs this User object
*/
public function __construct()
{
parent::__construct();
$this->preferences = new UserPreferences();
}
/**
* Returns a label which can be used as a human-friendly identifier for this user.
*
* @return string
*/
public function getLabel()
{
return $this->getName()->getFullName();
}
/**
* @return UserPreferences
* @api
*/
public function getPreferences()
{
return $this->preferences;
}
/**
* @param UserPreferences $preferences
* @return void
* @api
*/
public function setPreferences(UserPreferences $preferences)
{
$this->preferences = $preferences;
}
/**
* Checks if at least one account of this user ist active
*
* @return boolean
* @api
*/
public function isActive()
{
foreach ($this->accounts as $account) {
/** @var Account $account */
if ($account->isActive()) {
return true;
}
}
return false;
}
}