5 * Contains Drupal\Console\Command\Shared\ServicesTrait.
8 namespace Drupal\Console\Command\Shared;
10 use Drupal\Console\Core\Style\DrupalStyle;
15 * @param DrupalStyle $io
19 public function servicesQuestion(DrupalStyle $io)
22 $this->trans('commands.common.questions.services.confirm'),
26 $service_collection = [];
27 $io->writeln($this->trans('commands.common.questions.services.message'));
28 $services = $this->container->getServiceIds();
30 $service = $io->choiceNoList(
31 $this->trans('commands.common.questions.services.name'),
37 $service = trim($service);
38 if (empty($service)) {
42 array_push($service_collection, $service);
43 $service_key = array_search($service, $services, true);
45 if ($service_key >= 0) {
46 unset($services[$service_key]);
50 return $service_collection;
55 * @param array $services
59 public function buildServices($services)
61 if (!empty($services)) {
63 foreach ($services as $service) {
64 $class = get_class($this->container->get($service));
65 $shortClass = explode('\\', $class);
66 $machineName = str_replace('.', '_', $service);
67 $buildServices[$service] = [
69 'machine_name' => $machineName,
70 'camel_case_name' => $this->stringConverter->underscoreToCamelCase($machineName),
72 'short' => end($shortClass),
76 return $buildServices;