mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 11:03:50 +00:00
cs: Fix code style (safe rules only).
This commit is contained in:
@@ -1,75 +1,80 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
namespace Chill\PersonBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
|
||||
|
||||
/**
|
||||
* Render closing motive
|
||||
*
|
||||
* Render closing motive.
|
||||
*/
|
||||
class ClosingMotiveRender extends AbstractChillEntityRender
|
||||
{
|
||||
private CONST SEPARATOR = ' > ';
|
||||
|
||||
private const SEPARATOR = ' > ';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
private $translatableStringHelper;
|
||||
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper)
|
||||
{
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
|
||||
public function renderBox($entity, array $options): string
|
||||
{
|
||||
return
|
||||
$this->getDefaultOpeningBox('closing-motive').
|
||||
$this->renderString($entity, $options).
|
||||
$this->getDefaultClosingBox()
|
||||
;
|
||||
return
|
||||
$this->getDefaultOpeningBox('closing-motive') .
|
||||
$this->renderString($entity, $options) .
|
||||
$this->getDefaultClosingBox();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ClosingMotive $entity
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
public function renderString($entity, array $options): string
|
||||
{
|
||||
return $this->renderStringRecursive($entity,
|
||||
'', //$this->translatableStringHelper->localize($entity->getName()),
|
||||
$options);
|
||||
}
|
||||
|
||||
protected function renderStringRecursive(ClosingMotive $motive, $existing, array $options)
|
||||
{
|
||||
$newExisting = $this->translatableStringHelper->localize($motive->getName());
|
||||
|
||||
if ($motive->hasParent()) {
|
||||
|
||||
if (!empty($existing)) {
|
||||
$newExisting = $newExisting.self::SEPARATOR.$existing;
|
||||
}
|
||||
|
||||
return $this->renderStringRecursive($motive->getParent(), $newExisting,
|
||||
$options);
|
||||
} else {
|
||||
if (!empty($existing)) {
|
||||
return $newExisting.self::SEPARATOR.$existing;
|
||||
} else {
|
||||
return $newExisting;
|
||||
}
|
||||
}
|
||||
return $this->renderStringRecursive(
|
||||
$entity,
|
||||
'', //$this->translatableStringHelper->localize($entity->getName()),
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
public function supports($entity, array $options): bool
|
||||
{
|
||||
return $entity instanceof ClosingMotive;
|
||||
}
|
||||
|
||||
protected function renderStringRecursive(ClosingMotive $motive, $existing, array $options)
|
||||
{
|
||||
$newExisting = $this->translatableStringHelper->localize($motive->getName());
|
||||
|
||||
if ($motive->hasParent()) {
|
||||
if (!empty($existing)) {
|
||||
$newExisting = $newExisting . self::SEPARATOR . $existing;
|
||||
}
|
||||
|
||||
return $this->renderStringRecursive(
|
||||
$motive->getParent(),
|
||||
$newExisting,
|
||||
$options
|
||||
);
|
||||
}
|
||||
|
||||
if (!empty($existing)) {
|
||||
return $newExisting . self::SEPARATOR . $existing;
|
||||
}
|
||||
|
||||
return $newExisting;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user