Skip to content
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
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions classes/core/SettingsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use stdClass;
use PKP\facades\Locale;

class SettingsBuilder extends Builder
{
Expand Down Expand Up @@ -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)) {
Copy link
Collaborator

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?

$settingValue = $this->localizeNonLocalizedData($settingValue);
}
foreach ($settingValue as $locale => $localizedValue) {
$rows[] = [
$this->model->getKeyName() => $id, 'locale' => $locale, 'setting_name' => $settingName, 'setting_value' => $localizedValue
Expand All @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{
return [Locale::getLocale() => $value];
}

/**
* Delete model with settings
*/
Expand Down
364 changes: 0 additions & 364 deletions classes/userGroup/Collector.php

This file was deleted.

Loading