8000 [WebProfilerBundle] deprecated import/export commands · ostrolucky/symfony@17e00b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 17e00b9

Browse files
committed
[WebProfilerBundle] deprecated import/export commands
1 parent 0edcc2e commit 17e00b9

File tree

5 files changed

+39
-4
lines changed

5 files changed

+39
-4
lines changed

UPGRADE-2.8.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,11 @@ DependencyInjection
325325
</services>
326326
```
327327

328-
Web Development Toolbar
329-
-----------------------
328+
WebProfiler
329+
-----------
330+
331+
The `profiler:import` and `profiler:export` commands have been deprecated and
332+
will be removed in 3.0.
330333

331334
The web development toolbar has been completely redesigned. This update has
332335
introduced some changes in the HTML markup of the toolbar items.

src/Symfony/Bundle/WebProfilerBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
2.8.0
5+
-----
6+
7+
* deprecated profiler:import and profiler:export commands
8+
49
2.7.0
510
-----
611

src/Symfony/Bundle/WebProfilerBundle/Command/ExportCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
/**
2121
* Exports a profile.
2222
*
23+
* @deprecated since version 2.8, to be removed in 3.0.
24+
*
2325
* @author Fabien Potencier <fabien@symfony.com>
2426
*/
2527
class ExportCommand extends Command
@@ -49,7 +51,7 @@ protected function configure()
4951
{
5052
$this
5153
->setName('profiler:export')
52-
->setDescription('Exports a profile')
54+
->setDescription('[DEPRECATED] Exports a profile')
5355
->setDefinition(array(
5456
new InputArgument('token', InputArgument::REQUIRED, 'The profile token'),
5557
))
@@ -64,6 +66,10 @@ protected function configure()
6466

6567
protected function execute(InputInterface $input, OutputInterface $output)
6668
{
69+
$formatter = $this->getHelper('formatter');
70+
71+
$output->writeln($formatter->formatSection('warning', 'The profiler:export command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));
72+
6773
$token = $input->getArgument('token');
6874

6975
if (!$profile = $this->profiler->loadProfile($token)) {

src/Symfony/Bundle/WebProfilerBundle/Command/ImportCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
/**
2121
* Imports a profile.
2222
*
23+
* @deprecated since version 2.8, to be removed in 3.0.
24+
*
2325
* @author Fabien Potencier <fabien@symfony.com>
2426
*/
2527
class ImportCommand extends Command
@@ -49,7 +51,7 @@ protected function configure()
4951
{
5052
$this
5153
->setName('profiler:import')
52-
->setDescription('Imports a profile')
54+
->setDescription('[DEPRECATED] Imports a profile')
5355
->setDefinition(array(
5456
new InputArgument('filename', InputArgument::OPTIONAL, 'The profile path'),
5557
))
@@ -68,6 +70,10 @@ protected function configure()
6870

6971
protected function execute(InputInterface $input, OutputInterface $output)
7072
{
73+
$formatter = $this->getHelper('formatter');
74+
75+
$output->writeln($formatter->formatSection('warning', 'The profiler:import command is deprecated since version 2.8 and will be removed in 3.0', 'comment'));
76+
7177
$data = '';
7278
if ($input->getArgument('filename')) {
7379
$data = file_get_contents($input->getArgument('filename'));

src/Symfony/Bundle/WebProfilerBundle/Tests/Command/ExportCommandTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Bundle\WebProfilerBundle\Tests\Command;
1313

1414
use Symfony\Bundle\WebProfilerBundle\Command\ExportCommand;
15+
use Symfony\Component\Console\Helper\HelperSet;
1516
use Symfony\Component\Console\Tester\CommandTester;
1617
use Symfony\Component\HttpKernel\Profiler\Profile;
1718

@@ -28,7 +29,14 @@ public function testExecuteWithUnknownToken()
2829
->getMock()
2930
;
3031

32+
$helperSet = new HelperSet();
33+
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
34+
$helper->expects($this->any())->method('formatSection');
35+
$helperSet->set($helper, 'formatter');
36+
3137
$command = new ExportCommand($profiler);
38+
$command->setHelperSet($helperSet);
39+
3240
$commandTester = new CommandTester($command);
3341
$commandTester->execute(array('token' => 'TOKEN'));
3442
}
@@ -44,7 +52,14 @@ public function testExecuteWithToken()
4452
$profile = new Profile('TOKEN');
4553
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));
4654

55+
$helperSet = new HelperSet();
56+
$helper = $this->getMock('Symfony\Component\Console\Helper\FormatterHelper');
57+
$helper->expects($this->any())->method('formatSection');
58+
$helperSet->set($helper, 'formatter');
59+
4760
$command = new ExportCommand($profiler);
61+
$command->setHelperSet($helperSet);
62+
4863
$commandTester = new CommandTester($command);
4964
$commandTester->execute(array('token' => 'TOKEN'));
5065
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());

0 commit comments

Comments
 (0)
0