本文整理汇总了PHP中Grav\Common\Utils::resolve方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::resolve方法的具体用法?PHP Utils::resolve怎么用?PHP Utils::resolve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Utils
的用法示例。
在下文中一共展示了Utils::resolve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* Save a group
*/
public function save()
{
$blueprints = new Blueprints('blueprints://');
$blueprint = $blueprints->get('user/group');
$fields = $blueprint->fields();
self::getGrav()['config']->set("groups.{$this->groupname}", []);
foreach ($fields as $field) {
if ($field['type'] == 'text') {
$value = $field['name'];
if (isset($this->items[$value])) {
self::getGrav()['config']->set("groups.{$this->groupname}.{$value}", $this->items[$value]);
}
}
if ($field['type'] == 'array') {
$value = $field['name'];
$arrayValues = Utils::resolve($this->items, $field['name']);
if ($arrayValues) {
foreach ($arrayValues as $arrayIndex => $arrayValue) {
self::getGrav()['config']->set("groups.{$this->groupname}.{$value}.{$arrayIndex}", $arrayValue);
}
}
}
}
$type = 'groups';
$blueprints = $this->blueprints("config/{$type}");
$obj = new Data(self::getGrav()['config']->get($type), $blueprints);
$file = CompiledYamlFile::instance(self::getGrav()['locator']->findResource("config://{$type}.yaml"));
$obj->file($file);
$obj->save();
}
示例2: authorize
/**
* Checks user authorization to the action.
*
* @param string $action
*
* @return bool
*/
public function authorize($action)
{
if (empty($this->items)) {
return false;
}
if (isset($this->state) && $this->state !== 'enabled') {
return false;
}
$return = false;
//Check group access level
$groups = $this->get('groups');
if ($groups) {
foreach ((array) $groups as $group) {
$permission = self::getGrav()['config']->get("groups.{$group}.access.{$action}");
$return = Utils::isPositive($permission);
if ($return === true) {
break;
}
}
}
//Check user access level
if ($this->get('access')) {
if (Utils::resolve($this->get('access'), $action) !== null) {
$permission = $this->get("access.{$action}");
$return = Utils::isPositive($permission);
}
}
return $return;
}
示例3: testResolve
public function testResolve()
{
$array = ['test' => ['test2' => 'test2Value']];
$this->assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
}