public function EntityTraversalFactory::getTraversal in General Data Protection Regulation 8
Same name and namespace in other branches
- 8.2 modules/gdpr_fields/src/EntityTraversalFactory.php \Drupal\gdpr_fields\EntityTraversalFactory::getTraversal()
- 3.0.x modules/gdpr_fields/src/EntityTraversalFactory.php \Drupal\gdpr_fields\EntityTraversalFactory::getTraversal()
Instantiates the traversal class.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: Base entity to start recursive traversal.
Return value
\Drupal\gdpr_fields\EntityTraversalInterface Traversal class.
File
- modules/
gdpr_fields/ src/ EntityTraversalFactory.php, line 51
Class
- EntityTraversalFactory
- Factory class for traversing entities.
Namespace
Drupal\gdpr_fieldsCode
public function getTraversal(EntityInterface $entity) {
$traversal_class = $this->traverser;
$class = new \ReflectionClass($traversal_class);
if ($class
->implementsInterface(EntityTraversalInterface::class)) {
/* @var \Drupal\gdpr_fields\EntityTraversalInterface $instance */
$instance = $traversal_class::create($this->container, $entity);
return $instance;
}
// @todo Handle exceptions?
}