These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\DashboardBundle\Command; |
||
4 | |||
5 | use Kunstmaan\DashboardBundle\Manager\WidgetManager; |
||
6 | use Kunstmaan\DashboardBundle\Widget\DashboardWidget; |
||
7 | use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
||
8 | use Symfony\Component\Console\Input\InputInterface; |
||
9 | use Symfony\Component\Console\Output\OutputInterface; |
||
10 | |||
11 | /** |
||
12 | * Symfony CLI command to collect all the widget dashboard data using bin/console kuma:dashboard:collect |
||
13 | * |
||
14 | * @final since 5.1 |
||
15 | * NEXT_MAJOR extend from `Command` and remove `$this->getContainer` usages |
||
16 | */ |
||
17 | View Code Duplication | class DashboardCommand extends ContainerAwareCommand |
|
0 ignored issues
–
show
|
|||
18 | { |
||
19 | private $widgetManager; |
||
20 | |||
21 | public function __construct(WidgetManager $widgetManager = null) |
||
22 | { |
||
23 | parent::__construct(); |
||
24 | |||
25 | if (!$widgetManager instanceof WidgetManager) { |
||
26 | @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version symfony 3.4 and will be removed in symfony 4.0. If the command was registered by convention, make it a service instead. ', __METHOD__), E_USER_DEPRECATED); |
||
27 | |||
28 | $this->setName(null === $widgetManager ? 'kuma:dashboard:collect' : $widgetManager); |
||
29 | |||
30 | return; |
||
31 | } |
||
32 | |||
33 | $this->widgetManager = $widgetManager; |
||
34 | } |
||
35 | |||
36 | protected function configure() |
||
37 | { |
||
38 | $this |
||
39 | ->setName('kuma:dashboard:collect') |
||
40 | ->setDescription('Collect all the widget dashboard data'); |
||
41 | } |
||
42 | |||
43 | /** |
||
44 | * @return int|void|null |
||
45 | */ |
||
46 | protected function execute(InputInterface $input, OutputInterface $output) |
||
47 | { |
||
48 | if (null === $this->widgetManager) { |
||
49 | $this->widgetManager = $this->getContainer()->get('kunstmaan_dashboard.manager.widgets'); |
||
50 | } |
||
51 | |||
52 | /** @var DashboardWidget[] $widgets */ |
||
53 | $widgets = $this->widgetManager->getWidgets(); |
||
54 | foreach ($widgets as $widget) { |
||
55 | /* @var DashboardWidget $widget */ |
||
56 | $widget->getCommand()->execute($input, $output); |
||
57 | } |
||
58 | |||
59 | return 0; |
||
60 | } |
||
61 | } |
||
62 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.