Model/CommonAppModel.php
protected function _containForeignModels($query, $assoc = null) {
		if (
			(isset($query['contain']) && empty($query['contain']))
			|| (isset($this->contain) && empty($this->contain))
		) {
			return $query;
		}

		if (!isset($query['contain'])) {
			$query['contain'] = array();
		} else if (!is_array($query['contain'])) {
			$query['contain'] = (array) $query['contain'];
		}

		// Add the foreign models.
		foreach (array_keys($this->belongsToForeignModels) as $model) {
			if (!empty($assoc)) {
				$model = "$assoc.$model";
			}
			if (!in_array($model, $query['contain']) && !isset($query['contain'][$model])) {
				$query['contain'][] = $model;
			}
		}

		return $query;
	}
protected function _containForeignModels($query, $assoc = null) {
		if (
			(isset($query['contain']) && empty($query['contain']))
			|| (isset($this->contain) && empty($this->contain))
		) {
			return $query;
		}

		if (!isset($query['contain'])) {
			$query['contain'] = array();
		} else if (!is_array($query['contain'])) {
			$query['contain'] = (array) $query['contain'];
		}

		// Add the foreign models.
		foreach (array_keys($this->belongsToForeignModels) as $model) {
			if (!empty($assoc)) {
				$model = "$assoc.$model";
			}
			if (!in_array($model, $query['contain']) && !isset($query['contain'][$model])) {
				$query['contain'][] = $model;
			}
		}

		return $query;
	}
protected function _containForeignModels ( $ query , $ assoc = null ) { if ( ( isset ( $ query [ 'contain' ] ) && empty ( $ query [ 'contain' ] ) ) || ( isset ( $ this -> contain ) && empty ( $ this -> contain ) ) ) { return $ query ; } if ( ! isset ( $ query [ 'contain' ] ) ) { $ query [ 'contain' ] = array ( ) ; } else if ( ! is_array ( $ query [ 'contain' ] ) ) { $ query [ 'contain' ] = ( array ) $ query [ 'contain' ] ; } // Add the foreign models. foreach ( array_keys ( $ this -> belongsToForeignModels ) as $ model ) { if ( ! empty ( $ assoc ) ) { $ model = "$assoc.$model" ; } if ( ! in_array ( $ model , $ query [ 'contain' ] ) && ! isset ( $ query [ 'contain' ] [ $ model ] ) ) { $ query [ 'contain' ] [ ] = $ model ; } } return $ query ; }
Adds the foreign models to the query's `contain`.

@param array $query Find query.
@return array Modified find query.
Adds the foreign models to the query s contain .