src/Model/Table/Table.php
public function getRelatedInUse($tableName, $groupField = null, $type = 'all', $options = []) {
		if ($groupField === null) {
			$groupField = $this->belongsTo[$tableName]['foreignKey'];
		}
		$defaults = [
			'contain' => [$tableName],
			'group' => $groupField,
			'order' => isset($this->$tableName->order) ? $this->$tableName->order : [$tableName . '.' . $this->$tableName->getDisplayField() => 'ASC'],
		];
		if ($type === 'list') {
			$defaults['fields'] = [$tableName . '.' . $this->$tableName->getPrimaryKey(), $tableName . '.' . $this->$tableName->getDisplayField()];
			$defaults['keyField'] = $tableName . '.' . $this->$tableName->getPrimaryKey();
			$defaults['valueField'] = $tableName . '.' . $this->$tableName->getDisplayField();
		}
		$options += $defaults;

		return $this->find($type, $options);
	}
public function getRelatedInUse($tableName, $groupField = null, $type = 'all', $options = []) {
		if ($groupField === null) {
			$groupField = $this->belongsTo[$tableName]['foreignKey'];
		}
		$defaults = [
			'contain' => [$tableName],
			'group' => $groupField,
			'order' => isset($this->$tableName->order) ? $this->$tableName->order : [$tableName . '.' . $this->$tableName->getDisplayField() => 'ASC'],
		];
		if ($type === 'list') {
			$defaults['fields'] = [$tableName . '.' . $this->$tableName->getPrimaryKey(), $tableName . '.' . $this->$tableName->getDisplayField()];
			$defaults['keyField'] = $tableName . '.' . $this->$tableName->getPrimaryKey();
			$defaults['valueField'] = $tableName . '.' . $this->$tableName->getDisplayField();
		}
		$options += $defaults;

		return $this->find($type, $options);
	}
public function getRelatedInUse ( $ tableName , $ groupField = null , $ type = 'all' , $ options = [ ] ) { if ( $ groupField === null ) { $ groupField = $ this -> belongsTo [ $ tableName ] [ 'foreignKey' ] ; } $ defaults = [ 'contain' => [ $ tableName ] , 'group' => $ groupField , 'order' => isset ( $ this -> $ tableName -> order ) ? $ this -> $ tableName -> order : [ $ tableName . '.' . $ this -> $ tableName -> getDisplayField ( ) => 'ASC' ] , ] ; if ( $ type === 'list' ) { $ defaults [ 'fields' ] = [ $ tableName . '.' . $ this -> $ tableName -> getPrimaryKey ( ) , $ tableName . '.' . $ this -> $ tableName -> getDisplayField ( ) ] ; $ defaults [ 'keyField' ] = $ tableName . '.' . $ this -> $ tableName -> getPrimaryKey ( ) ; $ defaults [ 'valueField' ] = $ tableName . '.' . $ this -> $ tableName -> getDisplayField ( ) ; } $ options += $ defaults ; return $ this -> find ( $ type , $ options ) ; }
Get all related entries that have been used so far

@deprecated Must be refactored.

@param string $tableName The related model
@param string|null $groupField Field to group by
@param string $type Find type
@param array $options
@return \Cake\ORM\Query
Get all related entries that have been used so far