Skip to content

Commit 525ea2e

Browse files
committed
Added commands to enable/disable db profiler
1 parent 4b3963b commit 525ea2e

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace ClawRock\Debug\Console\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class DatabaseProfilerDisableCommand extends Command
10+
{
11+
/**
12+
* @var \ClawRock\Debug\Model\Config\Database\ProfilerWriter
13+
*/
14+
private $profilerWriter;
15+
16+
public function __construct(
17+
\ClawRock\Debug\Model\Config\Database\ProfilerWriter $profilerWriter
18+
) {
19+
parent::__construct('debug:db-profiler:disable');
20+
21+
$this->profilerWriter = $profilerWriter;
22+
}
23+
24+
protected function configure()
25+
{
26+
parent::configure();
27+
28+
$this->setDescription('Disable database profiler required for database collector.');
29+
}
30+
31+
/**
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
protected function execute(InputInterface $input, OutputInterface $output)
35+
{
36+
$this->profilerWriter->save(false);
37+
38+
$output->writeLn('<info>Database profiler disabled!</info>');
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace ClawRock\Debug\Console\Command;
4+
5+
use Symfony\Component\Console\Command\Command;
6+
use Symfony\Component\Console\Input\InputInterface;
7+
use Symfony\Component\Console\Output\OutputInterface;
8+
9+
class DatabaseProfilerEnableCommand extends Command
10+
{
11+
/**
12+
* @var \ClawRock\Debug\Model\Config\Database\ProfilerWriter
13+
*/
14+
private $profilerWriter;
15+
16+
public function __construct(
17+
\ClawRock\Debug\Model\Config\Database\ProfilerWriter $profilerWriter
18+
) {
19+
parent::__construct('debug:db-profiler:enable');
20+
21+
$this->profilerWriter = $profilerWriter;
22+
}
23+
24+
protected function configure()
25+
{
26+
parent::configure();
27+
28+
$this->setDescription('Enable database profiler required for database collector.');
29+
}
30+
31+
/**
32+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
*/
34+
protected function execute(InputInterface $input, OutputInterface $output)
35+
{
36+
$this->profilerWriter->save(true);
37+
38+
$output->writeLn('<info>Database profiler enabled!</info>');
39+
}
40+
}

etc/di.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,12 @@
8484
</argument>
8585
</arguments>
8686
</type>
87+
<type name="Magento\Framework\Console\CommandListInterface">
88+
<arguments>
89+
<argument name="commands" xsi:type="array">
90+
<item name="ClawRock_Debug::enable_database_profiler" xsi:type="object">ClawRock\Debug\Console\Command\DatabaseProfilerEnableCommand</item>
91+
<item name="ClawRock_Debug::disable_database_profiler" xsi:type="object">ClawRock\Debug\Console\Command\DatabaseProfilerDisableCommand</item>
92+
</argument>
93+
</arguments>
94+
</type>
8795
</config>

0 commit comments

Comments
 (0)