class ChainEntityResolver
Same name in other branches
- 9 core/modules/serialization/src/EntityResolver/ChainEntityResolver.php \Drupal\serialization\EntityResolver\ChainEntityResolver
- 8.9.x 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 \Drupal\serialization\EntityResolver\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
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ChainEntityResolver::$resolvers | protected | property | The concrete resolvers. |
ChainEntityResolver::addResolver | public | function | |
ChainEntityResolver::resolve | public | function | |
ChainEntityResolver::__construct | public | function | Constructs a ChainEntityResolver object. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.