function ParamConverterManager::getConverter

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php \Drupal\Core\ParamConverter\ParamConverterManager::getConverter()
  2. 10 core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php \Drupal\Core\ParamConverter\ParamConverterManager::getConverter()
  3. 9 core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php \Drupal\Core\ParamConverter\ParamConverterManager::getConverter()
  4. 8.9.x core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php \Drupal\Core\ParamConverter\ParamConverterManager::getConverter()

Lazy-loads converter services.

Parameters

string $id: The service id of converter service to load.

Return value

\Drupal\Core\ParamConverter\ParamConverterInterface The loaded converter service identified by the given service id.

Overrides ParamConverterManagerInterface::getConverter

File

core/lib/Drupal/Core/ParamConverter/ParamConverterManager.php, line 32

Class

ParamConverterManager
Manages converter services for converting request parameters to full objects.

Namespace

Drupal\Core\ParamConverter

Code

public function getConverter($converter) {
  if ($this->converters
    ->has($converter)) {
    return $this->converters
      ->get($converter);
  }
  throw new \InvalidArgumentException(sprintf('No converter has been registered for %s', $converter));
}

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