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


PHP Page::modifyHeader方法代码示例

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


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

示例1: addExtra

 /**
  * Add extra items to the shortcodes stream.
  *
  * @param string $group   The group name to add the extra items to.
  * @param any    $extra   The item to store.
  */
 public function addExtra($group, $method, $arguments = null)
 {
     $header = $this->page->header();
     $arguments = is_array($arguments) ? $arguments : [$arguments];
     // Modify page header
     $shortcodes = isset($header->shortcodes) ? $header->shortcodes : [];
     $shortcodes['extra'][$group][] = [$method, $arguments];
     // Temporally store Shortcode extras in page header
     $this->page->modifyHeader('shortcodes', $shortcodes);
     if ($this->page->id() == self::getGrav()['page']->id()) {
         $object = $group != 'page' ? self::getGrav()[$group] : $page;
         call_user_func_array([$object, $method], $arguments);
     }
 }
开发者ID:Sommerregen,项目名称:grav-plugin-shortcodes,代码行数:20,代码来源:Shortcodes.php

示例2: mergeConfig

 /**
  * Merge global and page configurations.
  *
  * @param  Page $page   The page to merge the configurations with the
  *                      plugin settings.
  *
  * @param bool  $deep   Should you use deep or shallow merging
  *
  * @return \Grav\Common\Data\Data
  */
 protected function mergeConfig(Page $page, $deep = false)
 {
     $class_name = $this->name;
     $class_name_merged = $class_name . '.merged';
     $defaults = $this->config->get('plugins.' . $class_name, array());
     $header = array();
     if (isset($page->header()->{$class_name_merged})) {
         $merged = $page->header()->{$class_name_merged};
         if (count($merged) > 0) {
             return $merged;
         } else {
             return new Data($defaults);
         }
     }
     // Get default plugin configurations and retrieve page header configuration
     if (isset($page->header()->{$class_name})) {
         if ($deep) {
             $header = array_replace_recursive($defaults, $page->header()->{$class_name});
         } else {
             $header = array_merge($defaults, $page->header()->{$class_name});
         }
     } else {
         $header = $defaults;
     }
     // Create new config object and set it on the page object so it's cached for next time
     $config = new Data($header);
     $page->modifyHeader($class_name_merged, $config);
     // Return configurations as a new data config class
     return $config;
 }
开发者ID:alexslack,项目名称:faith-game,代码行数:40,代码来源:Plugin.php

示例3: mergeConfig

 /**
  * Merge global and page configurations.
  *
  * @param Page  $page    The page to merge the configurations with the
  *                       plugin settings.
  * @param bool  $deep    Should you use deep or shallow merging
  * @param array $params  Array of additional configuration options to
  *                       merge with the plugin settings.
  *
  * @return \Grav\Common\Data\Data
  */
 protected function mergeConfig(Page $page, $deep = false, $params = [])
 {
     $class_name = $this->name;
     $class_name_merged = $class_name . '.merged';
     $defaults = $this->config->get('plugins.' . $class_name, []);
     $page_header = $page->header();
     $header = [];
     if (!isset($page_header->{$class_name_merged}) && isset($page_header->{$class_name})) {
         // Get default plugin configurations and retrieve page header configuration
         $config = $page_header->{$class_name};
         if (is_bool($config)) {
             // Overwrite enabled option with boolean value in page header
             $config = ['enabled' => $config];
         }
         // Merge page header settings using deep or shallow merging technique
         if ($deep) {
             $header = array_replace_recursive($defaults, $config);
         } else {
             $header = array_merge($defaults, $config);
         }
         // Create new config object and set it on the page object so it's cached for next time
         $page->modifyHeader($class_name_merged, new Data($header));
     } else {
         if (isset($page_header->{$class_name_merged})) {
             $merged = $page_header->{$class_name_merged};
             $header = $merged->toArray();
         }
     }
     if (empty($header)) {
         $header = $defaults;
     }
     // Merge additional parameter with configuration options
     if ($deep) {
         $header = array_replace_recursive($header, $params);
     } else {
         $header = array_merge($header, $params);
     }
     // Return configurations as a new data config class
     return new Data($header);
 }
开发者ID:indigo423,项目名称:blog.no42.org,代码行数:51,代码来源:Plugin.php

示例4: storeFiles

 /**
  * @param \Grav\Common\Page\Page|\Grav\Common\Data\Data $obj
  *
  * @return \Grav\Common\Page\Page|\Grav\Common\Data\Data
  */
 protected function storeFiles($obj)
 {
     // Process previously uploaded files for the current URI
     // and finally store them. Everything else will get discarded
     $queue = $this->admin->session()->getFlashObject('files-upload');
     $queue = $queue[base64_encode($this->grav['uri']->url())];
     if (is_array($queue)) {
         foreach ($queue as $key => $files) {
             foreach ($files as $destination => $file) {
                 if (!rename($file['tmp_name'], $destination)) {
                     throw new \RuntimeException(sprintf($this->admin->translate('PLUGIN_ADMIN.FILEUPLOAD_UNABLE_TO_MOVE', null), '"' . $file['tmp_name'] . '"', $destination));
                 }
                 unset($files[$destination]['tmp_name']);
             }
             if ($this->view == 'pages') {
                 $keys = explode('.', preg_replace('/^header./', '', $key));
                 $init_key = array_shift($keys);
                 if (count($keys) > 0) {
                     $new_data = isset($obj->header()->{$init_key}) ? $obj->header()->{$init_key} : [];
                     Utils::setDotNotation($new_data, implode('.', $keys), $files, true);
                 } else {
                     $new_data = $files;
                 }
                 if (isset($data['header'][$init_key])) {
                     $obj->modifyHeader($init_key, array_replace_recursive([], $data['header'][$init_key], $new_data));
                 } else {
                     $obj->modifyHeader($init_key, $new_data);
                 }
             } else {
                 // TODO: [this is JS handled] if it's single file, remove existing and use set, if it's multiple, use join
                 $obj->join($key, $files);
                 // stores
             }
         }
     }
     return $obj;
 }
开发者ID:getgrav,项目名称:grav-plugin-admin,代码行数:42,代码来源:adminbasecontroller.php


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