lithium\data\Model::relations()

public static method

Returns a list of models related to Model, or a list of models related to this model, but of a certain type.

Parameters

  • string $type

    A type of model relation.

Returns

array|object|void

An array of relation instances or an instance of relation.

Source

	public static function relations($type = null) {
		$self = static::_object();

		if ($type === null) {
			return static::_relations();
		}
		if (isset($self->_relationFieldNames[$type])) {
			$type = $self->_relationFieldNames[$type];
		}

		if (isset($self->_relations[$type])) {
			return $self->_relations[$type];
		}
		if (isset($self->_relationsToLoad[$type])) {
			return static::_relations(null, $type);
		}
		if (in_array($type, $self->_relationTypes, true)) {
			return array_keys(static::_relations($type));
		}
	}