Extends
lithium\core\StaticObject
Returns a list of models related to `Model`, or a list of models related
to this model, but of a certain type.
Parameters
- string $name A type of model relation.
Returns
array An array of relation types.Source
public static function relations($name = null) {
$self = static::_object();
if (!$name) {
return $self->_relations;
}
if (isset($self->_relationTypes[$name])) {
return array_keys(array_filter($self->_relations, function($i) use ($name) {
return $i->data('type') == $name;
}));
}
return isset($self->_relations[$name]) ? $self->_relations[$name] : null;
}