You are here

public function EntityParamConverter::convert in Content Planner 8

Converts path variables to their corresponding objects.

Parameters

mixed $value: The raw value.

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

mixed|null The converted parameter value.

Overrides ParamConverterInterface::convert

File

modules/content_kanban/src/ParamConverter/EntityParamConverter.php, line 36

Class

EntityParamConverter
Class EntityParamConverter.

Namespace

Drupal\content_kanban\ParamConverter

Code

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;
}