ChainEntityResolver.php in Drupal 10
File
core/modules/serialization/src/EntityResolver/ChainEntityResolver.php
View source
<?php
namespace Drupal\serialization\EntityResolver;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
class ChainEntityResolver implements ChainEntityResolverInterface {
protected $resolvers = [];
public function __construct(array $resolvers = []) {
$this->resolvers = $resolvers;
}
public function addResolver(EntityResolverInterface $resolver) {
$this->resolvers[] = $resolver;
}
public function resolve(NormalizerInterface $normalizer, $data, $entity_type) {
foreach ($this->resolvers as $resolver) {
$resolved = $resolver
->resolve($normalizer, $data, $entity_type);
if (isset($resolved)) {
return $resolved;
}
}
}
}