mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-10 00:34:58 +00:00
Feature: allow to administrate budget resources and charges from the admin
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user