class ChainEntityResolver in Drupal 9
Same name and namespace in other branches
- 8 core/modules/serialization/src/EntityResolver/ChainEntityResolver.php \Drupal\serialization\EntityResolver\ChainEntityResolver
- 10 core/modules/serialization/src/EntityResolver/ChainEntityResolver.php \Drupal\serialization\EntityResolver\ChainEntityResolver
Resolver delegating the entity resolution to a chain of resolvers.
Hierarchy
- class \Drupal\serialization\EntityResolver\ChainEntityResolver implements ChainEntityResolverInterface
Expanded class hierarchy of ChainEntityResolver
1 file declares its use of ChainEntityResolver
- ChainEntityResolverTest.php in core/
modules/ serialization/ tests/ src/ Unit/ EntityResolver/ ChainEntityResolverTest.php
1 string reference to 'ChainEntityResolver'
- serialization.services.yml in core/
modules/ serialization/ serialization.services.yml - core/modules/serialization/serialization.services.yml
1 service uses ChainEntityResolver
- serializer.entity_resolver in core/
modules/ serialization/ serialization.services.yml - Drupal\serialization\EntityResolver\ChainEntityResolver
File
- core/
modules/ serialization/ src/ EntityResolver/ ChainEntityResolver.php, line 10
Namespace
Drupal\serialization\EntityResolverView source
class ChainEntityResolver implements ChainEntityResolverInterface {
/**
* The concrete resolvers.
*
* @var \Drupal\serialization\EntityResolver\EntityResolverInterface[]
*/
protected $resolvers = [];
/**
* Constructs a ChainEntityResolver object.
*
* @param \Drupal\serialization\EntityResolver\EntityResolverInterface[] $resolvers
* The array of concrete resolvers.
*/
public function __construct(array $resolvers = []) {
$this->resolvers = $resolvers;
}
/**
* {@inheritdoc}
*/
public function addResolver(EntityResolverInterface $resolver) {
$this->resolvers[] = $resolver;
}
/**
* {@inheritdoc}
*/
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;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ChainEntityResolver:: |
protected | property | The concrete resolvers. | |
ChainEntityResolver:: |
public | function |
Adds an entity resolver. Overrides ChainEntityResolverInterface:: |
|
ChainEntityResolver:: |
public | function |
Returns the local ID of an entity referenced by serialized data. Overrides EntityResolverInterface:: |
|
ChainEntityResolver:: |
public | function | Constructs a ChainEntityResolver object. |