Skip to content

Commit 78b28de

Browse files
author
Oleksii Korshenko
authored
MAGETWO-69544: new CLI command: Enable Template Hints #9778
2 parents d568bfe + ba0e2bf commit 78b28de

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-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+
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
13+
14+
class TemplateHintsDisableCommand extends Command
15+
{
16+
/**
17+
* command name
18+
*/
19+
const COMMAND_NAME = 'dev:template-hints:disable';
20+
21+
/**
22+
* Success message
23+
*/
24+
const SUCCESS_MESSAGE = "Template hints disabled. Refresh cache types";
25+
26+
/**
27+
* @var ConfigInterface
28+
*/
29+
private $resourceConfig;
30+
31+
/**
32+
* Initialize dependencies.
33+
*
34+
* @param ConfigInterface $resourceConfig
35+
*/
36+
public function __construct(ConfigInterface $resourceConfig)
37+
{
38+
parent::__construct();
39+
$this->resourceConfig = $resourceConfig;
40+
}
41+
42+
/**
43+
* {@inheritdoc}
44+
*/
45+
protected function configure()
46+
{
47+
$this->setName(self::COMMAND_NAME)
48+
->setDescription('Disable frontend template hints. A cache flush might be required.');
49+
50+
parent::configure();
51+
}
52+
53+
/**
54+
* {@inheritdoc}
55+
* @throws \InvalidArgumentException
56+
*/
57+
protected function execute(InputInterface $input, OutputInterface $output)
58+
{
59+
$this->resourceConfig->saveConfig('dev/debug/template_hints_storefront', 0, 'default', 0);
60+
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");
61+
}
62+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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+
use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
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+
* @var ConfigInterface
29+
*/
30+
private $resourceConfig;
31+
32+
/**
33+
* Initialize dependencies.
34+
*
35+
* @param ConfigInterface $resourceConfig
36+
*/
37+
public function __construct(ConfigInterface $resourceConfig)
38+
{
39+
parent::__construct();
40+
$this->resourceConfig = $resourceConfig;
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
protected function configure()
47+
{
48+
$this->setName(self::COMMAND_NAME)
49+
->setDescription('Enable frontend template hints. A cache flush might be required.');
50+
51+
parent::configure();
52+
}
53+
54+
/**
55+
* {@inheritdoc}
56+
* @throws \InvalidArgumentException
57+
*/
58+
protected function execute(InputInterface $input, OutputInterface $output)
59+
{
60+
$this->resourceConfig->saveConfig('dev/debug/template_hints_storefront', 1, 'default', 0);
61+
$output->writeln("<info>". self::SUCCESS_MESSAGE . "</info>");
62+
}
63+
}

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)