1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kujaff\VersionsBundle\Command; |
4
|
|
|
|
5
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand; |
6
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
7
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Installation after schema update |
11
|
|
|
*/ |
12
|
|
|
class ListCommand extends ContainerAwareCommand |
13
|
|
|
{ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* {@inherited} |
17
|
|
|
*/ |
18
|
|
|
protected function configure() |
19
|
|
|
{ |
20
|
|
|
$this |
21
|
|
|
->setName('bundle:list') |
22
|
|
|
->setDescription('List all versionned bundles') |
23
|
|
|
; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* {@inherited} |
28
|
|
|
*/ |
29
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
30
|
|
|
{ |
31
|
|
|
$output->writeln('<comment>Bundle</comment> <comment>Files</comment> <comment>Installed</comment> <comment>Installation</comment> <comment>Last update</comment>'); |
32
|
|
|
|
33
|
|
|
$bundles = $this->getContainer()->get('versions.bundle')->getBundles(); |
34
|
|
|
foreach ($bundles as $bundleVersion) { |
35
|
|
|
$name = sprintf('%-30s', $bundleVersion->getName()); |
36
|
|
|
$version = sprintf('%-10s', $bundleVersion->getVersion()->asString()); |
37
|
|
|
if ($bundleVersion->isInstalled()) { |
38
|
|
|
$installedVersion = sprintf('%-10s', $bundleVersion->getInstalledVersion()->asString()); |
39
|
|
|
if ($bundleVersion->needUpdate()) { |
40
|
|
|
$installedVersion = '<error>' . $installedVersion . '</error>'; |
41
|
|
|
} else { |
42
|
|
|
$installedVersion = '<info>' . $installedVersion . '</info>'; |
43
|
|
|
} |
44
|
|
|
$installationDate = $bundleVersion->getInstallationDate()->format('Y-m-d H:i:s'); |
45
|
|
|
$updateDate = ($bundleVersion->getUpdateDate() === null) ? null : $bundleVersion->getUpdateDate()->format('Y-m-d H:i:s'); |
46
|
|
|
} else { |
47
|
|
|
$installedVersion = '<error>' . sprintf('%-10s', 'none') . '</error> '; |
48
|
|
|
$installationDate = sprintf('%-19s', null); |
49
|
|
|
$updateDate = sprintf('%-19s', null); |
50
|
|
|
} |
51
|
|
|
$output->writeln($name . ' ' . $version . ' ' . $installedVersion . ' ' . $installationDate . ' ' . $updateDate); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|