Browse Source

lumultiple dbo for get effective permissions

tags/0.1.0
Robin Thoni 9 years ago
parent
commit
322f8b8dde

+ 10
- 11
src/Auth/Business/LuticatePermissionsBusiness.php View File

@@ -5,6 +5,7 @@ namespace Luticate\Auth\Business;
5 5
 use Luticate\Utils\LuBusiness;
6 6
 use Luticate\Auth\DataAccess\LuticatePermissionsDataAccess;
7 7
 use Luticate\Auth\DBO\LuticatePermissionsDbo;
8
+use Luticate\Utils\LuMultipleDbo;
8 9
 
9 10
 class LuticatePermissionsBusiness extends LuBusiness {
10 11
     protected static function getDataAccess()
@@ -33,17 +34,15 @@ class LuticatePermissionsBusiness extends LuBusiness {
33 34
 
34 35
     public static function getAllEffectivePermission($user_id)
35 36
     {
36
-        return LuticatePermissionsDataAccess::getAllEffectivePermission($user_id);
37
-    }
38
-
39
-    public static function getEffectivePermissionMe($user, $permission_name)
40
-    {
41
-        return self::getEffectivePermission($user->getId(), $permission_name);
42
-    }
43
-
44
-    public static function getAllEffectivePermissionMe($user)
45
-    {
46
-        return self::getAllEffectivePermission($user->getId());
37
+        $values = LuticatePermissionsDataAccess::getAllEffectivePermission($user_id);
38
+        $dbos = [];
39
+        foreach ($values as $value) {
40
+            $dbo = new LuticatePermissionsDbo();
41
+            $dbo->setName($value->getPermissonName());
42
+            $dbo->setValue($value->getVal());
43
+            $dbos[] = $dbo;
44
+        }
45
+        return new LuMultipleDbo(count($dbos), $dbos);
47 46
     }
48 47
 
49 48
     public static function getEffectiveDynamicPermission($user_id, $permission_name, $resource_id)

+ 2
- 2
src/Auth/Controller/LuticatePermissionsController.php View File

@@ -32,7 +32,7 @@ class LuticatePermissionsController extends LuController {
32 32
      */
33 33
     public function getEffectivePermissionMe($_user, $permission_name)
34 34
     {
35
-        return LuticatePermissionsBusiness::getEffectivePermissionMe($_user, $permission_name);
35
+        return LuticatePermissionsBusiness::getEffectivePermission($_user->getId(), $permission_name);
36 36
     }
37 37
 
38 38
     /**
@@ -52,7 +52,7 @@ class LuticatePermissionsController extends LuController {
52 52
      */
53 53
     public function getAllEffectivePermissionMe($_user)
54 54
     {
55
-        return LuticatePermissionsBusiness::getAllEffectivePermissionMe($_user);
55
+        return LuticatePermissionsBusiness::getAllEffectivePermission($_user->getId());
56 56
     }
57 57
 
58 58
     /**

+ 1
- 9
src/Auth/DataAccess/LuticatePermissionsDataAccess.php View File

@@ -26,15 +26,7 @@ class LuticatePermissionsDataAccess extends LuDataAccess {
26 26
 
27 27
     public static function getAllEffectivePermission($user_id)
28 28
     {
29
-        $values = SpLuGetAllUserPermission::execute($user_id);
30
-        $dbos = [];
31
-        foreach ($values as $value) {
32
-            $dbo = new LuticatePermissionsDbo();
33
-            $dbo->setName($value->getPermissonName());
34
-            $dbo->setValue($value->getVal());
35
-            $dbos[] = $dbo;
36
-        }
37
-        return $dbos;
29
+        return SpLuGetAllUserPermission::execute($user_id);
38 30
     }
39 31
 
40 32
     public static function getModelByName($permission_name)

Loading…
Cancel
Save