[DATABASE][WRAPPER] Update DATABASE wrapper so entity names are provided without the namespace
This commit is contained in:
parent
0615adbb51
commit
643a937152
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// {{{ License
|
// {{{ License
|
||||||
|
|
||||||
// This file is part of GNU social - https://www.gnu.org/software/social
|
// This file is part of GNU social - https://www.gnu.org/software/social
|
||||||
//
|
//
|
||||||
// GNU social is free software: you can redistribute it and/or modify
|
// GNU social is free software: you can redistribute it and/or modify
|
||||||
@ -15,6 +16,7 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU Affero General Public License
|
// You should have received a copy of the GNU Affero General Public License
|
||||||
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// }}}
|
// }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,7 +67,7 @@ class AdminConfigController extends Controller
|
|||||||
$value = $data[_m('Value')];
|
$value = $data[_m('Value')];
|
||||||
$default = $defaults[$section][$setting];
|
$default = $defaults[$section][$setting];
|
||||||
if (gettype($default) === gettype($value)) {
|
if (gettype($default) === gettype($value)) {
|
||||||
$conf = DB::find('\App\Entity\Config', ['section' => $section, 'setting' => $setting]);
|
$conf = DB::find('config', ['section' => $section, 'setting' => $setting]);
|
||||||
$old_value = $conf->getValue();
|
$old_value = $conf->getValue();
|
||||||
$conf->setValue(serialize($value));
|
$conf->setValue(serialize($value));
|
||||||
DB::flush();
|
DB::flush();
|
||||||
|
@ -42,6 +42,12 @@ abstract class DB
|
|||||||
|
|
||||||
public static function __callStatic(string $name, array $args)
|
public static function __callStatic(string $name, array $args)
|
||||||
{
|
{
|
||||||
|
foreach (['find', 'getReference', 'getPartialReference', 'getRepository'] as $m) {
|
||||||
|
if ($name == $m) {
|
||||||
|
$args[0] = '\App\Entity\\' . ucfirst($args[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return self::$em->{$name}(...$args);
|
return self::$em->{$name}(...$args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ abstract class DefaultSettings
|
|||||||
public static array $defaults;
|
public static array $defaults;
|
||||||
public static function setDefaults()
|
public static function setDefaults()
|
||||||
{
|
{
|
||||||
$conf = DB::find('\App\Entity\Config', ['section' => 'site', 'setting' => 'defaults_modified']);
|
$conf = DB::find('config', ['section' => 'site', 'setting' => 'defaults_modified']);
|
||||||
if ($conf != null && filemtime(__FILE__) < $conf->getValue()) {
|
if ($conf != null && filemtime(__FILE__) < $conf->getValue()) {
|
||||||
// Don't bother modifying the table if this file is older
|
// Don't bother modifying the table if this file is older
|
||||||
return;
|
return;
|
||||||
@ -269,7 +269,7 @@ abstract class DefaultSettings
|
|||||||
// doesn't implement it. The difference between this and the
|
// doesn't implement it. The difference between this and the
|
||||||
// normal version is that that one does 221 queries in 30 to
|
// normal version is that that one does 221 queries in 30 to
|
||||||
// 50ms, while this does 2 in 10 to 15 ms.
|
// 50ms, while this does 2 in 10 to 15 ms.
|
||||||
if (DB::getRepository('\App\Entity\Config')->count([]) == 0) {
|
if (DB::getRepository('config')->count([]) == 0) {
|
||||||
$sql = 'insert into config (section, setting, value) values';
|
$sql = 'insert into config (section, setting, value) values';
|
||||||
foreach (self::$defaults as $section => $def) {
|
foreach (self::$defaults as $section => $def) {
|
||||||
foreach ($def as $setting => $value) {
|
foreach ($def as $setting => $value) {
|
||||||
|
@ -39,7 +39,7 @@ abstract class Common
|
|||||||
*/
|
*/
|
||||||
public static function config(string $section, string $setting)
|
public static function config(string $section, string $setting)
|
||||||
{
|
{
|
||||||
return DB::find('\App\Entity\Config', ['section' => $section, 'setting' => $setting]);
|
return DB::find('config', ['section' => $section, 'setting' => $setting]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +47,7 @@ abstract class Common
|
|||||||
*/
|
*/
|
||||||
public static function set_config(string $section, string $setting, mixed $value): void
|
public static function set_config(string $section, string $setting, mixed $value): void
|
||||||
{
|
{
|
||||||
$ojb = DB::getPatialReference('\App\Entity\Config', ['section' => $section, 'setting' => $setting]);
|
$ojb = DB::getPartialReference('config', ['section' => $section, 'setting' => $setting]);
|
||||||
$obj->setValue(serialize($value));
|
$obj->setValue(serialize($value));
|
||||||
DB::persist($obj);
|
DB::persist($obj);
|
||||||
DB::flush();
|
DB::flush();
|
||||||
|
Loading…
Reference in New Issue
Block a user