Flex SimpleStorage: added support for prefix (keeps items under nested array)

This commit is contained in:
Matias Griese
2020-02-06 11:52:51 +02:00
parent 10589e7940
commit ceaa20d5d4
3 changed files with 18 additions and 5 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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;