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


PHP Utils::setDotNotation方法代码示例

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


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

示例1: 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');
     $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);
         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:indigo423,项目名称:blog.no42.org,代码行数:54,代码来源:controller.php

示例2: testSetDotNotation

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


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