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