public function DevelCommands::services in Devel 8
Same name and namespace in other branches
- 8.3 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
$prefix A prefix to filter the service list by.:
Return value
array
File
- src/
Commands/ DevelCommands.php, line 246  
Class
- DevelCommands
 - For commands that are parts of modules, Drush expects to find commandfiles in __MODULE__/src/Commands, and the namespace is Drupal/__MODULE__/Commands.
 
Namespace
Drupal\devel\CommandsCode
public function services($prefix = NULL, $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;
}