mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
|
|
|
/**
|
|
* 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.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Chill\ThirdPartyBundle\Templating\Entity;
|
|
|
|
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
|
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
|
use Symfony\Component\Templating\EngineInterface;
|
|
|
|
class ThirdPartyRender extends AbstractChillEntityRender
|
|
{
|
|
protected EngineInterface $engine;
|
|
|
|
protected TranslatableStringHelper $translatableStringHelper;
|
|
|
|
public function __construct(
|
|
EngineInterface $engine,
|
|
TranslatableStringHelper $translatableStringHelper
|
|
) {
|
|
$this->engine = $engine;
|
|
$this->translatableStringHelper = $translatableStringHelper;
|
|
}
|
|
|
|
/**
|
|
* @param ThirdParty $entity
|
|
*/
|
|
public function renderBox($entity, array $options): string
|
|
{
|
|
$params = [
|
|
'with_valid_from' => $options['with_valid_from'] ?? true,
|
|
'addLink' => $options['addLink'] ?? false,
|
|
'addEntity' => $options['addEntity'] ?? false,
|
|
'addId' => $options['addId'] ?? false,
|
|
'addInfo' => $options['addInfo'] ?? false,
|
|
'hLevel' => $options['hLevel'] ?? 3,
|
|
'customButtons' => $options['customButtons'] ?? [],
|
|
'customArea' => $options['customArea'] ?? [],
|
|
'showContacts' => $options['showContacts'] ?? false,
|
|
'showParent' => $options['showParent'] ?? true,
|
|
'isConfidential' => $options['isConfidential'] ?? false,
|
|
];
|
|
|
|
return
|
|
$this->getDefaultOpeningBox('thirdparty') .
|
|
$this->engine->render('@ChillThirdParty/Entity/thirdparty.html.twig', [
|
|
'thirdparty' => $entity,
|
|
'render' => $options['render'] ?? 'raw',
|
|
'options' => $params,
|
|
]) .
|
|
$this->getDefaultClosingBox();
|
|
}
|
|
|
|
/**
|
|
* @param ThirdParty $entity
|
|
*/
|
|
public function renderString($entity, array $options): string
|
|
{
|
|
if ($entity->getCivility() !== null) {
|
|
$civility = $this->translatableStringHelper
|
|
->localize($entity->getCivility()->getAbbreviation()) . ' ';
|
|
} else {
|
|
$civility = '';
|
|
}
|
|
|
|
if (!empty($entity->getAcronym())) {
|
|
$acronym = ' (' . $entity->getAcronym() . ')';
|
|
} else {
|
|
$acronym = '';
|
|
}
|
|
|
|
return $civility . $entity->getName() . $acronym;
|
|
}
|
|
|
|
public function supports($entity, array $options): bool
|
|
{
|
|
return $entity instanceof ThirdParty;
|
|
}
|
|
}
|