public function PluginController::pluginSourceCode in Plugin 8
Returns example content for dialog testing.
File
- src/
Controller/ pluginController.php, line 45 - Contains \Drupal\plugin\PluginController.
Class
- PluginController
- Provides content for dialog tests.
Namespace
Drupal\plugin\ControllerCode
public function pluginSourceCode($service_id, $plugin_id) {
try {
$definitions = \Drupal::service($service_id)
->getDefinitions();
} catch (\Exception $e) {
throw new NotFoundHttpException();
}
if (isset($definitions[$plugin_id])) {
$definition = $definitions[$plugin_id];
}
else {
throw new NotFoundHttpException();
}
// Some classes stats with '\'.
$class = ltrim($definition['class'], '\\');
$file = $this->classLoader
->findFile($class);
//drupal_set_title($path);
$build['#title'] = $class;
$build['#markup'] = highlight_file($file, TRUE);
return $build;
}