diff --git a/src/Form/Type/CurrencyEntityType.php b/src/Form/Type/CurrencyEntityType.php index 40b563b2..59096302 100644 --- a/src/Form/Type/CurrencyEntityType.php +++ b/src/Form/Type/CurrencyEntityType.php @@ -79,6 +79,10 @@ class CurrencyEntityType extends StructuralEntityType { $tmp = parent::generateChoiceAttr($choice, $key, $value, $options); + if (!$choice instanceof Currency) { + throw new RuntimeException('The choice must be an instance of '.Currency::class); + } + if(!empty($choice->getIsoCode())) { $symbol = Currencies::getSymbol($choice->getIsoCode()); } else { diff --git a/src/Repository/StructuralDBElementRepository.php b/src/Repository/StructuralDBElementRepository.php index 2f8a656a..e23eda8f 100644 --- a/src/Repository/StructuralDBElementRepository.php +++ b/src/Repository/StructuralDBElementRepository.php @@ -111,8 +111,9 @@ class StructuralDBElementRepository extends NamedDBElementRepository //See if we already have an element with this name and parent $entity = $this->findOneBy(['name' => $name, 'parent' => $parent]); if (null === $entity) { + $class = $this->getClassName(); /** @var AbstractStructuralDBElement $entity */ - $entity = new ($this->getClassName()); + $entity = new $class; $entity->setName($name); $entity->setParent($parent); }