1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the XabbuhPandaBundle package. |
5
|
|
|
* |
6
|
|
|
* (c) Christian Flothmann <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace Xabbuh\PandaBundle\Command; |
13
|
|
|
|
14
|
|
|
use Symfony\Component\Console\Helper\Table; |
15
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Command to display a list of videos. |
21
|
|
|
* |
22
|
|
|
* @author Christian Flothmann <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class ListVideosCommand extends CloudCommand |
25
|
|
|
{ |
26
|
|
|
protected static $defaultName = 'panda:video:list'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritDoc} |
30
|
|
|
*/ |
31
|
6 |
|
protected function configure() |
32
|
|
|
{ |
33
|
6 |
|
$this->setDescription('List all videos of a cloud'); |
34
|
6 |
|
$this->addOption( |
35
|
6 |
|
'page', |
36
|
6 |
|
null, |
37
|
6 |
|
InputOption::VALUE_REQUIRED, |
38
|
6 |
|
'Page to show', |
39
|
6 |
|
1 |
40
|
|
|
); |
41
|
6 |
|
$this->addOption( |
42
|
6 |
|
'per-page', |
43
|
6 |
|
null, |
44
|
6 |
|
InputOption::VALUE_REQUIRED, |
45
|
6 |
|
'Number of videos per page', |
46
|
6 |
|
10 |
47
|
|
|
); |
48
|
|
|
|
49
|
6 |
|
parent::configure(); |
50
|
6 |
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* {@inheritDoc} |
54
|
|
|
*/ |
55
|
5 |
|
protected function doExecuteCommand(InputInterface $input, OutputInterface $output) |
56
|
|
|
{ |
57
|
5 |
|
$result = $this->getCloud($input)->getVideosForPagination( |
58
|
5 |
|
$input->getOption('page'), |
59
|
5 |
|
$input->getOption('per-page') |
60
|
|
|
); |
61
|
|
|
|
62
|
4 |
|
if ($result->total > 0) { |
63
|
3 |
|
$output->writeln(sprintf( |
64
|
3 |
|
'Page %d of %d', |
65
|
3 |
|
$result->page, |
66
|
3 |
|
ceil($result->total / $result->per_page) |
67
|
|
|
)); |
68
|
|
|
} |
69
|
|
|
|
70
|
4 |
|
$output->writeln('Total number of videos: '.$result->total); |
71
|
|
|
|
72
|
4 |
|
if (count($result->videos) > 0) { |
73
|
3 |
|
$table = new Table($output); |
74
|
3 |
|
$table->setHeaders(array( |
75
|
3 |
|
'video id', |
76
|
|
|
'encoding status', |
77
|
|
|
'file name', |
78
|
|
|
)); |
79
|
|
|
|
80
|
3 |
|
foreach ($result->videos as $video) { |
81
|
3 |
|
if ($video->getStatus() == 'fail') { |
82
|
3 |
|
$status = sprintf( |
83
|
3 |
|
'fail (%s)', |
84
|
3 |
|
$video->getErrorMessage() |
85
|
|
|
); |
86
|
3 |
|
} elseif ($video->getStatus() == 'processing') { |
87
|
3 |
|
$status = 'processing'; |
88
|
|
|
} else { |
89
|
3 |
|
$status = 'success'; |
90
|
|
|
} |
91
|
|
|
|
92
|
3 |
|
$table->addRow(array( |
93
|
3 |
|
$video->getId(), |
94
|
3 |
|
$status, |
95
|
3 |
|
$video->getOriginalFilename(), |
96
|
|
|
)); |
97
|
|
|
} |
98
|
|
|
|
99
|
3 |
|
$table->render($output); |
|
|
|
|
100
|
|
|
} |
101
|
4 |
|
} |
102
|
|
|
} |
103
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.
In this case you can add the
@ignore
PhpDoc annotation to the duplicate definition and it will be ignored.