class EntityRevisionParamConverter in Entity API 8.0
Parameter converter for single revisions.
Hierarchy
- class \Drupal\entity\ParamConverter\EntityRevisionParamConverter implements ParamConverterInterface
Expanded class hierarchy of EntityRevisionParamConverter
1 file declares its use of EntityRevisionParamConverter
- EntityRevisionParamConverterTest.php in tests/
src/ Unit/ ParamConverter/ EntityRevisionParamConverterTest.php - Contains \Drupal\Tests\entity\Unit\ParamConverter\EntityRevisionParamConverterTest.
1 string reference to 'EntityRevisionParamConverter'
1 service uses EntityRevisionParamConverter
File
- src/
ParamConverter/ EntityRevisionParamConverter.php, line 18 - Contains \Drupal\entity\ParamConverter\EntityRevisionParamConverter.
Namespace
Drupal\entity\ParamConverterView source
class EntityRevisionParamConverter implements ParamConverterInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Creates a new EntityRevisionParamConverter instance.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
list(, $entity_type_id) = explode(':', $definition['type']);
$entity_storage = $this->entityTypeManager
->getStorage($entity_type_id);
return $entity_storage
->loadRevision($value);
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return isset($definition['type']) && strpos($definition['type'], 'entity_revision:') !== FALSE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityRevisionParamConverter:: |
protected | property | The entity type manager. | |
EntityRevisionParamConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
EntityRevisionParamConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
EntityRevisionParamConverter:: |
public | function | Creates a new EntityRevisionParamConverter instance. |