public function DevelCommands::services in Devel 8.3
Same name and namespace in other branches
- 8 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::services()
- 8.2 src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::services()
- 4.x src/Commands/DevelCommands.php \Drupal\devel\Commands\DevelCommands::services()
Get a list of available container services.
@command devel:services
@aliases devel-container-services,dcs,devel-services @usage drush devel-services Gets a list of all available container services @usage drush dcs plugin.manager Get all services containing "plugin.manager"
Parameters
string $prefix: Optional prefix to filter the service list by.
array $options: An array of options (is this used?)
Return value
array The container service ids.
File
- src/
Commands/ DevelCommands.php, line 301
Class
- DevelCommands
- Class DevelCommands.
Namespace
Drupal\devel\CommandsCode
public function services($prefix = NULL, array $options = [
'format' => 'yaml',
]) {
$container = $this
->getContainer();
// Get a list of all available service IDs.
$services = $container
->getServiceIds();
// If there is a prefix, try to find matches.
if (isset($prefix)) {
$services = preg_grep("/{$prefix}/", $services);
}
if (empty($services)) {
throw new \Exception(dt('No container services found.'));
}
sort($services);
return $services;
}