Extends
lithium\core\StaticObject
Creates a relationship binding between this model and another.
Parameters
- string $type The type of relationship to create. Must be one of `'hasOne'`, `'hasMany'` or `'belongsTo'`.
- string $name The name of the relationship. If this is also the name of the model, the model must be in the same namespace as this model. Otherwise, the fully-namespaced path to the model class must be specified in `$config`.
- array $config Any other configuration that should be specified in the relationship. See the `Relationship` class for more information.
Returns
object Returns an instance of the `Relationship` class that defines the connection.Source
public static function bind($type, $name, array $config = array()) {
$self = static::_object();
if (!isset($self->_relationTypes[$type])) {
throw new ConfigException("Invalid relationship type `{$type}` specified.");
}
$rel = static::connection()->relationship(get_called_class(), $type, $name, $config);
return $self->_relations[$name] = $rel;
}