| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
namespace Symfony\Component\Serializer\Mapping\Loader; |
| 13 |
|
| 14 |
use Symfony\Component\Serializer\Exception\MappingException; |
| 15 |
use Symfony\Component\Serializer\Mapping\ClassMetadataInterface; |
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
> |
| 27 |
|
| 28 |
class LoaderChain implements LoaderInterface |
| 29 |
{ |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
public function __construct(private readonly array $loaders) |
| 38 |
{ |
| 39 |
foreach ($loaders as $loader) { |
| 40 |
if (!$loader instanceof LoaderInterface) { |
| 41 |
throw new MappingException(\sprintf('Class "%s" is expected to implement LoaderInterface.', get_debug_type($loader))); |
| 42 |
} |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
public function loadClassMetadata(ClassMetadataInterface $metadata): bool |
| 47 |
{ |
| 48 |
$success = false; |
| 49 |
|
| 50 |
foreach ($this->loaders as $loader) { |
| 51 |
$success = $loader->loadClassMetadata($metadata) || $success; |
| 52 |
} |
| 53 |
|
| 54 |
return $success; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public function getLoaders(): array |
| 61 |
{ |
| 62 |
return $this->loaders; |
| 63 |
} |
| 64 |
} |