Skip to content

Commit eb39fd0

Browse files
committed
修改命名空间
1 parent a146f3d commit eb39fd0

File tree

13 files changed

+33
-45
lines changed

13 files changed

+33
-45
lines changed

composer.json

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "tinywan/casbin",
3-
"description": "Webman Casbin Plugin",
2+
"name": "casbin/webman-permission",
3+
"description": "webman casbin permission Plugin",
44
"type": "library",
55
"license": "MIT",
66
"require": {
@@ -12,23 +12,17 @@
1212
},
1313
"autoload": {
1414
"psr-4": {
15-
"Tinywan\\Casbin\\": "src"
15+
"Casbin\\WebmanPermission\\": "src"
1616
}
1717
},
1818
"autoload-dev": {
1919
"psr-4": {
20-
"Tinywan\\Tests\\": "tests/"
20+
"Casbin\\WebmanPermission\\Tests\\": "tests/"
2121
}
2222
},
2323
"require-dev": {
2424
"phpunit/phpunit": "~7.0|~8.0|~9.0",
2525
"php-coveralls/php-coveralls": "^2.1",
2626
"workerman/webman": "^1.0"
27-
},
28-
"repositories": {
29-
"packagist": {
30-
"type": "composer",
31-
"url": "https://mirrors.aliyun.com/composer//"
32-
}
3327
}
3428
}

src/Adapter/DatabaseAdapter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
declare(strict_types=1);
1010

11-
namespace Tinywan\Casbin\Adapter;
11+
namespace Casbin\WebmanPermission\Adapter;
1212

1313
use Casbin\Model\Model;
1414
use Casbin\Persist\Adapter;
@@ -19,7 +19,7 @@
1919
use Casbin\Persist\Adapters\Filter;
2020
use Casbin\Exceptions\InvalidFilterTypeException;
2121
use think\facade\Db;
22-
use Tinywan\Casbin\Model\RuleModel;
22+
use Casbin\WebmanPermission\Model\RuleModel;
2323

2424
/**
2525
* DatabaseAdapter.

src/Install.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
namespace Tinywan\Casbin;
2+
namespace Casbin\WebmanPermission;
33

44
class Install
55
{
@@ -8,7 +8,9 @@ class Install
88
/**
99
* @var array
1010
*/
11-
protected static $pathRelation = array ('config/plugin/tinywan/casbin' => 'config/plugin/tinywan/casbin');
11+
protected static $pathRelation = array (
12+
'config/plugin/casbin/webman-permission' => 'config/plugin/casbin/webman-permission',
13+
);
1214

1315
/**
1416
* Install
@@ -43,6 +45,8 @@ public static function installByRelation()
4345
}
4446
//symlink(__DIR__ . "/$source", base_path()."/$dest");
4547
copy_dir(__DIR__ . "/$source", base_path()."/$dest");
48+
echo "Create $dest
49+
";
4650
}
4751
}
4852

@@ -57,9 +61,12 @@ public static function uninstallByRelation()
5761
if (!is_dir($path) && !is_file($path)) {
5862
continue;
5963
}
60-
/*if (is_link($path) {
64+
echo "Remove $dest
65+
";
66+
if (is_file($path) || is_link($path)) {
6167
unlink($path);
62-
}*/
68+
continue;
69+
}
6370
remove_dir($path);
6471
}
6572
}

src/Model/RuleModel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
declare(strict_types=1);
1010

11-
namespace Tinywan\Casbin\Model;
11+
namespace Casbin\WebmanPermission\Model;
1212

1313
use think\Model;
1414
use think\contract\Arrayable;

src/Permission.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@
77

88
declare(strict_types=1);
99

10-
namespace Tinywan\Casbin;
10+
namespace Casbin\WebmanPermission;
1111

1212

1313
use Casbin\Enforcer;
1414
use Casbin\Exceptions\CasbinException;
1515
use Casbin\Model\Model;
1616
use support\Container;
17-
use Tinywan\Casbin\Watcher\RedisWatcher;
17+
use Casbin\WebmanPermission\Watcher\RedisWatcher;
1818
use Workerman\Worker;
1919
use Webman\Bootstrap;
2020

2121
/**
2222
* @see \Casbin\Enforcer
23-
* @mixin \Casbin\Enforcer
23+
* @mixin Enforcer
2424
* @method static enforce(mixed ...$rvals) 权限检查,输入参数通常是(sub, obj, act)
2525
* @method static bool addPolicy(mixed ...$params) 当前策略添加授权规则
2626
* @method static bool addPolicies(mixed ...$params) 当前策略添加授权规则
@@ -61,15 +61,15 @@ class Permission implements Bootstrap
6161
public static function start($worker)
6262
{
6363
if ($worker) {
64-
$configType = config('plugin.tinywan.casbin.permission.basic.model.config_type');
64+
$configType = config('plugin.casbin.webman-permission.permission.basic.model.config_type');
6565
$model = new Model();
6666
if ('file' == $configType) {
67-
$model->loadModel(config('plugin.tinywan.casbin.permission.basic.model.config_file_path'));
67+
$model->loadModel(config('plugin.casbin.webman-permission.permission.basic.model.config_file_path'));
6868
} elseif ('text' == $configType) {
69-
$model->loadModel(config('plugin.tinywan.casbin.permission.basic.model.config_text'));
69+
$model->loadModel(config('plugin.casbin.webman-permission.permission.basic.model.config_text'));
7070
}
7171
if (is_null(static::$_manager)) {
72-
static::$_manager = new Enforcer($model, Container::get(config('plugin.tinywan.casbin.permission.basic.adapter')),false);
72+
static::$_manager = new Enforcer($model, Container::get(config('plugin.casbin.webman-permission.permission.basic.adapter')),false);
7373
}
7474

7575
$watcher = new RedisWatcher(config('redis.default'));

src/Watcher/RedisWatcher.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
declare(strict_types=1);
99

10-
namespace Tinywan\Casbin\Watcher;
10+
namespace Casbin\WebmanPermission\Watcher;
1111

1212

1313
use Casbin\Persist\Watcher;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php
2+
return [
3+
Casbin\WebmanPermission\Permission::class
4+
];

src/config/plugin/tinywan/casbin/permission.php renamed to src/config/plugin/casbin/webman-permission/permission.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
'config_text' => '',
1515
],
1616
# 适配器
17-
'adapter' => \Tinywan\Casbin\Adapter\DatabaseAdapter::class,
17+
'adapter' => Casbin\WebmanPermission\Adapter\DatabaseAdapter::class,
1818
'database' => [
1919
'connection' => '',
2020
'rules_table' => 'casbin_rule',

0 commit comments

Comments
 (0)