31 lines
799 B
PHP
31 lines
799 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Repository;
|
||
|
|
|
||
|
|
use App\Entity\AppSetting;
|
||
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||
|
|
use Doctrine\Persistence\ManagerRegistry;
|
||
|
|
|
||
|
|
final class AppSettingRepository extends ServiceEntityRepository
|
||
|
|
{
|
||
|
|
public function __construct(ManagerRegistry $registry)
|
||
|
|
{
|
||
|
|
parent::__construct($registry, AppSetting::class);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function getValue(string $name): ?string
|
||
|
|
{
|
||
|
|
return $this->findOneBy(['name' => $name])?->getValue();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function setValue(string $name, ?string $value): AppSetting
|
||
|
|
{
|
||
|
|
$setting = $this->findOneBy(['name' => $name]) ?? (new AppSetting())->setName($name);
|
||
|
|
$setting->setValue($value);
|
||
|
|
|
||
|
|
$this->getEntityManager()->persist($setting);
|
||
|
|
|
||
|
|
return $setting;
|
||
|
|
}
|
||
|
|
}
|