public function ConfigEntityRevisionsConverterBase::getEntityTypeFromDefaults in Config Entity Revisions 1.x
Same name and namespace in other branches
- 8.2 src/ConfigEntityRevisionsConverterBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsConverterBase::getEntityTypeFromDefaults()
- 8 src/ConfigEntityRevisionsConverterBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsConverterBase::getEntityTypeFromDefaults()
Determines the entity type ID given a route definition and route defaults.
Parameters
mixed $definition: The parameter definition provided in the route options.
string $name: The name of the parameter.
array $defaults: The route defaults array.
Return value
string The entity type ID.
Throws
ParamNotConvertedException Thrown when the dynamic entity type is not found in the route defaults.
Overrides DynamicEntityTypeParamConverterTrait::getEntityTypeFromDefaults
1 call to ConfigEntityRevisionsConverterBase::getEntityTypeFromDefaults()
- ConfigEntityRevisionsConverterBase::convert in src/
ConfigEntityRevisionsConverterBase.php - Converts path variables to their corresponding objects.
File
- src/
ConfigEntityRevisionsConverterBase.php, line 183
Class
- ConfigEntityRevisionsConverterBase
- Parameter converter for upcasting entity IDs to full objects.
Namespace
Drupal\config_entity_revisionsCode
public function getEntityTypeFromDefaults($definition, $name, array $defaults) {
$entity_type_id = substr($definition['type'], strlen('entity:'));
// If the entity type is dynamic, it will be pulled from the route defaults.
if (strpos($entity_type_id, '{') === 0) {
$entity_type_slug = substr($entity_type_id, 1, -1);
if (!isset($defaults[$entity_type_slug])) {
throw new ParamNotConvertedException(sprintf('The "%s" parameter was not converted because the "%s" parameter is missing', $name, $entity_type_slug));
}
$entity_type_id = $defaults[$entity_type_slug];
}
return $entity_type_id;
}