mirror of
https://github.com/getgrav/grav.git
synced 2026-03-24 13:30:11 +01:00
Added support for configurable actions in Flex
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Grav\Framework\Flex\Traits;
|
||||
|
||||
use Grav\Common\Grav;
|
||||
use Grav\Common\User\Interfaces\UserInterface;
|
||||
use Grav\Framework\Flex\FlexDirectory;
|
||||
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,11 @@ trait FlexAuthorizeTrait
|
||||
$action = $this->exists() ? 'update' : 'create';
|
||||
}
|
||||
|
||||
return $user->authorize(sprintf($this->_authorize, $scope, $action));
|
||||
$directory = $this instanceof FlexDirectory ? $this : $this->getFlexDirectory();
|
||||
$config = $directory->getConfig();
|
||||
$allowed = $config->get("{$scope}.actions.{$action}") ?? $config->get("actions.{$action}") ?? true;
|
||||
|
||||
return $allowed && $user->authorize(sprintf($this->_authorize, $scope, $action));
|
||||
}
|
||||
|
||||
protected function setAuthorizeRule(string $authorize) : void
|
||||
|
||||
Reference in New Issue
Block a user