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