當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。