mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix return type for center resolver
This commit is contained in:
parent
4664394a89
commit
fe3d4e1f0a
@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Security\Resolver;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
|
||||
final class CenterResolverManager implements CenterResolverManagerInterface
|
||||
{
|
||||
/**
|
||||
@ -20,7 +22,17 @@ final class CenterResolverManager implements CenterResolverManagerInterface
|
||||
{
|
||||
foreach($this->resolvers as $resolver) {
|
||||
if ($resolver->supports($entity, $options)) {
|
||||
return (array) $resolver->resolveCenter($entity, $options);
|
||||
$resolved = $resolver->resolveCenter($entity, $options);
|
||||
if (null === $resolved) {
|
||||
return [];
|
||||
} elseif ($resolved instanceof Center) {
|
||||
return [$resolved];
|
||||
} elseif (\is_array($resolved)) {
|
||||
return $resolved;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException(sprintf("the return type of a %s should be an instance of %s, an array or null. Resolver is %s",
|
||||
CenterResolverInterface::class, Center::class, get_class($resolver)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,10 +149,9 @@
|
||||
{% endif %}
|
||||
</li>
|
||||
{% if options['addCenter'] and person|chill_resolve_center|length > 0 %}
|
||||
{% set centers = person|chill_resolve_center %}
|
||||
<li>
|
||||
<i class="fa fa-li fa-long-arrow-right"></i>
|
||||
{% for c in centers %}
|
||||
{% for c in person|chill_resolve_center %}
|
||||
{{ c.name|upper }}{% if not loop.last %}, {% endif %}
|
||||
{% endfor %}
|
||||
</li>
|
||||
|
Loading…
x
Reference in New Issue
Block a user