Updated casbin to 1.x.
This commit is contained in:
parent
1883034043
commit
4e53d87672
|
@ -11,7 +11,7 @@
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"require": {
|
"require": {
|
||||||
"laravel/framework": "~5.1",
|
"laravel/framework": "~5.1",
|
||||||
"casbin/casbin": ">=0.2.1"
|
"casbin/casbin": "~1.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~5.7|~6.0|~7.0|~8.0",
|
"phpunit/phpunit": "~5.7|~6.0|~7.0|~8.0",
|
||||||
|
|
|
@ -62,7 +62,9 @@ class DatabaseAdapter implements DatabaseAdapterContract
|
||||||
$rows = $this->eloquent->getAllFromCache();
|
$rows = $this->eloquent->getAllFromCache();
|
||||||
|
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
$line = implode(', ', array_slice(array_values($row), 1));
|
$line = implode(', ', array_filter($row, function ($val) {
|
||||||
|
return '' != $val && !is_null($val);
|
||||||
|
}));
|
||||||
$this->loadPolicyLine(trim($line), $model);
|
$this->loadPolicyLine(trim($line), $model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,12 +44,12 @@ class Rule extends Model
|
||||||
/**
|
/**
|
||||||
* Gets rules from caches.
|
* Gets rules from caches.
|
||||||
*
|
*
|
||||||
* @return void
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function getAllFromCache()
|
public function getAllFromCache()
|
||||||
{
|
{
|
||||||
$get = function () {
|
$get = function () {
|
||||||
return $this->get()->toArray();
|
return $this->select('ptype', 'v0', 'v1', 'v2', 'v3', 'v4', 'v5')->get()->toArray();
|
||||||
};
|
};
|
||||||
if (!$this->config('cache.enabled', false)) {
|
if (!$this->config('cache.enabled', false)) {
|
||||||
return $get();
|
return $get();
|
||||||
|
@ -60,8 +60,6 @@ class Rule extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh Cache.
|
* Refresh Cache.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function refreshCache()
|
public function refreshCache()
|
||||||
{
|
{
|
||||||
|
@ -75,8 +73,6 @@ class Rule extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Forget Cache.
|
* Forget Cache.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
public function forgetCache()
|
public function forgetCache()
|
||||||
{
|
{
|
||||||
|
@ -85,8 +81,6 @@ class Rule extends Model
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init cache.
|
* Init cache.
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
*/
|
||||||
protected function initCache()
|
protected function initCache()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue