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


PHP Datasource::__processParametersInString方法代码示例

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


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

示例1: setDefaultValues

 /**
  * @uses EventPreSaveFilter
  */
 public function setDefaultValues(&$context)
 {
     if (!isset($context['event']->eDefaultValues) || !is_array($context['event']->eDefaultValues)) {
         return;
     }
     // Create a Datasource class, which has the logic for finding Parameters
     // and turning them into the values.
     $datasource = new Datasource(null, false);
     // Fake an environment to find Parameters in
     $env = array('env' => Frontend::instance()->Page()->Env(), 'param' => Frontend::instance()->Page()->Params());
     // Loop over the Default Values, setting them in $_POST or `$context['fields']`
     // as appropriate.
     foreach ($context['event']->eDefaultValues as $field => $dv) {
         $value = $datasource->__processParametersInString($dv['value'], $env);
         // Custom field, this will set $_POST instead of the `$context['fields']`
         // as `$context['fields']` only contains things inside $_POST['fields']
         if ($dv['custom'] == 'yes') {
             $matches = preg_split('/\\[/U', $field);
             foreach ($matches as $key => $match) {
                 $matches[$key] = trim($match, ']');
             }
             if (count($matches) == 1) {
                 self::setArrayValue($_POST, $field, $value, $dv['override'] == 'yes');
             } else {
                 $tree = self::addKey($matches, $value);
                 // If the DV is an override, set it regardless
                 // DV is not an override, so only set if it hasn't already been set
                 if ($dv['override'] == 'no' && !self::checkArrayForTree($_POST, $tree)) {
                     $_POST = array_merge_recursive($_POST, $tree);
                 } else {
                     if ($dv['override'] == 'yes') {
                         $_POST = array_replace_recursive($_POST, $tree);
                     }
                 }
             }
             continue;
         }
         self::setArrayValue($_POST['fields'], $field, $value, $dv['override'] == 'yes');
         self::setArrayValue($context['fields'], $field, $value, $dv['override'] == 'yes');
     }
 }
开发者ID:michael-e,项目名称:default_event_values,代码行数:44,代码来源:extension.driver.php


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