mirror of
https://github.com/getgrav/grav.git
synced 2026-03-01 18:11:25 +01:00
Flex SimpleStorage: added support for prefix (keeps items under nested array)
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
1. [](#bugfix)
|
||||
* Regression: Fixed fatal error in blueprints [#2811](https://github.com/getgrav/grav/issues/2811)
|
||||
* Regression: Fixed bad method call in FlexDirectory::getAuthorizeRule()
|
||||
* Regression: Fixed fatal error in admin if the site has custom permissions in `onAdminRegisterPermissions`
|
||||
|
||||
# v1.7.0-rc.5
|
||||
## 02/03/2020
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace Grav\Framework\Acl;
|
||||
|
||||
use Grav\Common\Inflector;
|
||||
|
||||
/**
|
||||
* Class Action
|
||||
* @package Grav\Framework\Acl
|
||||
@@ -37,10 +39,20 @@ class Action implements \IteratorAggregate, \Countable
|
||||
*/
|
||||
public function __construct(string $name, array $action = [])
|
||||
{
|
||||
$label = $action['label'] ?? null;
|
||||
if (!$label) {
|
||||
if ($pos = strrpos($name, '.')) {
|
||||
$label = substr($name, $pos + 1);
|
||||
} else {
|
||||
$label = $name;
|
||||
}
|
||||
$label = Inflector::humanize($label, 'all');
|
||||
}
|
||||
|
||||
$this->name = $name;
|
||||
$this->type = $action['type'] ?? 'action';
|
||||
$this->visible = (bool)($action['visible'] ?? true);
|
||||
$this->label = $action['label'] ?? null;
|
||||
$this->label = $label;
|
||||
unset($action['type'], $action['label']);
|
||||
$this->params = $action;
|
||||
|
||||
|
||||
@@ -212,12 +212,12 @@ class Permissions implements \ArrayAccess, \Countable, \IteratorAggregate
|
||||
protected function getParent(string $name): ?Action
|
||||
{
|
||||
if ($pos = strrpos($name, '.')) {
|
||||
$name = substr($name, 0, $pos);
|
||||
$parentName = substr($name, 0, $pos);
|
||||
|
||||
$parent = $this->getAction($name);
|
||||
$parent = $this->getAction($parentName);
|
||||
if (!$parent) {
|
||||
// TODO: create parent action(s) on the fly
|
||||
throw new \RuntimeException(__METHOD__ . '(): Adding child action before parent is not supported');
|
||||
$parent = new Action($parentName);
|
||||
$this->addAction($parent);
|
||||
}
|
||||
|
||||
return $parent;
|
||||
|
||||
Reference in New Issue
Block a user