From 5ead9cbf61e47d6618dfc7737673584e34f9440a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Mon, 30 Jan 2023 00:43:03 +0100 Subject: [PATCH] Fixed some incompatibility on PHP 7.4 --- src/Form/Type/CurrencyEntityType.php | 4 ++++ src/Repository/StructuralDBElementRepository.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) 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); }