Skip to content

Commit

Permalink
BREAKING CHANGE: upgrade to PHP 8.0 and PHP-Casbin 4.0 (#48)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: upgrade to PHP 8.0 and PHP-Casbin 4.0 (#48)
  • Loading branch information
Dobmod authored and leeqvip committed Oct 29, 2024
1 parent a5bc495 commit 2fe2143
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ 7.2, 7.3, 7.4, 8.0, 8.1, 8.2 ]
php: [ 8.0, 8.1, 8.2, 8.3 ]

name: PHP${{ matrix.php }}

Expand Down
30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
],
"license": "Apache-2.0",
"require": {
"casbin/casbin": "~3.0",
"topthink/framework": "~6.0|^8.0.3",
"topthink/think-migration": "^3.1.0",
"casbin/psr3-bridge": "^1.1"
"php": ">=8.0",
"casbin/casbin": "~4.0",
"topthink/framework": "^8.0.3",
"topthink/think-migration": "^3.1.0"
},
"require-dev": {
"phpunit/phpunit": "~7.0|~8.0|~9.0",
"php-coveralls/php-coveralls": "^2.4",
"topthink/think": "~6.0|~8.0"
"phpunit/phpunit": "~9.0",
"php-coveralls/php-coveralls": "^2.7",
"topthink/think": "~8.0"
},
"autoload": {
"psr-4": {
Expand Down
21 changes: 10 additions & 11 deletions src/TauthzService.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace tauthz;

use Casbin\Bridge\Logger\LoggerBridge;
use Casbin\Enforcer;
use Casbin\Model\Model;
use Casbin\Log\Log;
use Casbin\Log\Logger\DefaultLogger;
use think\Service;
use tauthz\command\Publish;

Expand Down Expand Up @@ -42,7 +42,15 @@ public function register()
$model->loadModel($config['model']['config_text']);
}

return new Enforcer($model, app($adapter), $this->app->config->get('tauthz.log.enabled', false));
if ($logger = $this->app->config->get('tauthz.log.logger')) {
if (is_string($logger)) {
$logger = new DefaultLogger($this->app->make($logger));
}

Log::setLogger($logger);
}

return new Enforcer($model, app($adapter), $logger, $this->app->config->get('tauthz.log.enabled', false));
});
}

Expand All @@ -55,15 +63,6 @@ public function boot()
{
$this->mergeConfigFrom(__DIR__.'/../config/tauthz.php', 'tauthz');

// 设置 Casbin Logger
if ($logger = $this->app->config->get('tauthz.log.logger')) {
if (is_string($logger)) {
$logger = $this->app->make($logger);
}

Log::setLogger(new LoggerBridge($logger));
}

$this->commands(['tauthz:publish' => Publish::class]);
}

Expand Down

0 comments on commit 2fe2143

Please sign in to comment.