36 lines
836 B
PHP
36 lines
836 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace External\FlexiBeeBundle\Util;
|
|
|
|
use External\FlexiBeeBundle\Exception\FlexiBeeException;
|
|
use External\FlexiBeeBundle\Synchronizers\SynchronizerInterface;
|
|
use Symfony\Component\DependencyInjection\ServiceLocator;
|
|
|
|
class FlexiBeeLocator
|
|
{
|
|
private ServiceLocator $locator;
|
|
|
|
public function __construct(ServiceLocator $locator)
|
|
{
|
|
$this->locator = $locator;
|
|
}
|
|
|
|
public function getTypes(): array
|
|
{
|
|
return $this->locator->getProvidedServices();
|
|
}
|
|
|
|
public function getServiceByType(string $type): SynchronizerInterface
|
|
{
|
|
if (!$this->locator->has($type)) {
|
|
throw new FlexiBeeException(
|
|
sprintf('Unknown synchronizer type \'%s\'!', $type)
|
|
);
|
|
}
|
|
|
|
return $this->locator->get($type);
|
|
}
|
|
}
|