|
- <?php
-
- namespace Lc\SovBundle\Solver\Setting;
-
- use Lc\SovBundle\Doctrine\EntityInterface;
- use Lc\SovBundle\Model\Setting\SettingInterface;
- use Lc\SovBundle\Model\Setting\SettingModel;
-
- class SettingSolver
- {
- public function getSetting(EntityInterface $entity, string $name): ?SettingModel
- {
- if ($entity->getSettings()) {
- foreach ($entity->getSettings() as $setting) {
- if ($setting->getName() == $name) {
- return $setting;
- }
- }
- }
-
- return null;
- }
-
- public function getSettingValue(EntityInterface $entity, string $name): ?string
- {
- $setting = $this->getSetting($entity, $name);
-
- if($setting) {
- return $this->getValue($setting);
- }
-
- return null;
- }
-
- public function getValue(SettingInterface $setting): ?string
- {
- if ($setting->getText()) {
- return $setting->getText();
- } elseif ($setting->getDate()) {
- return $setting->getDate();
- } elseif ($setting->getFile()) {
- return $setting->getFile();
- }
-
- return null;
- }
- }
|