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

Public Member Functions

 __construct ($id, $label=null)
 
 addUser ($users=[])
 
 deleteUser ($users=[])
 
 userExists ($userId)
 
 getUsers ()
 
 setLabel ($label)
 
 getId ()
 
 getLabel ()
 

Protected Member Functions

 setId ($id)
 

Protected Attributes

 $serviceId = null
 
 $serviceLabel = null
 
 $users = []
 

Detailed Description

Class .

Describe a service.

Definition at line 47 of file Service.php.

Constructor & Destructor Documentation

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

Built a new service.

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

Definition at line 79 of file Service.php.

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

Here is the call graph for this function:

Member Function Documentation

Hoa\Acl\Service::addUser (   $users = [])

Add user.

Parameters
array$usersUser to add.
Returns
array

Definition at line 93 of file Service.php.

94  {
95  if (!is_array($users)) {
96  $users = [$users];
97  }
98 
99  foreach ($users as $user) {
100  if ($user instanceof User) {
101  $user = $user->getId();
102  }
103 
104  if (true === $this->userExists($user)) {
105  continue;
106  }
107 
108  $this->users[$user] = true;
109  }
110 
111  return $this->getUsers();
112  }
userExists($userId)
Definition: Service.php:145

Here is the call graph for this function:

Hoa\Acl\Service::deleteUser (   $users = [])

Delete user.

Parameters
array$usersUser to add.
Returns
array

Definition at line 120 of file Service.php.

121  {
122  $users = (array) $users;
123 
124  foreach ($users as $user) {
125  if ($user instanceof User) {
126  $user = $user->getId();
127  }
128 
129  if (false === $this->userExists($user)) {
130  continue;
131  }
132 
133  unset($this->users[$user]);
134  }
135 
136  return $this->getUsers();
137  }
userExists($userId)
Definition: Service.php:145

Here is the call graph for this function:

Hoa\Acl\Service::getId ( )

Get service ID.

Returns
mixed

Definition at line 197 of file Service.php.

198  {
199  return $this->serviceId;
200  }

Here is the caller graph for this function:

Hoa\Acl\Service::getLabel ( )

Get service label.

Returns
mixed

Definition at line 207 of file Service.php.

208  {
209  return $this->serviceLabel;
210  }
Hoa\Acl\Service::getUsers ( )

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

Returns
array

Definition at line 159 of file Service.php.

160  {
161  return array_keys($this->users);
162  }

Here is the caller graph for this function:

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

Set service ID.

Parameters
mixed$idThe service ID.
Returns
mixed

Definition at line 170 of file Service.php.

171  {
172  $old = $this->serviceId;
173  $this->serviceId = $id;
174 
175  return $old;
176  }

Here is the caller graph for this function:

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

Set service label.

Parameters
string$labelThe service label.
Returns
string

Definition at line 184 of file Service.php.

185  {
186  $old = $this->serviceLabel;
187  $this->serviceLabel = $label;
188 
189  return $old;
190  }

Here is the caller graph for this function:

Hoa\Acl\Service::userExists (   $userId)

Check if a user exists.

Parameters
mixed$userIdThe user ID.
Returns
bool

Definition at line 145 of file Service.php.

146  {
147  if ($userId instanceof User) {
148  $userId = $userId->getId();
149  }
150 
151  return isset($this->users[$userId]);
152  }

Here is the caller graph for this function:

Member Data Documentation

Hoa\Acl\Service::$serviceId = null
protected

Definition at line 54 of file Service.php.

Hoa\Acl\Service::$serviceLabel = null
protected

Definition at line 61 of file Service.php.

Hoa\Acl\Service::$users = []
protected

Definition at line 68 of file Service.php.


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