You are here

class TokenConverter in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Routing/TokenConverter.php \Drupal\webprofiler\Routing\TokenConverter
  2. 8.2 webprofiler/src/Routing/TokenConverter.php \Drupal\webprofiler\Routing\TokenConverter
  3. 4.x webprofiler/src/Routing/TokenConverter.php \Drupal\webprofiler\Routing\TokenConverter

Class TokenConverter

Hierarchy

Expanded class hierarchy of TokenConverter

1 string reference to 'TokenConverter'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses TokenConverter
webprofiler.token_converter in webprofiler/webprofiler.services.yml
Drupal\webprofiler\Routing\TokenConverter

File

webprofiler/src/Routing/TokenConverter.php, line 11

Namespace

Drupal\webprofiler\Routing
View source
class TokenConverter implements ParamConverterInterface {

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {

    // "profiler" service isn't injected to prevent circular reference when
    // more than one language is active and "Account administration pages" is
    // enabled on admin/config/regional/language/detection. See #2710787 for
    // more information.

    /** @var \Drupal\webprofiler\Profiler\Profiler $profiler */
    $profiler = \Drupal::service('profiler');
    if (NULL === $profiler) {
      return NULL;
    }
    $profile = $profiler
      ->loadProfile($value);
    if (NULL === $profile) {
      return NULL;
    }
    return $profile;
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    if (!empty($definition['type']) && $definition['type'] === 'webprofiler:token') {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TokenConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
TokenConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert