chill-bundles/src/Bundle/ChillMainBundle/Security/Resolver/CenterResolverDispatcher.php

48 lines
1.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Chill\MainBundle\Security\Resolver;
use Chill\MainBundle\Entity\Center;
/**
* @deprecated Use CenterResolverManager and its interface CenterResolverManagerInterface
*/
final class CenterResolverDispatcher
{
/**
* @var CenterResolverInterface[]
*/
private iterable $resolvers;
public function __construct(iterable $resolvers = [])
{
$this->resolvers = $resolvers;
}
/**
* @return null|Center|Center[]
*/
public function resolveCenter($entity, ?array $options = [])
{
trigger_deprecation(
'ChillMainBundle',
'dev-master',
'
Use the service CenterResolverManager through the interface CenterResolverManagerInterface.
The new method "CenterResolverManagerInterface::resolveCenters(): array" is available and the typing
has been improved in order to avoid mixing types.
'
);
foreach($this->resolvers as $resolver) {
if ($resolver->supports($entity, $options)) {
return $resolver->resolveCenter($entity, $options);
}
}
return null;
}
}