public function init()
{
$this->_init();
// handle foreign table containing a dot
if (is_string($this->foreign_table) && strpos($this->foreign_table, '.') !== false) {
if (!isset($this->reverse)) {
$this->reverse = true;
if (isset($this->master_field)) {
// both master and foreign fields are set
// master_field exists, no we will use that
/*
if (!is_object($this->master_field)
&& !$this->owner->hasElement($this->master_field
)) {
*/
throw new Exception(['You are trying to link tables on non-id fields. This is not implemented yet', 'condition' => $this->owner->table . '.' . $this->master_field . ' = ' . $this->foreign_table]);
/*
}
$this->reverse = 'link';
*/
}
}
list($this->foreign_table, $this->foreign_field) = explode('.', $this->foreign_table, 2);
if (!$this->master_field) {
$this->master_field = 'id';
}
} else {
$this->reverse = false;
if (!$this->master_field) {
$this->master_field = $this->foreign_table . '_id';
}
if (!$this->foreign_field) {
$this->foreign_field = 'id';
}
}
$this->owner->addHook('afterUnload', $this);
}