protected function _getTargetFields($isList = false) {
		$result = [];
		$targetModels = $this->_modelConfigSearchInfo->getTargetModels();
		$targetDeep = $this->_modelConfigSearchInfo->getTargetDeep();
		$cachePath = null;
		if (empty($targetModels)) {
			return $result;
		}

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

		foreach ($targetModels as $modelName => $modelConfig) {
			$modelObj = ClassRegistry::init($modelName, true);
			if ($modelObj === false) {
				continue;
			}

			if (empty($modelConfig) || !is_array($modelConfig)) {
				continue;
			}

			$modelLabel = (isset($modelConfig['name']) ? $modelConfig['name'] : $modelName);
			if ($targetDeep < 1) {
				if ($isList) {
					$result[] = $modelName;
				} else {
					$result[$modelLabel] = $modelName;
				}
			} else {
				if (!isset($modelConfig['fields']) || empty($modelConfig['fields'])) {
					continue;
				}

				foreach ($modelConfig['fields'] as $modelFieldName => $fieldLabel) {
					if (!$this->_checkFieldType($modelFieldName)) {
						continue;
					}

					if ($isList) {
						$result[] = $modelName . '.' . $modelFieldName;
					} else {
						$result[$modelLabel][$modelName . '.' . $modelFieldName] = $fieldLabel;
					}
				}
			}
		}
		if ($isList) {
			if (($targetDeep > 0) && !empty($result)) {
				$result = array_values(array_unique($result));
			}
		}
		Cache::write($cachePath, $result, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);

		return $result;
	}
protected function _getTargetFields($isList = false) {
		$result = [];
		$targetModels = $this->_modelConfigSearchInfo->getTargetModels();
		$targetDeep = $this->_modelConfigSearchInfo->getTargetDeep();
		$cachePath = null;
		if (empty($targetModels)) {
			return $result;
		}

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

		foreach ($targetModels as $modelName => $modelConfig) {
			$modelObj = ClassRegistry::init($modelName, true);
			if ($modelObj === false) {
				continue;
			}

			if (empty($modelConfig) || !is_array($modelConfig)) {
				continue;
			}

			$modelLabel = (isset($modelConfig['name']) ? $modelConfig['name'] : $modelName);
			if ($targetDeep < 1) {
				if ($isList) {
					$result[] = $modelName;
				} else {
					$result[$modelLabel] = $modelName;
				}
			} else {
				if (!isset($modelConfig['fields']) || empty($modelConfig['fields'])) {
					continue;
				}

				foreach ($modelConfig['fields'] as $modelFieldName => $fieldLabel) {
					if (!$this->_checkFieldType($modelFieldName)) {
						continue;
					}

					if ($isList) {
						$result[] = $modelName . '.' . $modelFieldName;
					} else {
						$result[$modelLabel][$modelName . '.' . $modelFieldName] = $fieldLabel;
					}
				}
			}
		}
		if ($isList) {
			if (($targetDeep > 0) && !empty($result)) {
				$result = array_values(array_unique($result));
			}
		}
		Cache::write($cachePath, $result, CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG);

		return $result;
	}
protected function _getTargetFields ( $ isList = false ) { $ result = [ ] ; $ targetModels = $ this -> _modelConfigSearchInfo -> getTargetModels ( ) ; $ targetDeep = $ this -> _modelConfigSearchInfo -> getTargetDeep ( ) ; $ cachePath = null ; if ( empty ( $ targetModels ) ) { return $ result ; } $ language = ( string ) Configure :: read ( 'Config.language' ) ; $ dataStr = serialize ( $ targetModels + compact ( 'targetDeep' , 'isList' , 'language' ) ) ; $ cachePath = 'TargetFields.' . md5 ( $ dataStr ) ; $ cached = Cache :: read ( $ cachePath , CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG ) ; if ( ! empty ( $ cached ) ) { return $ cached ; } foreach ( $ targetModels as $ modelName => $ modelConfig ) { $ modelObj = ClassRegistry :: init ( $ modelName , true ) ; if ( $ modelObj === false ) { continue ; } if ( empty ( $ modelConfig ) || ! is_array ( $ modelConfig ) ) { continue ; } $ modelLabel = ( isset ( $ modelConfig [ 'name' ] ) ? $ modelConfig [ 'name' ] : $ modelName ) ; if ( $ targetDeep < 1 ) { if ( $ isList ) { $ result [ ] = $ modelName ; } else { $ result [ $ modelLabel ] = $ modelName ; } } else { if ( ! isset ( $ modelConfig [ 'fields' ] ) || empty ( $ modelConfig [ 'fields' ] ) ) { continue ; } foreach ( $ modelConfig [ 'fields' ] as $ modelFieldName => $ fieldLabel ) { if ( ! $ this -> _checkFieldType ( $ modelFieldName ) ) { continue ; } if ( $ isList ) { $ result [ ] = $ modelName . '.' . $ modelFieldName ; } else { $ result [ $ modelLabel ] [ $ modelName . '.' . $ modelFieldName ] = $ fieldLabel ; } } } } if ( $ isList ) { if ( ( $ targetDeep > 0 ) && ! empty ( $ result ) ) { $ result = array_values ( array_unique ( $ result ) ) ; } } Cache :: write ( $ cachePath , $ result , CAKE_SEARCH_INFO_CACHE_KEY_QUERY_CFG ) ; return $ result ; }
Get target fields information

@param bool $isList If True - return list of target fields.
Otherwise - return information about target fields.
@return array Information about target fields in format:
- deep 0:
- $isList - False:
[
__('Scope name 1') => 'ModelName1',
__('Scope name 2') => 'ModelName2',
__('Scope name 3') => 'ModelName3'
]
- $isList - True:
[
'ModelName1',
'ModelName2',
'ModelName3'
]
- deep 1:
- $isList - False:
[
__('Scope name 1') => [
'ModelName1.ModelName1.FieldName1' => __('Field name 1'),
'ModelName1.ModelName1.FieldName2' => __('Field name 2'),
'ModelName1.ModelName1.FieldName3' => __('Field name 3')
],
__('Scope name 2') => [
'ModelName2.ModelName2.FieldName1' => __('Field name 1')
],
__('Scope name 3') => [
'ModelName3.ModelName2.FieldName1' => __('Field name 1'),
'ModelName3.ModelName3.FieldName1' => __('Field name 2')
]
]
- $isList - True:
[
'ModelName1.ModelName1.FieldName1',
'ModelName1.ModelName1.FieldName2',
'ModelName1.ModelName1.FieldName3',
'ModelName2.ModelName2.FieldName1',
'ModelName3.ModelName2.FieldName1',
'ModelName3.ModelName3.FieldName1',
]
Get target fields information