You are here

class RunConverter in XHProf 8

Casts run identifier into Run object.

Hierarchy

Expanded class hierarchy of RunConverter

See also

\Drupal\xhprof\Controller\XHProfController::runAction()

\Drush\Commands\core\XhprofCommands::xhprofPost()

1 string reference to 'RunConverter'
xhprof.services.yml in ./xhprof.services.yml
xhprof.services.yml
1 service uses RunConverter
xhprof.run_converter in ./xhprof.services.yml
Drupal\xhprof\Routing\RunConverter

File

src/Routing/RunConverter.php, line 15

Namespace

Drupal\xhprof\Routing
View source
class RunConverter implements ParamConverterInterface {

  /**
   * The profiler.
   *
   * @var \Drupal\xhprof\ProfilerInterface
   */
  private $profiler;

  /**
   * Constructs the RunConverter object
   *
   * @param \Drupal\xhprof\ProfilerInterface $profiler
   *   A profiler.
   */
  public function __construct(ProfilerInterface $profiler) {
    $this->profiler = $profiler;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {
    try {
      return $this->profiler
        ->getRun($value);
    } catch (\Exception $e) {
      return NULL;
    }
  }

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

}

Members

Namesort descending Modifiers Type Description Overrides
RunConverter::$profiler private property The profiler.
RunConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
RunConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
RunConverter::__construct public function Constructs the RunConverter object