|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?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)
- {
- $setting = $this->getSetting($entity, $name);
-
- if($setting) {
- return $this->getValue($setting);
- }
-
- return null;
- }
-
- public function getValue(SettingInterface $setting)
- {
- if ($setting->getText()) {
- return $setting->getText();
- } elseif ($setting->getDate()) {
- return $setting->getDate();
- } elseif ($setting->getFile()) {
- return $setting->getFile();
- }
-
- return null;
- }
- }
|