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


PHP Utils::getDotNotation方法代码示例

本文整理汇总了PHP中Grav\Common\Utils::getDotNotation方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::getDotNotation方法的具体用法?PHP Utils::getDotNotation怎么用?PHP Utils::getDotNotation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grav\Common\Utils的用法示例。


在下文中一共展示了Utils::getDotNotation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * Save a group
  */
 public function save()
 {
     $grav = Grav::instance();
     $config = $grav['config'];
     $blueprints = new Blueprints();
     $blueprint = $blueprints->get('user/group');
     $fields = $blueprint->fields();
     $config->set("groups.{$this->groupname}", []);
     foreach ($fields as $field) {
         if ($field['type'] == 'text') {
             $value = $field['name'];
             if (isset($this->items['data'][$value])) {
                 $config->set("groups.{$this->groupname}.{$value}", $this->items['data'][$value]);
             }
         }
         if ($field['type'] == 'array') {
             $value = $field['name'];
             $arrayValues = Utils::getDotNotation($this->items['data'], $field['name']);
             if ($arrayValues) {
                 foreach ($arrayValues as $arrayIndex => $arrayValue) {
                     $config->set("groups.{$this->groupname}.{$value}.{$arrayIndex}", $arrayValue);
                 }
             }
         }
     }
     $type = 'groups';
     $blueprints = $this->blueprints("config/{$type}");
     $obj = new Data($config->get($type), $blueprints);
     $file = CompiledYamlFile::instance($grav['locator']->findResource("config://{$type}.yaml"));
     $obj->file($file);
     $obj->save();
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:35,代码来源:Group.php

示例2: normalizeFiles

 /**
  * Internal method to normalize the $_FILES array
  *
  * @param array  $data $_FILES starting point data
  * @param string $key
  * @return object a new Object with a normalized list of files
  */
 protected function normalizeFiles($data, $key = '')
 {
     $files = new \stdClass();
     $files->field = $key;
     $files->file = new \stdClass();
     foreach ($data as $fieldName => $fieldValue) {
         // Since Files Upload are always happening via Ajax
         // we are not interested in handling `multiple="true"`
         // because they are always handled one at a time.
         // For this reason we normalize the value to string,
         // in case it is arriving as an array.
         $value = (array) Utils::getDotNotation($fieldValue, $key);
         $files->file->{$fieldName} = array_shift($value);
     }
     return $files;
 }
开发者ID:getgrav,项目名称:grav-plugin-form,代码行数:23,代码来源:form.php

示例3: testGetDotNotation

 public function testGetDotNotation()
 {
     $array = ['test' => ['test2' => 'test2Value', 'test3' => ['test4' => 'test4Value']]];
     $this->assertEquals('test2Value', Utils::getDotNotation($array, 'test.test2'));
     $this->assertEquals('test4Value', Utils::getDotNotation($array, 'test.test3.test4'));
     $this->assertEquals('defaultValue', Utils::getDotNotation($array, 'test.non_existent', 'defaultValue'));
 }
开发者ID:getgrav,项目名称:grav,代码行数:7,代码来源:UtilsTest.php

示例4: taskRemoveFileFromBlueprint

 /**
  * Handle deleting a file from a blueprint
  *
  * @return bool True if the action was performed.
  */
 protected function taskRemoveFileFromBlueprint()
 {
     $uri = $this->grav['uri'];
     $blueprint = base64_decode($uri->param('blueprint'));
     $path = base64_decode($uri->param('path'));
     $proute = base64_decode($uri->param('proute'));
     $type = $uri->param('type');
     $field = $uri->param('field');
     $event = $this->grav->fireEvent('onAdminCanSave', new Event(['controller' => &$this]));
     if (!$event['can_save']) {
         return false;
     }
     $this->taskRemoveMedia();
     if ($type == 'pages') {
         $page = $this->admin->page(true, $proute);
         $keys = explode('.', preg_replace('/^header./', '', $field));
         $header = (array) $page->header();
         $data_path = implode('.', $keys);
         $data = Utils::getDotNotation($header, $data_path);
         if (isset($data[$path])) {
             unset($data[$path]);
             Utils::setDotNotation($header, $data_path, $data);
             $page->header($header);
         }
         $page->save();
     } else {
         $blueprint_prefix = $type == 'config' ? '' : $type . '.';
         $blueprint_name = str_replace('/blueprints', '', str_replace('config/', '', $blueprint));
         $blueprint_field = $blueprint_prefix . $blueprint_name . '.' . $field;
         $files = $this->grav['config']->get($blueprint_field);
         if ($files) {
             foreach ($files as $key => $value) {
                 if ($key == $path) {
                     unset($files[$key]);
                 }
             }
         }
         $this->grav['config']->set($blueprint_field, $files);
         switch ($type) {
             case 'config':
                 $data = $this->grav['config']->get($blueprint_name);
                 $config = $this->admin->data($blueprint, $data);
                 $config->save();
                 break;
             case 'themes':
                 Theme::saveConfig($blueprint_name);
                 break;
             case 'plugins':
                 Plugin::saveConfig($blueprint_name);
                 break;
         }
     }
     $this->admin->json_response = ['status' => 'success', 'message' => $this->admin->translate('PLUGIN_ADMIN.REMOVE_SUCCESSFUL')];
     return true;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:60,代码来源:adminbasecontroller.php

示例5: 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 = Grav::instance()['config']->get("groups.{$group}.access.{$action}");
             $return = Utils::isPositive($permission);
             if ($return === true) {
                 break;
             }
         }
     }
     //Check user access level
     if ($this->get('access')) {
         if (Utils::getDotNotation($this->get('access'), $action) !== null) {
             $permission = $this->get("access.{$action}");
             $return = Utils::isPositive($permission);
         }
     }
     return $return;
 }
开发者ID:dweelie,项目名称:grav,代码行数:36,代码来源:User.php


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