Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Acl\User Class Reference

Public Member Functions

 __construct ($id, $label=null)
 
 addGroup ($groups=[])
 
 deleteGroup ($groups=[])
 
 groupExists ($groupId)
 
 getGroups ()
 
 setLabel ($label)
 
 getId ()
 
 getLabel ()
 

Protected Member Functions

 setId ($id)
 

Protected Attributes

 $userId = null
 
 $userLabel = null
 
 $groups = []
 

Detailed Description

Class .

Describe a user.

Definition at line 47 of file User.php.

Constructor & Destructor Documentation

Hoa\Acl\User::__construct (   $id,
  $label = null 
)

Built a new user.

Parameters
mixed$idThe user ID.
string$labelThe user label.
Returns
void

Definition at line 79 of file User.php.

80  {
81  $this->setId($id);
82  $this->setLabel($label);
83 
84  return;
85  }
setLabel($label)
Definition: User.php:186
setId($id)
Definition: User.php:172

Here is the call graph for this function:

Member Function Documentation

Hoa\Acl\User::addGroup (   $groups = [])

Add group.

Parameters
array$groupsGroup to add.
Returns
array

Definition at line 93 of file User.php.

94  {
95  if (!is_array($groups)) {
96  $groups = [$groups];
97  }
98 
99  foreach ($groups as $group) {
100  if ($group instanceof Group) {
101  $group = $group->getId();
102  }
103 
104  if (true === $this->groupExists($group)) {
105  continue;
106  }
107 
108  $this->groups[$group] = true;
109  }
110 
111  return $this->getGroups();
112  }
groupExists($groupId)
Definition: User.php:147
getGroups()
Definition: User.php:161

Here is the call graph for this function:

Hoa\Acl\User::deleteGroup (   $groups = [])

Delete group.

Parameters
array$groupsGroup to add.
Returns
array

Definition at line 120 of file User.php.

121  {
122  if (!is_array($groups)) {
123  $groups = [$groups];
124  }
125 
126  foreach ($groups as $group) {
127  if ($group instanceof Group) {
128  $group = $group->getId();
129  }
130 
131  if (false === $this->groupExists($group)) {
132  continue;
133  }
134 
135  unset($this->groups[$group]);
136  }
137 
138  return $this->getGroups();
139  }
groupExists($groupId)
Definition: User.php:147
getGroups()
Definition: User.php:161

Here is the call graph for this function:

Hoa\Acl\User::getGroups ( )

Get all groups, i.e. the groups collection.

Returns
array

Definition at line 161 of file User.php.

162  {
163  return array_keys($this->groups);
164  }

Here is the caller graph for this function:

Hoa\Acl\User::getId ( )

Get user ID.

Returns
mixed

Definition at line 199 of file User.php.

200  {
201  return $this->userId;
202  }

Here is the caller graph for this function:

Hoa\Acl\User::getLabel ( )

Get user label.

Returns
mixed

Definition at line 209 of file User.php.

210  {
211  return $this->userLabel;
212  }
Hoa\Acl\User::groupExists (   $groupId)

Check if a group exists.

Parameters
mixed$groupIdThe group ID.
Returns
bool

Definition at line 147 of file User.php.

148  {
149  if ($groupId instanceof Group) {
150  $groupId = $groupId->getId();
151  }
152 
153  return isset($this->groups[$groupId]);
154  }

Here is the caller graph for this function:

Hoa\Acl\User::setId (   $id)
protected

Set user ID.

Parameters
mixed$idThe user ID.
Returns
mixed

Definition at line 172 of file User.php.

173  {
174  $old = $this->userId;
175  $this->userId = $id;
176 
177  return $old;
178  }

Here is the caller graph for this function:

Hoa\Acl\User::setLabel (   $label)

Set user label.

Parameters
string$labelThe user label.
Returns
string

Definition at line 186 of file User.php.

187  {
188  $old = $this->userLabel;
189  $this->userLabel = $label;
190 
191  return $old;
192  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Acl\User::$groups = []
protected

Definition at line 68 of file User.php.

Hoa\Acl\User::$userId = null
protected

Definition at line 54 of file User.php.

Hoa\Acl\User::$userLabel = null
protected

Definition at line 61 of file User.php.


The documentation for this class was generated from the following file: