protected function _getBindModelCfg($fields = []) {
		$fieldsDb = $this->_modelConfigSync->getListFieldsDb();
		$fieldsLdap = $this->_modelConfigSync->getListFieldsLdap();
		$fieldsList = array_keys(array_flip($fieldsDb) + array_flip($fieldsLdap));
		if (!empty($fields)) {
			$fieldsList = array_intersect($fieldsList, (array)$fields);
		}
		$result = [];
		if (empty($fieldsList)) {
			return $result;
		}

		$bindModelCfg = $this->_getListBindModelCfg();
		foreach ($bindModelCfg as $checkField => $bindInfo) {
			if (!in_array($checkField, $fieldsList)) {
				continue;
			}

			foreach ($bindInfo as $bindType => $targetModels) {
				foreach ($targetModels as $targetModel => $targetModelInfo) {
					switch ($targetModel) {
						case 'Department':
							$modelDepartment = ClassRegistry::init('Department', true);
							if ($modelDepartment !== false) {
								$targetModelInfo['className'] = 'Department';
								$useBlockDepartment = $modelDepartment->hasField('block');
								if ($useBlockDepartment) {
									$targetModelInfo['fields'][] = $targetModel . '.block';
								}
							}
							break;
						case 'Manager':
						case 'Subordinate':
							$modelEmployee = ClassRegistry::init('Employee', true);
							if ($modelEmployee !== false) {
								$targetModelInfo['className'] = 'Employee';
							}
							$targetModelInfo['fields'][] = $targetModel . '.' . $this->displayField . ' AS name';
							if ($targetModel === 'Subordinate') {
								$targetModelInfo['order'] = [$targetModel . '.' . $this->displayField => 'asc'];
							}
							if ($this->hasField(CAKE_LDAP_LDAP_ATTRIBUTE_TITLE)) {
								$targetModelInfo['fields'][] = $targetModel . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE;
							}
							break;
					}
					$result[$bindType][$targetModel] = $targetModelInfo;
				}
			}
		}

		return $result;
	}
protected function _getBindModelCfg($fields = []) {
		$fieldsDb = $this->_modelConfigSync->getListFieldsDb();
		$fieldsLdap = $this->_modelConfigSync->getListFieldsLdap();
		$fieldsList = array_keys(array_flip($fieldsDb) + array_flip($fieldsLdap));
		if (!empty($fields)) {
			$fieldsList = array_intersect($fieldsList, (array)$fields);
		}
		$result = [];
		if (empty($fieldsList)) {
			return $result;
		}

		$bindModelCfg = $this->_getListBindModelCfg();
		foreach ($bindModelCfg as $checkField => $bindInfo) {
			if (!in_array($checkField, $fieldsList)) {
				continue;
			}

			foreach ($bindInfo as $bindType => $targetModels) {
				foreach ($targetModels as $targetModel => $targetModelInfo) {
					switch ($targetModel) {
						case 'Department':
							$modelDepartment = ClassRegistry::init('Department', true);
							if ($modelDepartment !== false) {
								$targetModelInfo['className'] = 'Department';
								$useBlockDepartment = $modelDepartment->hasField('block');
								if ($useBlockDepartment) {
									$targetModelInfo['fields'][] = $targetModel . '.block';
								}
							}
							break;
						case 'Manager':
						case 'Subordinate':
							$modelEmployee = ClassRegistry::init('Employee', true);
							if ($modelEmployee !== false) {
								$targetModelInfo['className'] = 'Employee';
							}
							$targetModelInfo['fields'][] = $targetModel . '.' . $this->displayField . ' AS name';
							if ($targetModel === 'Subordinate') {
								$targetModelInfo['order'] = [$targetModel . '.' . $this->displayField => 'asc'];
							}
							if ($this->hasField(CAKE_LDAP_LDAP_ATTRIBUTE_TITLE)) {
								$targetModelInfo['fields'][] = $targetModel . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE;
							}
							break;
					}
					$result[$bindType][$targetModel] = $targetModelInfo;
				}
			}
		}

		return $result;
	}
protected function _getBindModelCfg ( $ fields = [ ] ) { $ fieldsDb = $ this -> _modelConfigSync -> getListFieldsDb ( ) ; $ fieldsLdap = $ this -> _modelConfigSync -> getListFieldsLdap ( ) ; $ fieldsList = array_keys ( array_flip ( $ fieldsDb ) + array_flip ( $ fieldsLdap ) ) ; if ( ! empty ( $ fields ) ) { $ fieldsList = array_intersect ( $ fieldsList , ( array ) $ fields ) ; } $ result = [ ] ; if ( empty ( $ fieldsList ) ) { return $ result ; } $ bindModelCfg = $ this -> _getListBindModelCfg ( ) ; foreach ( $ bindModelCfg as $ checkField => $ bindInfo ) { if ( ! in_array ( $ checkField , $ fieldsList ) ) { continue ; } foreach ( $ bindInfo as $ bindType => $ targetModels ) { foreach ( $ targetModels as $ targetModel => $ targetModelInfo ) { switch ( $ targetModel ) { case 'Department' : $ modelDepartment = ClassRegistry :: init ( 'Department' , true ) ; if ( $ modelDepartment !== false ) { $ targetModelInfo [ 'className' ] = 'Department' ; $ useBlockDepartment = $ modelDepartment -> hasField ( 'block' ) ; if ( $ useBlockDepartment ) { $ targetModelInfo [ 'fields' ] [ ] = $ targetModel . '.block' ; } } break ; case 'Manager' : case 'Subordinate' : $ modelEmployee = ClassRegistry :: init ( 'Employee' , true ) ; if ( $ modelEmployee !== false ) { $ targetModelInfo [ 'className' ] = 'Employee' ; } $ targetModelInfo [ 'fields' ] [ ] = $ targetModel . '.' . $ this -> displayField . ' AS name' ; if ( $ targetModel === 'Subordinate' ) { $ targetModelInfo [ 'order' ] = [ $ targetModel . '.' . $ this -> displayField => 'asc' ] ; } if ( $ this -> hasField ( CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ) ) { $ targetModelInfo [ 'fields' ] [ ] = $ targetModel . '.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ; } break ; } $ result [ $ bindType ] [ $ targetModel ] = $ targetModelInfo ; } } } return $ result ; }
Return configuration for binding associated models

@param array|string $fields List of fields for checking on
binding associated models
@return array Return configuration for binding models.
Return configuration for binding associated models