atk4\data\Join_SQL::init PHP Метод

init() публичный Метод

This method is to figure out stuff.
public init ( )
    public function init()
    {
        parent::init();
        $this->owner->persistence_data['use_table_prefixes'] = true;
        // If kind is not specified, figure out join type
        if (!isset($this->kind)) {
            $this->kind = $this->weak ? 'left' : 'inner';
        }
        // Our short name will be unique
        if (!$this->foreign_alias) {
            $this->foreign_alias = (isset($this->owner->table_alias) ? $this->owner->table_alias : '') . $this->short_name;
        }
        $this->owner->addhook('initSelectQuery', $this);
        // Add necessary hooks
        if ($this->reverse) {
            $this->owner->addHook('afterInsert', $this);
            $this->owner->addHook('beforeUpdate', $this);
            $this->owner->addHook('beforeDelete', [$this, 'doDelete'], null, -5);
            $this->owner->addHook('afterLoad', $this);
        } else {
            // Master field indicates ID of the joined item. In the past it had to be
            // defined as a physical field in the main table. Now it is a model field
            // so you can use expressions or fields inside joined entities.
            // If string specified here does not point to an existing model field
            // a new basic field is inserted and marked hidden.
            if (is_string($this->master_field)) {
                $e = $this->owner->hasElement($this->master_field);
                if (!$e) {
                    if ($this->join) {
                        $e = $this->join->addField($this->master_field, ['system' => true, 'read_only' => true]);
                    } else {
                        $e = $this->owner->addField($this->master_field, ['system' => true, 'read_only' => true]);
                    }
                    $this->master_field = $e->short_name;
                }
            }
            $this->owner->addHook('beforeInsert', $this, null, -5);
            $this->owner->addHook('beforeUpdate', $this);
            $this->owner->addHook('afterDelete', [$this, 'doDelete']);
            $this->owner->addHook('afterLoad', $this);
        }
    }