当前位置: 首页>>代码示例>>PHP>>正文


PHP Utils::resolve方法代码示例

本文整理汇总了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();
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:33,代码来源:Group.php

示例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;
 }
开发者ID:jeremycherfas,项目名称:grav-blog,代码行数:36,代码来源:User.php

示例3: testResolve

 public function testResolve()
 {
     $array = ['test' => ['test2' => 'test2Value']];
     $this->assertEquals('test2Value', Utils::resolve($array, 'test.test2'));
 }
开发者ID:getgrav,项目名称:grav,代码行数:5,代码来源:UtilsTest.php


注:本文中的Grav\Common\Utils::resolve方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。