forked from pkp/pkp-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkp#9425 Make submission language selection and metadata forms indepe…
…ndent from website language settings
- Loading branch information
Showing
21 changed files
with
200 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
classes/migration/upgrade/v3_5_0/I9425_SeparateUIAndSubmissionLocales.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?php | ||
|
||
/** | ||
* @file classes/migration/upgrade/v3_5_0/I9425_SeparateUIAndSubmissionLocales.php | ||
* | ||
* Copyright (c) 2023 Simon Fraser University | ||
* Copyright (c) 2023 John Willinsky | ||
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. | ||
* | ||
* @class I9425_SeparateUIAndSubmissionLocales | ||
* | ||
* @brief pkp/pkp-lib#9425 Make submission language selection and metadata forms independent from website language settings | ||
*/ | ||
|
||
namespace PKP\migration\upgrade\v3_5_0; | ||
|
||
use Illuminate\Support\Facades\DB; | ||
use PKP\install\DowngradeNotSupportedException; | ||
use PKP\migration\Migration; | ||
|
||
abstract class I9425_SeparateUIAndSubmissionLocales extends Migration | ||
{ | ||
abstract protected function getContextTable(): string; | ||
abstract protected function getContextSettingsTable(): string; | ||
abstract protected function getContextIdColumn(): string; | ||
|
||
/** | ||
* Run the migrations. | ||
*/ | ||
public function up(): void | ||
{ | ||
// DB changes | ||
$insert = function (int $contextId, string $settingName, string $settingValue) { | ||
DB::table($this->getContextSettingsTable())->insert( | ||
[ | ||
$this->getContextIdColumn() => $contextId, | ||
'locale' => '', | ||
'setting_name' => $settingName, | ||
'setting_value' => $settingValue, | ||
] | ||
); | ||
}; | ||
$pluck = fn (int $contextId, string $settingName) => DB::table($this->getContextSettingsTable()) | ||
->where($this->getContextIdColumn(), '=', $contextId) | ||
->where('setting_name', '=', $settingName) | ||
->pluck('setting_value')[0]; | ||
|
||
foreach (DB::table($this->getContextTable())->select('primary_locale', $this->getContextIdColumn())->get() as $localeId) { | ||
// supportedDefaultSubmissionLocale from primary locale | ||
$insert($localeId->{$this->getContextIdColumn()}, 'supportedDefaultSubmissionLocale', $localeId->primary_locale); | ||
// supportedAddedSubmissionLocales from supportedLocales | ||
$insert($localeId->{$this->getContextIdColumn()}, 'supportedAddedSubmissionLocales', $pluck($localeId->{$this->getContextIdColumn()}, 'supportedLocales')); | ||
// supportedSubmissionMetadataLocales from supportedSubmissionLocales | ||
$insert($localeId->{$this->getContextIdColumn()}, 'supportedSubmissionMetadataLocales', $pluck($localeId->{$this->getContextIdColumn()}, 'supportedSubmissionLocales')); | ||
} | ||
} | ||
|
||
/** | ||
* Reverse the downgrades | ||
*/ | ||
public function down(): void | ||
{ | ||
throw new DowngradeNotSupportedException(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.