function AdminPathConfigEntityConverter::convert

Same name in this branch
  1. 10 core/lib/Drupal/Core/ProxyClass/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ProxyClass\ParamConverter\AdminPathConfigEntityConverter::convert()
Same name in other branches
  1. 9 core/lib/Drupal/Core/ProxyClass/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ProxyClass\ParamConverter\AdminPathConfigEntityConverter::convert()
  2. 9 core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ParamConverter\AdminPathConfigEntityConverter::convert()
  3. 8.9.x core/lib/Drupal/Core/ProxyClass/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ProxyClass\ParamConverter\AdminPathConfigEntityConverter::convert()
  4. 8.9.x core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ParamConverter\AdminPathConfigEntityConverter::convert()
  5. 11.x core/lib/Drupal/Core/ProxyClass/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ProxyClass\ParamConverter\AdminPathConfigEntityConverter::convert()
  6. 11.x core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php \Drupal\Core\ParamConverter\AdminPathConfigEntityConverter::convert()

Overrides EntityConverter::convert

1 method overrides AdminPathConfigEntityConverter::convert()
ViewUIConverter::convert in core/modules/views_ui/src/ParamConverter/ViewUIConverter.php
Converts path variables to their corresponding objects.

File

core/lib/Drupal/Core/ParamConverter/AdminPathConfigEntityConverter.php, line 64

Class

AdminPathConfigEntityConverter
Makes sure the unmodified ConfigEntity is loaded on admin pages.

Namespace

Drupal\Core\ParamConverter

Code

public function convert($value, $definition, $name, array $defaults) {
    $entity_type_id = $this->getEntityTypeFromDefaults($definition, $name, $defaults);
    if (!$this->entityTypeManager
        ->hasDefinition($entity_type_id)) {
        return NULL;
    }
    // If the entity type is dynamic, confirm it to be a config entity. Static
    // entity types will have performed this check in self::applies().
    if (str_starts_with($definition['type'], 'entity:{')) {
        $entity_type = $this->entityTypeManager
            ->getDefinition($entity_type_id);
        if (!$entity_type->entityClassImplements(ConfigEntityInterface::class)) {
            return parent::convert($value, $definition, $name, $defaults);
        }
    }
    if ($storage = $this->entityTypeManager
        ->getStorage($entity_type_id)) {
        // Make sure no overrides are loaded.
        return $storage->loadOverrideFree($value);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.