diff --git a/Admin/Install/Interfaces/DatabaseExchanger/ExchangeTrait.php b/Admin/Install/Interfaces/DatabaseExchanger/ExchangeTrait.php index 50c9c91..2ca9431 100755 --- a/Admin/Install/Interfaces/DatabaseExchanger/ExchangeTrait.php +++ b/Admin/Install/Interfaces/DatabaseExchanger/ExchangeTrait.php @@ -41,8 +41,11 @@ trait ExchangeTrait */ public function exchangeFromRequest(RequestAbstract $request) : array { - /** @var \Modules\Exchange\Models\ExhcangeSetting $setting */ - $setting = ExchangeSettingMapper::get()->where('id', (int) $request->getData('setting'))->execute(); + /** @var \Modules\Exchange\Models\ExchangeSetting $setting */ + $setting = ExchangeSettingMapper::get() + ->where('id', (int) $request->getData('setting')) + ->execute(); + $settingData = $setting->getData(); $lang = []; @@ -73,7 +76,8 @@ trait ExchangeTrait ] ); - foreach (($setting['relation'] ?? []) as $table) { + $relations = $setting->getRelations(); + foreach ($relations as $table) { $importQuery = new Builder($importConnection); $importQuery->from($table['src']); diff --git a/Admin/Install/db.json b/Admin/Install/db.json index 96bc410..3fa3a01 100755 --- a/Admin/Install/db.json +++ b/Admin/Install/db.json @@ -75,6 +75,11 @@ "type": "TEXT", "null": false }, + "exchange_settings_relations": { + "name": "exchange_settings_relations", + "type": "TEXT", + "null": false + }, "exchange_settings_job": { "name": "exchange_settings_job", "type": "INT", diff --git a/Models/ExchangeSetting.php b/Models/ExchangeSetting.php index 88ed4ae..35b91b6 100755 --- a/Models/ExchangeSetting.php +++ b/Models/ExchangeSetting.php @@ -42,6 +42,14 @@ class ExchangeSetting implements \JsonSerializable */ public string $title = ''; + /** + * Relation definitions between tables/columns. + * + * @var array + * @since 1.0.0 + */ + private array $relations = []; + /** * Data. * @@ -104,6 +112,32 @@ class ExchangeSetting implements \JsonSerializable return $this->id; } + /** + * Set relations + * + * @param array $relations Relations between tables/columsn + * + * @return void + * + * @since 1.0.0 + */ + public function setRelations(array $relations) : void + { + $this->relations = $relations; + } + + /** + * Get table/column relations + * + * @return array + * + * @since 1.0.0 + */ + public function getRelations() : array + { + return $this->relations; + } + /** * {@inheritdoc} */ diff --git a/Models/ExchangeSettingMapper.php b/Models/ExchangeSettingMapper.php index 98e982d..6f9218f 100755 --- a/Models/ExchangeSettingMapper.php +++ b/Models/ExchangeSettingMapper.php @@ -36,6 +36,7 @@ final class ExchangeSettingMapper extends DataMapperFactory 'exchange_settings_id' => ['name' => 'exchange_settings_id', 'type' => 'int', 'internal' => 'id'], 'exchange_settings_title' => ['name' => 'exchange_settings_title', 'type' => 'string', 'internal' => 'title'], 'exchange_settings_data' => ['name' => 'exchange_settings_data', 'type' => 'Json', 'internal' => 'data'], + 'exchange_settings_relations' => ['name' => 'exchange_settings_relations', 'type' => 'Json', 'internal' => 'relations'], 'exchange_settings_job' => ['name' => 'exchange_settings_job', 'type' => 'int', 'internal' => 'job'], 'exchange_settings_exchange' => ['name' => 'exchange_settings_exchange', 'type' => 'int', 'internal' => 'exchange'], ]; diff --git a/Models/InterfaceManager.php b/Models/InterfaceManager.php index 1f0444a..ff45518 100755 --- a/Models/InterfaceManager.php +++ b/Models/InterfaceManager.php @@ -130,7 +130,7 @@ class InterfaceManager public function __construct(string $path = '') { $this->path = $path; - $this->account = new NullAccount(); + $this->createdBy = new NullAccount(); $this->createdAt = new \DateTimeImmutable(); $this->source = new NullCollection(); }