2021-11-30 13:54:58 +01:00

78 lines
2.1 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\ActivityBundle\Templating\Entity;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\MainBundle\Templating\TranslatableStringHelper;
/**
* Render activity reason.
*/
class ActivityReasonRender extends AbstractChillEntityRender
{
/**
* @var TranslatableStringHelper
*/
protected $translatableStringHelper;
public function __construct(TranslatableStringHelper $translatableStringHelper)
{
$this->translatableStringHelper = $translatableStringHelper;
}
public function renderBox($entity, array $options): string
{
return
$this->getDefaultOpeningBox('activity-reason') .
'<span class="badge bg-chill-pink">' .
'<i class="fa fa-question-circle"></i>&nbsp;' .
'<span class="category">' .
$this->translatableStringHelper->localize(
$entity->getCategory()->getName()
) .
'</span>' .
'<span class="separator">&nbsp;>&nbsp;</span>' .
'<span class="reason">' .
$this->translatableStringHelper->localize(
$entity->getName()
) .
'</span>' .
'</span>' .
$this->getDefaultClosingBox();
}
/**
* @param ActivityReason $entity
*/
public function renderString($entity, array $options): string
{
$category = '';
if (null !== $entity->getCategory()) {
$category = $this->translatableStringHelper->localize(
$entity->getCategory()->getName()
) . ' > ';
}
return $category .
$this->translatableStringHelper->localize(
$entity->getName()
);
}
public function supports($entity, array $options): bool
{
return $entity instanceof ActivityReason;
}
}