function ContainerInfoController::serviceDetail
Same name in other branches
- 5.x src/Controller/ContainerInfoController.php \Drupal\devel\Controller\ContainerInfoController::serviceDetail()
Returns a render array representation of the service.
Parameters
string $service_id: The ID of the service to retrieve.
Return value
array A render array containing the service detail.
Throws
\Symfony\Component\HttpKernel\Exception\NotFoundHttpException If the requested service is not defined.
1 string reference to 'ContainerInfoController::serviceDetail'
File
-
src/
Controller/ ContainerInfoController.php, line 145
Class
- ContainerInfoController
- Provides route responses for the container info pages.
Namespace
Drupal\devel\ControllerCode
public function serviceDetail($service_id) {
$instance = $this->container
->get($service_id, ContainerInterface::NULL_ON_INVALID_REFERENCE);
if ($instance === NULL) {
throw new NotFoundHttpException();
}
$output = [];
if ($cached_definitions = $this->kernel
->getCachedContainerDefinition()) {
// Tries to retrieve the service definition from the kernel's cached
// container definition.
if (isset($cached_definitions['services'][$service_id])) {
$definition = unserialize($cached_definitions['services'][$service_id]);
// If the service has an alias add it to the definition.
if ($alias = array_search($service_id, $cached_definitions['aliases'])) {
$definition['alias'] = $alias;
}
$output['definition'] = $this->dumper
->exportAsRenderable($definition, $this->t('Computed Definition'));
}
}
$output['instance'] = $this->dumper
->exportAsRenderable($instance, $this->t('Instance'));
return $output;
}