Skip to content

Commit dbff27d

Browse files
author
Oleksii Korshenko
committed
MAGETWO-69544: new CLI command: Enable Template Hints #9778
- Merge Pull Request #9778 from miguelbalparda/magento2:cli-template-hints-clean
2 parents 6086595 + 40a4275 commit dbff27d

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Developer\Console\Command;
8+
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
13+
class TemplateHintsDisableCommand extends Command
14+
{
15+
/**
16+
* command name
17+
*/
18+
const COMMAND_NAME = 'dev:template-hints:disable';
19+
20+
/**
21+
* Success message
22+
*/
23+
const SUCCESS_MESSAGE = "Template hints disabled. Refresh cache types";
24+
25+
/**
26+
* TemplateHintsDisableCommand constructor.
27+
* @param \Magento\Config\Model\ResourceModel\Config $resourceConfig
28+
*/
29+
public function __construct(
30+
\Magento\Config\Model\ResourceModel\Config $resourceConfig
31+
) {
32+
parent::__construct();
33+
$this->_resourceConfig = $resourceConfig;
34+
}
35+
36+
/**
37+
* {@inheritdoc}
38+
*/
39+
protected function configure()
40+
{
41+
$this->setName(self::COMMAND_NAME)
42+
->setDescription('Disable frontend template hints. A cache flush might be required.');
43+
44+
parent::configure();
45+
}
46+
47+
/**
48+
* {@inheritdoc}
49+
* @throws \InvalidArgumentException
50+
*/
51+
protected function execute(InputInterface $input, OutputInterface $output)
52+
{
53+
$this->_resourceConfig->saveConfig(
54+
'dev/debug/template_hints_storefront',
55+
0,
56+
'default',
57+
0
58+
);
59+
60+
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");
61+
}
62+
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Developer\Console\Command;
8+
9+
use Symfony\Component\Console\Command\Command;
10+
use Symfony\Component\Console\Input\InputInterface;
11+
use Symfony\Component\Console\Output\OutputInterface;
12+
13+
14+
class TemplateHintsEnableCommand extends Command
15+
{
16+
17+
/**
18+
* command name
19+
*/
20+
const COMMAND_NAME = 'dev:template-hints:enable';
21+
22+
/**
23+
* Success message
24+
*/
25+
const SUCCESS_MESSAGE = "Template hints enabled.";
26+
27+
/**
28+
* TemplateHintsDisableCommand constructor.
29+
* @param \Magento\Config\Model\ResourceModel\Config $resourceConfig
30+
*/
31+
public function __construct(
32+
\Magento\Config\Model\ResourceModel\Config $resourceConfig
33+
) {
34+
parent::__construct();
35+
$this->_resourceConfig = $resourceConfig;
36+
}
37+
38+
/**
39+
* {@inheritdoc}
40+
*/
41+
protected function configure()
42+
{
43+
$this->setName(self::COMMAND_NAME)
44+
->setDescription('Disable frontend template hints. A cache flush might be required.');
45+
46+
parent::configure();
47+
}
48+
49+
/**
50+
* {@inheritdoc}
51+
* @throws \InvalidArgumentException
52+
*/
53+
protected function execute(InputInterface $input, OutputInterface $output)
54+
{
55+
$this->_resourceConfig->saveConfig(
56+
'dev/debug/template_hints_storefront',
57+
1,
58+
'default',
59+
0
60+
);
61+
62+
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");
63+
}
64+
}

app/code/Magento/Developer/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@
100100
<item name="dev_di_info" xsi:type="object">Magento\Developer\Console\Command\DiInfoCommand</item>
101101
<item name="dev_query_log_enable" xsi:type="object">Magento\Developer\Console\Command\QueryLogEnableCommand</item>
102102
<item name="dev_query_log_disable" xsi:type="object">Magento\Developer\Console\Command\QueryLogDisableCommand</item>
103+
<item name="dev_template_hints_disable" xsi:type="object">Magento\Developer\Console\Command\TemplateHintsDisableCommand</item>
104+
<item name="dev_template_hints_enable" xsi:type="object">Magento\Developer\Console\Command\TemplateHintsEnableCommand</item>
103105
</argument>
104106
</arguments>
105107
</type>

0 commit comments

Comments
 (0)