本文整理汇总了PHP中ArrayHelper::isAssoc方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::isAssoc方法的具体用法?PHP ArrayHelper::isAssoc怎么用?PHP ArrayHelper::isAssoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayHelper
的用法示例。
在下文中一共展示了ArrayHelper::isAssoc方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _attributesTo
protected static function _attributesTo($dimension, $modelData, $attributes = NULL)
{
$attributes = self::_parseMoneyAttributes($modelData, $attributes);
foreach ($attributes as $key => $attribute) {
$name = is_string($key) ? $key : $attribute;
if (empty($modelData[$name]) and !is_object($modelData) || empty($modelData->{$name})) {
continue;
}
$value = $modelData[$name];
if (is_array($attribute)) {
if (!ArrayHelper::isAssoc($attribute, true)) {
$modelData[$name] = self::_arrayTo($dimension, $value, $attribute);
} elseif (is_array($value) or is_object($value)) {
$modelData[$name] = self::_attributesTo($dimension, $value, $attribute);
} else {
$modelData[$name] = self::_to($dimension, $value);
}
} else {
if (is_array($value)) {
$modelData[$name] = self::_arrayTo($dimension, $value);
} else {
$modelData[$name] = self::_to($dimension, $value);
}
}
}
return $modelData;
}
示例2: beforeAction
public function beforeAction($event)
{
$result = parent::beforeAction($event);
//decode extjs filters format
if (is_string($this->restFilter) && isset($_GET['extjs'])) {
$this->restFilter = CJSON::decode($this->restFilter);
//convert operators to accepted format by ERestHelperScopes
foreach ($this->restFilter as $index => $filter) {
if (isset($filter['operator'])) {
$this->restFilter[$index]['operator'] = $this->convertFilterOperator($filter['operator']);
}
}
}
if (ArrayHelper::isAssoc($this->restFilter)) {
//Conversion needed
if (!empty($this->acceptFilters['plain'])) {
$plainKeys = AESHelper::explode($this->acceptFilters['plain']);
foreach ($plainKeys as $key) {
if (isset($this->restFilter[$key])) {
$this->plainFilter[$key] = $this->restFilter[$key];
}
}
} else {
//copy all to plainFilter
foreach ($this->restFilter as $key => $value) {
$this->plainFilter[$key] = $value;
}
}
if (!empty($this->acceptFilters['model'])) {
$acceptableKeys = AESHelper::explode($this->acceptFilters['model']);
foreach ($this->restFilter as $key => $value) {
if (!in_array($key, $acceptableKeys)) {
unset($this->restFilter[$key]);
} elseif ($value == '') {
$this->restFilter[$key] = null;
}
}
}
if ($this->convertRestFilters) {
//Convert filters to acceptable format
$convertedFilter = array();
foreach ($this->restFilter as $filterName => $value) {
if (!is_array($value) || !key_exists('property', $value) && !key_exists('value', $value)) {
$convertedFilter[] = array('property' => $filterName, 'value' => $value);
} else {
$convertedFilter[] = $value;
}
}
$this->restFilter = $convertedFilter;
}
} else {
//Filters are in acceptable format
$plainKeys = array();
$filterableModelKeys = array();
if (!empty($this->acceptFilters['plain'])) {
$plainKeys = AESHelper::explode($this->acceptFilters['plain']);
}
if (!empty($this->acceptFilters['model'])) {
$filterableModelKeys = AESHelper::explode($this->acceptFilters['model']);
}
$checkPlain = (bool) count($plainKeys);
$checkModel = (bool) count($filterableModelKeys);
if ($checkModel || $checkPlain) {
foreach ($this->restFilter as $index => $filter) {
$filterKey = $filter['property'];
if ($checkPlain && in_array($filterKey, $plainKeys)) {
$this->plainFilter[$filterKey] = $filter['value'];
}
if ($checkModel && !in_array($filterKey, $filterableModelKeys)) {
unset($this->restFilter[$index]);
}
}
}
}
return $result;
}