1 | <?php |
||
28 | class DebugAspectCommand extends BaseAspectCommand |
||
29 | { |
||
30 | /** |
||
31 | * {@inheritDoc} |
||
32 | */ |
||
33 | protected function configure(): void |
||
34 | { |
||
35 | parent::configure(); |
||
36 | $this |
||
37 | ->setName('debug:aspect') |
||
38 | ->addOption('aspect', null, InputOption::VALUE_OPTIONAL, 'Optional aspect name to filter') |
||
39 | ->setDescription('Provides an interface for querying the information about aspects') |
||
40 | ->setHelp( |
||
41 | <<<EOT |
||
42 | Allows to query an information about enabled aspects. |
||
43 | EOT |
||
44 | ) |
||
45 | ; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * {@inheritDoc} |
||
50 | */ |
||
51 | protected function execute(InputInterface $input, OutputInterface $output): int |
||
52 | { |
||
53 | $this->loadAspectKernel($input, $output); |
||
54 | |||
55 | $io = new SymfonyStyle($input, $output); |
||
56 | |||
57 | $container = $this->aspectKernel->getContainer(); |
||
58 | $aspects = []; |
||
59 | $io->title('Aspect debug information'); |
||
60 | |||
61 | $aspectName = $input->getOption('aspect'); |
||
62 | if (!$aspectName) { |
||
63 | $io->text('<info>' . get_class($this->aspectKernel) . '</info> has following enabled aspects:'); |
||
64 | $aspects = $container->getByTag('aspect'); |
||
65 | } else { |
||
66 | $aspect = $container->getAspect($aspectName); |
||
67 | $aspects[] = $aspect; |
||
68 | } |
||
69 | $this->showRegisteredAspectsInfo($io, $aspects); |
||
70 | |||
71 | return 0; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Shows an information about registered aspects |
||
76 | * |
||
77 | * @param Aspect[] $aspects List of aspects |
||
78 | */ |
||
79 | private function showRegisteredAspectsInfo(SymfonyStyle $io, array $aspects): void |
||
80 | { |
||
81 | foreach ($aspects as $aspect) { |
||
82 | $this->showAspectInfo($io, $aspect); |
||
83 | } |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Displays an information about single aspect |
||
88 | */ |
||
89 | private function showAspectInfo(SymfonyStyle $io, Aspect $aspect): void |
||
101 | |||
102 | /** |
||
103 | * Shows an information about aspect pointcuts and advisors |
||
104 | */ |
||
105 | private function showAspectPointcutsAndAdvisors(SymfonyStyle $io, Aspect $aspect): void |
||
127 | |||
128 | /** |
||
129 | * Gets the reformatted comment text. |
||
130 | */ |
||
131 | private function getPrettyText(string $comment): string |
||
137 | } |
||
138 |