public function getQueryConfig($target = null) {
		$targetModels = $this->_modelConfigSearchInfo->getTargetModels();
		$cachePath = null;
		$result = [
			'anyPart' => $this->getAnyPartFlag($target),
			'modelConfig' => []
		];

		if (empty($target)) {
			$result['modelConfig'] = $targetModels;

			return $result;
		}

		if (!is_array($target)) {
			$target = [$target];
		}

		$language = (string)Configure::read('Config.language');
		$dataStr = serialize($targetModels + $target) . '_' . $language;
		$cachePath = 'QueryConfig.' . md5($dataStr);
		$cached = Cache::read($cachePath, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);
		if (!empty($cached)) {
			return $cached;
		}

		$targetDeep = $this->_modelConfigSearchInfo->getTargetDeep();
		if ($targetDeep < 1) {
			$result['modelConfig'] = array_intersect_key($targetModels, array_flip($target));
		} else {
			$modelConfig = [];
			foreach ($target as $targetModelField) {
				if (strpos($targetModelField, '.') === false) {
					continue;
				}

				list($targetModel, $targetField) = pluginSplit($targetModelField);
				if (!isset($targetModels[$targetModel]['fields'][$targetField])) {
					continue;
				}

				$targetData = $targetModels[$targetModel];
				$targetData['fields'] = [$targetField => $targetModels[$targetModel]['fields'][$targetField]];
				$modelConfig = Hash::mergeDiff($modelConfig, [$targetModel => $targetData]);
			}
			foreach ($modelConfig as $modelName => &$modelCfg) {
				if (isset($modelCfg['order'])) {
					if (is_array($modelCfg['order']) && (count($modelCfg['order']) === 1) &&
						(count(array_intersect_key($modelCfg['order'], $modelCfg['fields'])) === 1)) {
						continue;
					}
				}
				$fields = array_keys($modelCfg['fields']);
				$field = array_shift($fields);
				if (empty($field)) {
					if (isset($modelCfg['order'])) {
						unset($modelCfg['order']);
					}
				}
			}
			$result['modelConfig'] = $modelConfig;
		}
		Cache::write($cachePath, $result, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);

		return $result;
	}
public function getQueryConfig($target = null) {
		$targetModels = $this->_modelConfigSearchInfo->getTargetModels();
		$cachePath = null;
		$result = [
			'anyPart' => $this->getAnyPartFlag($target),
			'modelConfig' => []
		];

		if (empty($target)) {
			$result['modelConfig'] = $targetModels;

			return $result;
		}

		if (!is_array($target)) {
			$target = [$target];
		}

		$language = (string)Configure::read('Config.language');
		$dataStr = serialize($targetModels + $target) . '_' . $language;
		$cachePath = 'QueryConfig.' . md5($dataStr);
		$cached = Cache::read($cachePath, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);
		if (!empty($cached)) {
			return $cached;
		}

		$targetDeep = $this->_modelConfigSearchInfo->getTargetDeep();
		if ($targetDeep < 1) {
			$result['modelConfig'] = array_intersect_key($targetModels, array_flip($target));
		} else {
			$modelConfig = [];
			foreach ($target as $targetModelField) {
				if (strpos($targetModelField, '.') === false) {
					continue;
				}

				list($targetModel, $targetField) = pluginSplit($targetModelField);
				if (!isset($targetModels[$targetModel]['fields'][$targetField])) {
					continue;
				}

				$targetData = $targetModels[$targetModel];
				$targetData['fields'] = [$targetField => $targetModels[$targetModel]['fields'][$targetField]];
				$modelConfig = Hash::mergeDiff($modelConfig, [$targetModel => $targetData]);
			}
			foreach ($modelConfig as $modelName => &$modelCfg) {
				if (isset($modelCfg['order'])) {
					if (is_array($modelCfg['order']) && (count($modelCfg['order']) === 1) &&
						(count(array_intersect_key($modelCfg['order'], $modelCfg['fields'])) === 1)) {
						continue;
					}
				}
				$fields = array_keys($modelCfg['fields']);
				$field = array_shift($fields);
				if (empty($field)) {
					if (isset($modelCfg['order'])) {
						unset($modelCfg['order']);
					}
				}
			}
			$result['modelConfig'] = $modelConfig;
		}
		Cache::write($cachePath, $result, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);

		return $result;
	}
public function getQueryConfig ( $ target = null ) { $ targetModels = $ this -> _modelConfigSearchInfo -> getTargetModels ( ) ; $ cachePath = null ; $ result = [ 'anyPart' => $ this -> getAnyPartFlag ( $ target ) , 'modelConfig' => [ ] ] ; if ( empty ( $ target ) ) { $ result [ 'modelConfig' ] = $ targetModels ; return $ result ; } if ( ! is_array ( $ target ) ) { $ target = [ $ target ] ; } $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ dataStr = serialize ( $ targetModels + $ target ) . '_' . $ language ; $ cachePath = 'QueryConfig.' . md5 ( $ dataStr ) ; $ cached = Cache :: read ( $ cachePath , CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } $ targetDeep = $ this -> _modelConfigSearchInfo -> getTargetDeep ( ) ; if ( $ targetDeep < 1 ) { $ result [ 'modelConfig' ] = array_intersect_key ( $ targetModels , array_flip ( $ target ) ) ; } else { $ modelConfig = [ ] ; foreach ( $ target as $ targetModelField ) { if ( strpos ( $ targetModelField , '.' ) === false ) { continue ; } list ( $ targetModel , $ targetField ) = pluginSplit ( $ targetModelField ) ; if ( ! isset ( $ targetModels [ $ targetModel ] [ 'fields' ] [ $ targetField ] ) ) { continue ; } $ targetData = $ targetModels [ $ targetModel ] ; $ targetData [ 'fields' ] = [ $ targetField => $ targetModels [ $ targetModel ] [ 'fields' ] [ $ targetField ] ] ; $ modelConfig = Hash :: mergeDiff ( $ modelConfig , [ $ targetModel => $ targetData ] ) ; } foreach ( $ modelConfig as $ modelName => & $ modelCfg ) { if ( isset ( $ modelCfg [ 'order' ] ) ) { if ( is_array ( $ modelCfg [ 'order' ] ) && ( count ( $ modelCfg [ 'order' ] ) === 1 ) && ( count ( array_intersect_key ( $ modelCfg [ 'order' ] , $ modelCfg [ 'fields' ] ) ) === 1 ) ) { continue ; } } $ fields = array_keys ( $ modelCfg [ 'fields' ] ) ; $ field = array_shift ( $ fields ) ; if ( empty ( $ field ) ) { if ( isset ( $ modelCfg [ 'order' ] ) ) { unset ( $ modelCfg [ 'order' ] ) ; } } } $ result [ 'modelConfig' ] = $ modelConfig ; } Cache :: write ( $ cachePath , $ result , CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG ) ; return $ result ; }
Get configuration for query

@param string|array $target Target fields or model.
@return array Return array of configuration for query in format:
- deep 0:
[
'anyPart' => false,
'modelConfig' => [
'ModelName' => [
'fields' => [
'ModelName.FieldName1' => __('Field name 1'),
'ModelName.FieldName2' => __('Field name 2'),
'ModelName.FieldName3' => __('Field name 3'),
'ModelName.FieldName4' => __('Field name 4'),
'ModelName.FieldName5' => __('Field name 5')
],
'order' => [
'ModelName.FieldName' => 'direction'
],
'name' => __('Scope name')
]
]
]
- deep 1:
[
'anyPart' => false,
'modelConfig' => [
'ModelName' => [
'fields' => [
'ModelName.FieldName' => __('Field name')
],
'order' => [
'ModelName.FieldName' => 'direction'
],
'conditions' => [
'ModelName.FieldName' => 'SomeValue'
],
'name' => __('Scope name'),
]
]
]
Get configuration for query