class UuidConverter in Email confirmer 8
Email confirmation UUID param converter.
Hierarchy
- class \Drupal\email_confirmer\ParamConverter\UuidConverter implements ParamConverterInterface
Expanded class hierarchy of UuidConverter
1 string reference to 'UuidConverter'
1 service uses UuidConverter
File
- src/
ParamConverter/ UuidConverter.php, line 13
Namespace
Drupal\email_confirmer\ParamConverterView source
class UuidConverter implements ParamConverterInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Construct an email confirmation UUID param converter.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
$confirmation = NULL;
if (Uuid::isValid($value) && ($storage = $this->entityTypeManager
->getStorage('email_confirmer_confirmation'))) {
$entities = $storage
->loadByProperties([
'uuid' => $value,
]);
$confirmation = $entities ? reset($entities) : NULL;
}
return $confirmation;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'email-confirmer-confirmation-uuid';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
UuidConverter:: |
protected | property | The entity type manager. | |
UuidConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
UuidConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
UuidConverter:: |
public | function | Construct an email confirmation UUID param converter. |