当前位置: 首页>>代码示例>>PHP>>正文


PHP ArrayHelper::isAssoc方法代码示例

本文整理汇总了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;
 }
开发者ID:bangkok,项目名称:CodeExample,代码行数:27,代码来源:MoneyFormat.php

示例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;
 }
开发者ID:vasiliy-pdk,项目名称:aes,代码行数:76,代码来源:RestController.php


注:本文中的ArrayHelper::isAssoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。