1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file was created by developers working at BitBag |
||
5 | * Do you need more information about us and what we do? Visit our https://bitbag.io website! |
||
6 | * We are hiring developers from all over the world. Join us and start your new, exciting adventure and become part of us: https://bitbag.io/career |
||
7 | */ |
||
8 | |||
9 | declare(strict_types=1); |
||
10 | |||
11 | namespace BitBag\SyliusCmsPlugin\Resolver; |
||
12 | |||
13 | use BitBag\SyliusCmsPlugin\Entity\MediaInterface; |
||
14 | use BitBag\SyliusCmsPlugin\MediaProvider\ProviderInterface; |
||
15 | use Sylius\Component\Registry\ServiceRegistryInterface; |
||
16 | use Webmozart\Assert\Assert; |
||
17 | |||
18 | final class MediaProviderResolver implements MediaProviderResolverInterface |
||
19 | { |
||
20 | /** @var ServiceRegistryInterface */ |
||
21 | private $providerRegistry; |
||
22 | |||
23 | public function __construct(ServiceRegistryInterface $providerRegistry) |
||
24 | { |
||
25 | $this->providerRegistry = $providerRegistry; |
||
26 | } |
||
27 | |||
28 | public function resolveProvider(MediaInterface $media): ProviderInterface |
||
29 | { |
||
30 | Assert::notNull($media->getType()); |
||
31 | /** @var ProviderInterface $provider */ |
||
32 | $provider = $this->providerRegistry->get($media->getType()); |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
33 | |||
34 | return $provider; |
||
35 | } |
||
36 | } |
||
37 |