本文整理汇总了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');
}
}