Feature: allow to administrate budget resources and charges from the admin

This commit is contained in:
2023-01-23 20:40:01 +00:00
parent 99482edf0d
commit c4eb45edcc
57 changed files with 1546 additions and 49 deletions

View File

@@ -0,0 +1,55 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\BudgetBundle\Templating;
use Chill\BudgetBundle\Entity\ChargeKind;
use Chill\BudgetBundle\Entity\ResourceKind;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Templating\EngineInterface;
final class BudgetElementTypeRender implements ChillEntityRenderInterface
{
private EngineInterface $engine;
private TranslatableStringHelperInterface $translatableStringHelper;
public function __construct(TranslatableStringHelperInterface $translatableStringHelper, EngineInterface $engine)
{
$this->translatableStringHelper = $translatableStringHelper;
$this->engine = $engine;
}
public function renderBox($entity, array $options): string
{
return $this->engine->render('@ChillBudget/Entity/budget_element_type.html.twig', [
'entity' => $entity,
'options' => $options,
]);
}
public function renderString($entity, array $options): string
{
$title = '';
if (null !== $entity->getName()) {
return $this->translatableStringHelper->localize($entity->getName());
}
return $title;
}
public function supports($entity, array $options): bool
{
return $entity instanceof ChargeKind || $entity instanceof ResourceKind;
}
}