function ContainerInfoController::serviceList
Same name in other branches
- 4.x src/Controller/ContainerInfoController.php \Drupal\devel\Controller\ContainerInfoController::serviceList()
Builds the services overview page.
Return value
array A render array as expected by the renderer.
1 string reference to 'ContainerInfoController::serviceList'
File
-
src/
Controller/ ContainerInfoController.php, line 47
Class
- ContainerInfoController
- Provides route responses for the container info pages.
Namespace
Drupal\devel\ControllerCode
public function serviceList() : array {
$headers = [
$this->t('ID'),
$this->t('Class'),
$this->t('Alias'),
$this->t('Operations'),
];
$rows = [];
if ($cached_definitions = $this->kernel
->getCachedContainerDefinition()) {
foreach ($cached_definitions['services'] as $service_id => $definition) {
$service = unserialize($definition);
$row['id'] = [
'data' => $service_id,
'filter' => TRUE,
];
$row['class'] = [
'data' => $service['class'] ?? '',
'filter' => TRUE,
];
$row['alias'] = [
'data' => array_search($service_id, $cached_definitions['aliases'], TRUE) ?: '',
'filter' => TRUE,
];
$row['operations']['data'] = [
'#type' => 'operations',
'#links' => [
'devel' => [
'title' => $this->t('Devel'),
'url' => Url::fromRoute('devel.container_info.service.detail', [
'service_id' => $service_id,
]),
'attributes' => [
'class' => [
'use-ajax',
],
'data-dialog-type' => 'modal',
'data-dialog-options' => Json::encode([
'width' => 700,
'minHeight' => 500,
]),
],
],
],
];
$rows[$service_id] = $row;
}
ksort($rows);
}
$output['services'] = [
'#type' => 'devel_table_filter',
'#filter_label' => $this->t('Search'),
'#filter_placeholder' => $this->t('Enter service id, alias or class'),
'#filter_description' => $this->t('Enter a part of the service id, service alias or class to filter by.'),
'#header' => $headers,
'#rows' => $rows,
'#empty' => $this->t('No services found.'),
'#sticky' => TRUE,
'#attributes' => [
'class' => [
'devel-service-list',
],
],
];
return $output;
}