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,20 +1,29 @@
|
||||
<?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\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use function array_merge;
|
||||
|
||||
class UserRender implements ChillEntityRenderInterface
|
||||
{
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
public const DEFAULT_OPTIONS = [
|
||||
'main_scope' => true,
|
||||
'user_job' => true,
|
||||
];
|
||||
|
||||
private EngineInterface $engine;
|
||||
|
||||
const DEFAULT_OPTIONS = [
|
||||
'main_scope' => true,
|
||||
'user_job' => true
|
||||
];
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||
{
|
||||
@@ -22,45 +31,40 @@ class UserRender implements ChillEntityRenderInterface
|
||||
$this->engine = $engine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function supports($entity, array $options): bool
|
||||
public function renderBox($entity, array $options): string
|
||||
{
|
||||
return $entity instanceof User;
|
||||
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
|
||||
return $this->engine->render('@ChillMain/Entity/user.html.twig', [
|
||||
'user' => $entity,
|
||||
'opts' => $opts,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param User $entity
|
||||
*/
|
||||
public function renderString($entity, array $options): string
|
||||
{
|
||||
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
$opts = array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
|
||||
$str = $entity->getLabel();
|
||||
if (NULL !== $entity->getUserJob() && $opts['user_job']) {
|
||||
$str .= ' ('.$this->translatableStringHelper
|
||||
->localize($entity->getUserJob()->getLabel()).')';
|
||||
|
||||
if (null !== $entity->getUserJob() && $opts['user_job']) {
|
||||
$str .= ' (' . $this->translatableStringHelper
|
||||
->localize($entity->getUserJob()->getLabel()) . ')';
|
||||
}
|
||||
if (NULL !== $entity->getMainScope() && $opts['main_scope']) {
|
||||
$str .= ' ('.$this->translatableStringHelper
|
||||
->localize($entity->getMainScope()->getName()).')';
|
||||
|
||||
if (null !== $entity->getMainScope() && $opts['main_scope']) {
|
||||
$str .= ' (' . $this->translatableStringHelper
|
||||
->localize($entity->getMainScope()->getName()) . ')';
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function renderBox($entity, array $options): string
|
||||
public function supports($entity, array $options): bool
|
||||
{
|
||||
$opts = \array_merge(self::DEFAULT_OPTIONS, $options);
|
||||
|
||||
return $this->engine->render('@ChillMain/Entity/user.html.twig', [
|
||||
'user' => $entity,
|
||||
'opts' => $opts
|
||||
]);
|
||||
return $entity instanceof User;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user