-
Notifications
You must be signed in to change notification settings - Fork 448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pkp/pkp-lib#10506 Refactor UserGroup to use Eloquent #10519
Draft
Hafsa-Naeem
wants to merge
5
commits into
pkp:main
Choose a base branch
from
Hafsa-Naeem:i10506_UserGroup_to_Use_Eloquent_Model
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
35b9299
pkp/pkp-lib#10506 Refactor UserGroup to use Eloquent
Hafsa-Naeem f20097d
pkp/pkp-lib#10506 Update usage for porting UserGroup to Eloquent
Hafsa-Naeem 1ce4b3f
pkp/pkp-lib#10506 Fix UserGroup and Repository code to correct settin…
Hafsa-Naeem 2ef27fa
pkp/pkp-lib#10506 optimize relationships with eager loading
Hafsa-Naeem 08c53ec
lib/pkp-lib#10506 Fix type errors and refactor with scopes
Hafsa-Naeem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
use Illuminate\Support\Facades\DB; | ||
use Illuminate\Support\Str; | ||
use stdClass; | ||
use PKP\facades\Locale; | ||
|
||
class SettingsBuilder extends Builder | ||
{ | ||
|
@@ -110,6 +111,10 @@ public function insertGetId(array $values, $sequence = null) | |
$settingValues->each(function (mixed $settingValue, string $settingName) use ($id, &$rows) { | ||
$settingName = Str::camel($settingName); | ||
if ($this->isMultilingual($settingName)) { | ||
// if non-localized data passed, set the locale to default one | ||
if (is_string($settingValue)) { | ||
$settingValue = $this->localizeNonLocalizedData($settingValue); | ||
} | ||
foreach ($settingValue as $locale => $localizedValue) { | ||
$rows[] = [ | ||
$this->model->getKeyName() => $id, 'locale' => $locale, 'setting_name' => $settingName, 'setting_value' => $localizedValue | ||
|
@@ -127,6 +132,14 @@ public function insertGetId(array $values, $sequence = null) | |
return $id; | ||
} | ||
|
||
/** | ||
* Wrap a non localized value with the default locale | ||
*/ | ||
protected function localizeNonLocalizedData(string $value): array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this will be covered by @touhidurabir's PR: https://github.com/pkp/pkp-lib/pull/10324/files#diff-c02696b6e6df357a9749cf0c4b474c57ae717b5212e740a236b3e785fd1835a2. Let's skip this for now |
||
{ | ||
return [Locale::getLocale() => $value]; | ||
} | ||
|
||
/** | ||
* Delete model with settings | ||
*/ | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it makes the code better. @jonasraoni, do you have an opinion whether we should allow to set multilingual value by the default locale?