<?php

namespace common\modules\relation;

use yii\base\Object;

class relationObject extends Object {
    protected $key;
    protected $entity1;
    protected $entity2;

    protected $moduleRelations = [];

    public function __construct($relation_key, $params) {
        $relation_key = strtolower($relation_key);
        if (is_string($params)) {
            // Get data from module's data
            $relation_entity = $params;
            $relation = $this->_getRelationParams($relation_key);
            $relation['inner'] = $relation[$relation_entity];
            $relation['outer'] = $relation[$relation_entity == 'entity1' ? 'entity2' : 'entity1'];
            $relation['linked_table'] = $relation['via']['model']::tableName();
        }

        $this->moduleRelations = relationHelper::getRelations();


    }
}