Allow to retrieve price and shopping informations from info providers

This commit is contained in:
Jan Böhmer 2023-07-14 00:09:22 +02:00
parent c4439cc9db
commit 0cb46039dd
11 changed files with 348 additions and 4 deletions

View file

@ -102,6 +102,9 @@ class StructuralEntityChoiceHelper
$symbol = empty($choice->getIsoCode()) ? null : Currencies::getSymbol($choice->getIsoCode());
$tmp['data-short'] = $options['short'] ? $symbol : $choice->getName();
//Show entities that are not added to DB yet separately from other entities
$tmp['data-not_in_db_yet'] = $choice->getID() === null;
return $tmp + [
'data-symbol' => $symbol,
];

View file

@ -23,6 +23,7 @@ declare(strict_types=1);
namespace App\Form\Type\Helper;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\PriceInformations\Currency;
use App\Repository\StructuralDBElementRepository;
use App\Services\Trees\NodesListBuilder;
use Doctrine\ORM\EntityManagerInterface;
@ -59,6 +60,12 @@ class StructuralEntityChoiceLoader extends AbstractChoiceLoader
public function createNewEntitiesFromValue(string $value): array
{
if (!$this->options['allow_add']) {
//Always allow the starting element to be added
if ($this->starting_element !== null && $this->starting_element->getID() === null) {
$this->entityManager->persist($this->starting_element);
return [$this->starting_element];
}
throw new \RuntimeException('Cannot create new entity, because allow_add is not enabled!');
}