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


PHP ArrayHelper::isIndexed方法代码示例

本文整理汇总了PHP中ArrayHelper::isIndexed方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayHelper::isIndexed方法的具体用法?PHP ArrayHelper::isIndexed怎么用?PHP ArrayHelper::isIndexed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ArrayHelper的用法示例。


在下文中一共展示了ArrayHelper::isIndexed方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: adjustParameters

 protected function adjustParameters(AbstractDataQueryControllerRequest $request) {
     if (isset($request->parameters)) {
         if (is_array($request->parameters) && ArrayHelper::isIndexed($request->parameters)) {
             foreach ($request->parameters as $index => $compositeParameter) {
                 $request->parameters[$index] = $this->adjustCompositeParameter($compositeParameter);
             }
         }
         else {
             $request->parameters = $this->adjustCompositeParameter($request->parameters);
         }
     }
 }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:12,代码来源:DataQueryControllerRequestCleaner.php

示例2: addCompositeQueryValues

    public function addCompositeQueryValues($compositeQuery) {
        if (!isset($compositeQuery)) {
            return;
        }

        $isIndexedArray = ArrayHelper::isIndexed($compositeQuery);
        if ($isIndexedArray && (count($compositeQuery) === 1)) {
            $compositeQuery = $compositeQuery[0];
            $isIndexedArray = FALSE;
        }

        if ($isIndexedArray) {
            foreach ($compositeQuery as $query) {
                $this->addCompositeQueryValues($query);
            }
        }
        else {
            $index = count($this->queries);

            foreach ($compositeQuery as $name => $value) {
                $this->addQueryValues($index, $name, $value);
            }
        }
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:24,代码来源:AbstractDatasetQueryRequest.php

示例3: parseParameters

    public static function parseParameters(array $parameters = NULL) {
        if (!isset($parameters)) {
            return NULL;
        }

        $adjustedParameters = NULL;

        foreach ($parameters as $parameterIndex => $parameterProperties) {
            if (!is_array($parameterProperties)) {
                $parameterProperties = array($parameterProperties);
            }

            $isParameterPropertyDetected = FALSE;

            $parameterName = NULL;
            if (is_int($parameterIndex)) {
                if (!isset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__COLUMN_NAME])) {
                    throw new IllegalArgumentException(t(
                        'Could not find corresponding column name for the parameter: %parameterIndex',
                        array('%parameterIndex' => $parameterIndex)));
                }
                $parameterName = $parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__COLUMN_NAME];

                unset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__COLUMN_NAME]);
                $isParameterPropertyDetected = TRUE;
            }
            else {
                $parameterName = $parameterIndex;
            }

            $operatorName = NULL;
            if (isset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_NAME])) {
                $operatorName = $parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_NAME];

                unset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_NAME]);
                $isParameterPropertyDetected = TRUE;
            }
            else {
                $operatorName = EqualOperatorHandler::OPERATOR__NAME;
            }

            $parameterValues = NULL;
            if (isset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_VALUE])) {
                $parameterValues = $parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_VALUE];

                unset($parameterProperties[DataQueryControllerUIParameterNames::PARAMETER__OPERATOR_VALUE]);
                $isParameterPropertyDetected = TRUE;
            }

            if (!$isParameterPropertyDetected) {
                $parameterValues = $parameterProperties;
                // marking that all properties are processed in the variable
                $parameterProperties = NULL;
            }

            // some properties are left and we do not know what to do with them
            if (count($parameterProperties) > 0) {
                throw new IllegalArgumentException(t(
                    'Unsupported keys for parameter definition: %unsupportedKeys',
                    array('%unsupportedKeys' => implode(', ', array_keys($parameterProperties)))));
            }

            $operatorValues = NULL;
            if (isset($parameterValues)) {
                if (ArrayHelper::isIndexed($parameterValues)) {
                    $operatorValues = $parameterValues;
                }
                else {
                    // named operator value parameters are provided
                    // we need to order the values in the same order as the parameters defined for the operator
                    $operatorMetaData = OperatorFactory::getInstance()->getOperatorMetaData($operatorName);
                    $operatorParameterMetaDatas = $operatorMetaData->getParameters();
                    if (isset($operatorParameterMetaDatas)) {
                        foreach ($operatorParameterMetaDatas as $operatorParameterMetaData) {
                            $name = $operatorParameterMetaData->name;

                            $value = NULL;
                            if (isset($parameterValues[$name])) {
                                $value = $parameterValues[$name];

                                unset($parameterValues[$name]);
                            }
                            $operatorValues[] = $value;
                        }
                    }

                    // some named parameters are not recognized
                    if (count($parameterValues) > 0) {
                        throw new IllegalArgumentException(t(
                            'Unsupported keys for parameter value definition: %unsupportedKeys',
                            array('%unsupportedKeys' => implode(', ', array_keys($parameterValues)))));
                    }
                }
            }

            $operator = OperatorFactory::getInstance()->initiateHandler($operatorName, $operatorValues);

            if (isset($adjustedParameters[$parameterName])) {
                $previousOperator = $adjustedParameters[$parameterName];
                if (is_array($previousOperator)) {
//.........这里部分代码省略.........
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:101,代码来源:DataQueryControllerUIRequestParser.php

示例4: mergeWith

    public static function mergeWith(&$instance, $source, $mergeCompositeProperty = FALSE, $existingPropertyRule = self::EXISTING_PROPERTY_RULE__ERROR_IF_PRESENT) {
        if (isset($source)) {
            if (is_object($source) || is_array($source)) {
                $isPropertyIndexed = ArrayHelper::isIndexed($source);
                foreach ($source as $name => $value) {
                    $value = StringHelper::trim($value);
                    $mergedValue = self::getPropertyValue($instance, $name);

                    if (is_object($value) || is_array($value)) {
                        if ($mergeCompositeProperty) {
                            self::mergeWith($mergedValue, $value, TRUE, $existingPropertyRule);
                        }
                    }
                    else {
                        if (isset($mergedValue) && isset($value)) {
                            if (($mergedValue != $value)) {
                                switch ($existingPropertyRule) {
                                    case self::EXISTING_PROPERTY_RULE__SKIP_IF_PRESENT:
                                        break;
                                    case self::EXISTING_PROPERTY_RULE__OVERRIDE_IF_PRESENT:
                                        $mergedValue = $value;
                                        break;
                                    default:
                                        LogHelper::log_error(t(
                                            "'@propertyName' property already contains value: @existingPropertyValue. Merge cannot be performed with new value: @newPropertyValue",
                                            array('@propertyName' => $name, '@existingPropertyValue' => $mergedValue, '@newPropertyValue' => $value)));
                                        throw new UnsupportedOperationException(t(
                                            '%propertyName property already contains value. Merge cannot be performed',
                                            array('%propertyName' => $name)));
                                }
                            }
                        }
                        else {
                            $mergedValue = $value;
                        }
                    }

                    if (!isset($instance)) {
                        $instance = $isPropertyIndexed ? array() : new stdClass();
                    }
                    if ($isPropertyIndexed) {
                        $instance[$name] = $mergedValue;
                    }
                    else {
                        $instance->$name = $mergedValue;
                    }
                }
            }
            else {
                if (isset($instance)) {
                    if (($instance != $source)) {
                        switch ($existingPropertyRule) {
                            case self::EXISTING_PROPERTY_RULE__SKIP_IF_PRESENT:
                                break;
                            case self::EXISTING_PROPERTY_RULE__OVERRIDE_IF_PRESENT:
                                $instance = $source;
                                break;
                            default:
                                LogHelper::log_error(t(
                                    "The instance already contains value: @existingPropertyValue. Assignment cannot be performed with new value: @newPropertyValue",
                                    array('@existingPropertyValue' => $instance, '@newPropertyValue' => $source)));
                                throw new UnsupportedOperationException(t('The instance already contains value. Assignment cannot be performed'));
                        }
                    }
                }
                else {
                    $instance = $source;
                }
            }
        }

        return $instance;
    }
开发者ID:reisystems-india,项目名称:GovDashboard-Community,代码行数:73,代码来源:ObjectHelper.php


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