@@ -15,45 +15,45 @@ |
||
| 15 | 15 | use Symfony\Bridge\Doctrine\RegistryInterface; |
| 16 | 16 | |
| 17 | 17 | class ConfigurationResolver { |
| 18 | - /** |
|
| 19 | - * @var RegistryInterface |
|
| 20 | - */ |
|
| 21 | - private $doctrine; |
|
| 22 | - |
|
| 23 | - /** |
|
| 24 | - * @var Definition |
|
| 25 | - */ |
|
| 26 | - private $definition; |
|
| 27 | - |
|
| 28 | - public function __construct(RegistryInterface $doctrine, Definition $definition) { |
|
| 29 | - $this->doctrine = $doctrine; |
|
| 30 | - $this->definition = $definition; |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - public function getDefinition() : Definition { |
|
| 34 | - return $this->definition; |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * @return null|object |
|
| 39 | - * @throws \UnexpectedValueException |
|
| 40 | - */ |
|
| 41 | - public function resolve() { |
|
| 42 | - $repo = $this->doctrine->getRepository(ConfigurationValue::class); |
|
| 43 | - $configurationValue = $repo->find($this->definition->getKey()); |
|
| 44 | - if ($configurationValue === null) { |
|
| 45 | - return null; |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - switch (get_class($this->definition)) { |
|
| 49 | - case StringDefinition::class: |
|
| 50 | - return $configurationValue->getValue(); |
|
| 51 | - case EntityDefinition::class: |
|
| 52 | - /* @var $entityDefinition EntityDefinition */ |
|
| 53 | - $entityDefinition = $this->definition; |
|
| 54 | - return $this->doctrine->getRepository($entityDefinition->getClass())->find($configurationValue->getValue()); |
|
| 55 | - default: |
|
| 56 | - throw new \UnexpectedValueException(); |
|
| 57 | - } |
|
| 58 | - } |
|
| 18 | + /** |
|
| 19 | + * @var RegistryInterface |
|
| 20 | + */ |
|
| 21 | + private $doctrine; |
|
| 22 | + |
|
| 23 | + /** |
|
| 24 | + * @var Definition |
|
| 25 | + */ |
|
| 26 | + private $definition; |
|
| 27 | + |
|
| 28 | + public function __construct(RegistryInterface $doctrine, Definition $definition) { |
|
| 29 | + $this->doctrine = $doctrine; |
|
| 30 | + $this->definition = $definition; |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + public function getDefinition() : Definition { |
|
| 34 | + return $this->definition; |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * @return null|object |
|
| 39 | + * @throws \UnexpectedValueException |
|
| 40 | + */ |
|
| 41 | + public function resolve() { |
|
| 42 | + $repo = $this->doctrine->getRepository(ConfigurationValue::class); |
|
| 43 | + $configurationValue = $repo->find($this->definition->getKey()); |
|
| 44 | + if ($configurationValue === null) { |
|
| 45 | + return null; |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + switch (get_class($this->definition)) { |
|
| 49 | + case StringDefinition::class: |
|
| 50 | + return $configurationValue->getValue(); |
|
| 51 | + case EntityDefinition::class: |
|
| 52 | + /* @var $entityDefinition EntityDefinition */ |
|
| 53 | + $entityDefinition = $this->definition; |
|
| 54 | + return $this->doctrine->getRepository($entityDefinition->getClass())->find($configurationValue->getValue()); |
|
| 55 | + default: |
|
| 56 | + throw new \UnexpectedValueException(); |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | } |