class EntityParamConverter in Content Planner 8
Class EntityParamConverter.
Hierarchy
- class \Drupal\content_kanban\ParamConverter\EntityParamConverter implements ParamConverterInterface
Expanded class hierarchy of EntityParamConverter
1 string reference to 'EntityParamConverter'
- content_kanban.services.yml in modules/
content_kanban/ content_kanban.services.yml - modules/content_kanban/content_kanban.services.yml
1 service uses EntityParamConverter
- content_kanban.entity_params in modules/
content_kanban/ content_kanban.services.yml - Drupal\content_kanban\ParamConverter\EntityParamConverter
File
- modules/
content_kanban/ src/ ParamConverter/ EntityParamConverter.php, line 14
Namespace
Drupal\content_kanban\ParamConverterView source
class EntityParamConverter implements ParamConverterInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* EntityParamConverter constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManager $entityTypeManager
* The entity type manager service.
*/
public function __construct(EntityTypeManager $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
}
/**
* {@inheritdoc}
*/
public function convert($value, $definition, $name, array $defaults) {
try {
$entityType = $this->entityTypeManager
->getStorage($defaults['entity_type']);
$entity = $entityType
->load($value);
return $entity;
} catch (InvalidPluginDefinitionException $e) {
watchdog_exception('content_kanban', $e);
} catch (PluginNotFoundException $e) {
watchdog_exception('content_kanban', $e);
}
return NULL;
}
/**
* {@inheritdoc}
*/
public function applies($definition, $name, Route $route) {
return !empty($definition['type']) && $definition['type'] == 'entity';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityParamConverter:: |
protected | property | The entity type manager. | |
EntityParamConverter:: |
public | function |
Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface:: |
|
EntityParamConverter:: |
public | function |
Converts path variables to their corresponding objects. Overrides ParamConverterInterface:: |
|
EntityParamConverter:: |
public | function | EntityParamConverter constructor. |