Skip to content

Commit

Permalink
fix bug:permission
Browse files Browse the repository at this point in the history
  • Loading branch information
garming committed Dec 27, 2018
1 parent d25b567 commit aa08e78
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ source ~/.bash_profile
2. `tangram create moduleName`
> create module which named `moduleName`
## #Plan
1. dependency
2. data permission

License
-------

Expand Down
16 changes: 8 additions & 8 deletions src/Tangram/Reflection/AnnotationReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ private static function analyze(Application $application)
// $requestPath = '/' . $module['uri-prefix'] . '/' . strtolower($modulePath) . '/' . strtolower(str_replace('Controller', '', $requestPath));
// $requestPath = str_replace("//", "/", $requestPath);
// $requestPath = str_replace("\\", "/", $requestPath);
$permissionName = "";
$requestPath = "";
$ctrlPermissionName = "";
if (!empty($ctrlRequestMapping)) {
if (is_string($ctrlRequestMapping)) {
$requestPath = rtrim($ctrlRequestMapping, "/**");
Expand All @@ -65,7 +65,7 @@ private static function analyze(Application $application)
}
if (!empty($mainPermission)) {
if (is_string($mainPermission)) {
$permissionName = rtrim($mainPermission, "/**");
$ctrlPermissionName = rtrim($mainPermission, "/**");
}
}
//auth-handler
Expand All @@ -83,10 +83,10 @@ private static function analyze(Application $application)
$main_uri = str_replace("//", "/", $main_uri);
$main_uri = str_replace("\\", "/", $main_uri);

if(!empty($permissionName)){
$permissionName = "/".$permissionName . "/";
if(!empty($ctrlPermissionName) && strpos($ctrlPermissionName,"/") != 0){
$ctrlPermissionName = "/".$ctrlPermissionName;
}

$permissionName = "";
$requestMethod = "GET";
$uri = $method->name;

Expand All @@ -99,13 +99,12 @@ private static function analyze(Application $application)
//有method的comment
$methodRequestMapping = $method->getAnnotation('RequestMapping');
$methodPermission = $method->getAnnotation('Permission');

if(!empty($methodPermission)){
if (is_string($methodPermission)) {
if (empty($permissionName)) {
if (empty($ctrlPermissionName) || strpos($methodPermission,"/") === 0) {
$permissionName = $methodPermission;
} else {
$permissionName = $permissionName . $methodPermission;
$permissionName = $ctrlPermissionName . "/". $methodPermission;
}
}
}
Expand Down Expand Up @@ -184,6 +183,7 @@ private static function analyze(Application $application)
if(!empty($permissionName)){
static::$annotationMap[$applicationName]["permission"][] = $rs;
}
$permissionName = "";
}
}
}
Expand Down

0 comments on commit aa08e78

Please sign in to comment.