forked from hechoendrupal/drupal-console
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerDebugCommand.php
More file actions
46 lines (40 loc) · 1.46 KB
/
Copy pathContainerDebugCommand.php
File metadata and controls
46 lines (40 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file
* Contains \Drupal\AppConsole\Command\ContainerDebugCommand.
*/
namespace Drupal\AppConsole\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ContainerDebugCommand extends ContainerAwareCommand
{
protected function configure()
{
$this
->setName('container:debug')
->setDescription('Displays current services for an application')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
// skip services
// service declaration at core/core.services.yml file, arguments are not properly set, must be
// arguments: ['@controller_resolver', '@entity.manager', '@form_builder', NULL]
$skip[] = 'controller.entityform';
// scope: request declaration make it fails on container->get($id)
// find a better way to retrieve services filtering by tag or scope
$skip = array_merge($skip, ['finish_response_subscriber', 'redirect_response_subscriber']);
$services = $this->getServices();
$table = $this->getHelperSet()->get('table');
$table->setHeaders(['Service ID', 'Class name']);
$table->setlayout($table::LAYOUT_COMPACT);
foreach ($services as $serviceId) {
if ( false === array_search($serviceId, $skip) ) {
$service = $this->getContainer()->get($serviceId);
$class = get_class($service);
$table->addRow([$serviceId, $class]);
}
}
$table->render($output);
}
}