class EntityTraversalFactory in General Data Protection Regulation 8.2
Same name and namespace in other branches
- 8 modules/gdpr_fields/src/EntityTraversalFactory.php \Drupal\gdpr_fields\EntityTraversalFactory
- 3.0.x modules/gdpr_fields/src/EntityTraversalFactory.php \Drupal\gdpr_fields\EntityTraversalFactory
Factory class for traversing entities.
@package Drupal\gdpr_fields
Hierarchy
- class \Drupal\gdpr_fields\EntityTraversalFactory
Expanded class hierarchy of EntityTraversalFactory
2 files declare their use of EntityTraversalFactory
- Anonymizer.php in modules/
gdpr_tasks/ src/ Anonymizer.php - GdprTasksSarWorker.php in modules/
gdpr_tasks/ src/ Plugin/ QueueWorker/ GdprTasksSarWorker.php
1 string reference to 'EntityTraversalFactory'
- gdpr_tasks.services.yml in modules/
gdpr_tasks/ gdpr_tasks.services.yml - modules/gdpr_tasks/gdpr_tasks.services.yml
4 services use EntityTraversalFactory
- gdpr_tasks.rta_display_traversal in modules/
gdpr_tasks/ gdpr_tasks.services.yml - Drupal\gdpr_fields\EntityTraversalFactory
- gdpr_tasks.rta_traversal in modules/
gdpr_tasks/ gdpr_tasks.services.yml - Drupal\gdpr_fields\EntityTraversalFactory
- gdpr_tasks.rtf_display_traversal in modules/
gdpr_tasks/ gdpr_tasks.services.yml - Drupal\gdpr_fields\EntityTraversalFactory
- gdpr_tasks.rtf_traversal in modules/
gdpr_tasks/ gdpr_tasks.services.yml - Drupal\gdpr_fields\EntityTraversalFactory
File
- modules/
gdpr_fields/ src/ EntityTraversalFactory.php, line 14
Namespace
Drupal\gdpr_fieldsView source
class EntityTraversalFactory {
/**
* The service container.
*
* @var \Symfony\Component\DependencyInjection\ContainerInterface
*/
protected $container;
/**
* The traversal class name to be instantiated.
*
* @var string
*/
protected $traverser;
/**
* EntityTraversal constructor.
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container.
* @param string $traverser
* The traversal class name.
*/
public function __construct(ContainerInterface $container, $traverser) {
$this->container = $container;
$this->traverser = $traverser;
}
/**
* Instantiates the traversal class.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* Base entity to start recursive traversal.
*
* @return \Drupal\gdpr_fields\EntityTraversalInterface
* Traversal class.
*/
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?
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityTraversalFactory:: |
protected | property | The service container. | |
EntityTraversalFactory:: |
protected | property | The traversal class name to be instantiated. | |
EntityTraversalFactory:: |
public | function | Instantiates the traversal class. | |
EntityTraversalFactory:: |
public | function | EntityTraversal constructor. |