本文整理匯總了PHP中ArrayUtil::normalizeToArrayR方法的典型用法代碼示例。如果您正苦於以下問題:PHP ArrayUtil::normalizeToArrayR方法的具體用法?PHP ArrayUtil::normalizeToArrayR怎麽用?PHP ArrayUtil::normalizeToArrayR使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil::normalizeToArrayR方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: normalizeToWidgetJSONPropertiesStructures
/**
* Ensures that each subarray in $currentFields corresponds to a JSON properties structure
* definition defined in some SortableWidget subclass.
*
* @param array $expectedFields The array with key => default value pairs
* @param array $currentFields The array to copy values from
* @return array
*/
private function normalizeToWidgetJSONPropertiesStructures($expectedFields, $currentFields)
{
$fields = array();
foreach ($currentFields as $key => $val) {
// widget class name can optionally be followed by a sequence of digits. This is
// used for widget cloning
$widgetClassName = preg_replace("/_\\w+\$/", '', $key);
if (is_array($val) && isset($currentFields[$key]) && is_array($expectedFields[$widgetClassName])) {
// JSON property structure definitions can be nested
$fields[$key] = ArrayUtil::normalizeToArrayR($expectedFields[$widgetClassName], $currentFields[$key]);
}
}
foreach ($expectedFields as $key => $val) {
if (!isset($fields[$key])) {
$fields[$key] = $expectedFields[$key];
}
}
return $fields;
}
示例2: unpackAttribute
/**
* JSON-decodes the value stored in the database column for the attribute,
* and then normalizes it to the structure defined in {@link fields}
* @param string $name The attribute to be unpacked
* @return type
*/
public function unpackAttribute($name)
{
$fields = $this->fields($name);
$attribute = CJSON::decode($this->getOwner()->{$name});
$attribute = is_array($attribute) ? ArrayUtil::normalizeToArrayR($fields, $attribute, $this->maintainCurrentFieldsOrder) : $fields;
return $attribute;
}