-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from CottaCush/updates/implement-psr2
(Cleanup): Apply PSR coding convention
- Loading branch information
Showing
7 changed files
with
45 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ public function canAccess($permissionKey) | |
} | ||
|
||
/** | ||
* @param $roleKey | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function setRoleByKey($roleKey) | ||
|
@@ -38,9 +39,9 @@ public function setRoleByKey($roleKey) | |
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $roleId | ||
* @return void | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function setRoleById($roleId) | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,61 +8,62 @@ | |
use cottacush\rbac\libs\Constants; | ||
use cottacush\rbac\models\Permission; | ||
use cottacush\rbac\models\Role; | ||
use Yii; | ||
|
||
class DbPermissionManager extends BasePermissionManager | ||
{ | ||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRoles() | ||
{ | ||
return Role::find()->asArray()->all(); | ||
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $key | ||
* @return Role | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRole($key) | ||
{ | ||
return Role::find()->where(['key' => $key, 'status' => Constants::STATUS_ACTIVE])->limit(1)->one(); | ||
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $roleId | ||
* @return Role | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRoleById($roleId) | ||
{ | ||
return Role::find()->where(['id' => $roleId, 'status' => Constants::STATUS_ACTIVE])->limit(1)->one(); | ||
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermissions() | ||
{ | ||
return Permission::find()->asArray()->all(); | ||
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $key | ||
* @return Permission | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermission($key) | ||
{ | ||
return Permission::find()->where(['key' => $key, 'status' => Constants::STATUS_ACTIVE])->limit(1)->one(); | ||
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $permissionId | ||
* @return Permission | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermissionById($permissionId) | ||
{ | ||
|
@@ -71,17 +72,18 @@ public function getPermissionById($permissionId) | |
} | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getUserRole() | ||
{ | ||
$role = \Yii::$app->session->get($this->sessionPrefix . '::user_role'); | ||
$role = Yii::$app->session->get($this->sessionPrefix . '::user_role'); | ||
return $role; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
* @throws \yii\base\InvalidConfigException | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getUserPermissions() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,75 +10,75 @@ interface ManagerInterface | |
{ | ||
/** | ||
* Checks if the user has the specified permission. | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $permissionKey | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function canAccess($permissionKey); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRoles(); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getUserRole(); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $key | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRole($key); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $roleId | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getRoleById($roleId); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermissions(); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $key | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermission($key); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $permissionId | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermissionById($permissionId); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $roleKey | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function setRoleByKey($roleKey); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @param $roleId | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function setRoleById($roleId); | ||
|
||
/** | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getUserPermissions(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -68,8 +68,9 @@ public function getRolePermissions() | |
|
||
/** | ||
* Get Permissions assigned to role | ||
* @author Adegoke Obasa <[email protected]> | ||
* @return mixed | ||
* @throws \yii\base\InvalidConfigException | ||
* @author Adegoke Obasa <[email protected]> | ||
*/ | ||
public function getPermissions() | ||
{ | ||
|