Merge remote-tracking branch 'origin/master' into features/activity-form

This commit is contained in:
2021-06-08 17:24:47 +02:00
130 changed files with 4288 additions and 1221 deletions

View File

@@ -23,6 +23,8 @@ namespace Chill\PersonBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Symfony\Component\Templating\EngineInterface;
/**
* Render a Person
@@ -30,15 +32,16 @@ use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
*/
class PersonRender extends AbstractChillEntityRender
{
/**
*
* @var ConfigPersonAltNamesHelper
*/
protected $configAltNamesHelper;
private ConfigPersonAltNamesHelper $configAltNamesHelper;
private EngineInterface $engine;
public function __construct(ConfigPersonAltNamesHelper $configAltNamesHelper)
{
public function __construct(
ConfigPersonAltNamesHelper $configAltNamesHelper,
EngineInterface $engine
) {
$this->configAltNamesHelper = $configAltNamesHelper;
$this->engine = $engine;
}
/**
@@ -49,13 +52,13 @@ class PersonRender extends AbstractChillEntityRender
*/
public function renderBox($person, array $options): string
{
return
$this->getDefaultOpeningBox('person').
'<span class="chill_denomination">'.$person->getFirstName().'</span>'.
' <span class="chill_denomination">'.$person->getLastName().'</span>'.
$this->addAltNames($person, true).
$this->getDefaultClosingBox()
;
return $this->engine->render('@ChillPerson/Entity/person.html.twig',
[
'person' => $person,
'addAltNames' => $this->configAltNamesHelper->hasAltNames(),
'addLink' => $options['addLink'] ?? false
]
);
}
/**
@@ -69,7 +72,7 @@ class PersonRender extends AbstractChillEntityRender
return $person->getFirstName().' '.$person->getLastName()
.$this->addAltNames($person, false);
}
protected function addAltNames(Person $person, bool $addSpan)
{
$str = '';

View File

@@ -5,9 +5,10 @@ namespace Chill\PersonBundle\Templating\Entity;
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use RuntimeException;
use Symfony\Component\Templating\EngineInterface;
class SocialIssueRender implements ChillEntityRenderInterface
final class SocialIssueRender implements ChillEntityRenderInterface
{
private TranslatableStringHelper $translatableStringHelper;
private EngineInterface $engine;
@@ -28,11 +29,14 @@ class SocialIssueRender implements ChillEntityRenderInterface
{
return $entity instanceof SocialIssue;
}
/**
* @param SocialIssue $socialIssue
*/
public function renderString($socialIssue, array $options): string
{
/** @var $socialIssue SocialIssue */
$options = \array_merge(self::DEFAULT_ARGS, $options);
$options = array_merge(self::DEFAULT_ARGS, $options);
$str = $this->translatableStringHelper->localize($socialIssue->getTitle());
@@ -46,26 +50,36 @@ class SocialIssueRender implements ChillEntityRenderInterface
return $str;
}
protected function buildParents($socialIssue): array
protected function buildParents(SocialIssue $socialIssue): array
{
$parents = [];
while ($socialIssue->hasParent()) {
$socialIssue = $parents[] = $socialIssue->getParent();
}
return $parents;
}
}
/**
*
* @param SocialIssue $socialIssue
*/
public function renderBox($socialIssue, array $options): string
{
$options = \array_merge(self::DEFAULT_ARGS, $options);
$options = array_merge(self::DEFAULT_ARGS, $options);
// give some help to twig: an array of parents
$parents = $this->buildParents($socialIssue);
return $this->engine->render('@ChillPerson/Entity/social_issue.html.twig', [
'socialIssue' => $socialIssue,
'parents' => $parents,
'options' => $options
]);
return $this
->engine
->render(
'@ChillPerson/Entity/social_issue.html.twig',
[
'socialIssue' => $socialIssue,
'parents' => $parents,
'options' => $options
]
);
}
}