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
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Installation after schema update |
12
|
|
|
*/ |
13
|
|
|
class VersionCommand extends ContainerAwareCommand |
14
|
|
|
{ |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* {@inherited} |
18
|
|
|
*/ |
19
|
|
|
protected function configure() |
20
|
|
|
{ |
21
|
|
|
$this |
22
|
|
|
->setName('bundle:version') |
23
|
|
|
->setDescription('Informations about a bundle') |
24
|
|
|
->addArgument('name', InputArgument::REQUIRED) |
25
|
|
|
; |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inherited} |
30
|
|
|
*/ |
31
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
32
|
|
|
{ |
33
|
|
|
$name = $input->getArgument('name'); |
34
|
|
|
$bundleVersion = $this->getContainer()->get('versions.bundle')->getVersion($name); |
35
|
|
|
|
36
|
|
|
// informations |
37
|
|
|
$output->writeln('<comment>' . $name . '</comment> informations :'); |
38
|
|
|
|
39
|
|
|
// unversionned bundle |
40
|
|
|
if ($bundleVersion->isVersionned() === false) { |
41
|
|
|
$output->writeln('Bundle <error>not versionned</error>.'); |
42
|
|
|
$output->writeln('Unable to get informations, install, update or uninstall it.'); |
43
|
|
|
$output->writeln('To create a versionned bundle, see <info>README.md</info>'); |
44
|
|
|
|
45
|
|
|
// versionned bundle |
46
|
|
|
} else { |
47
|
|
|
$output->writeln('Files version : ' . $bundleVersion->getVersion()->asString()); |
48
|
|
|
if ($bundleVersion->getInstalledVersion() === null) { |
49
|
|
|
$output->writeln('Installed version : <error>not installed</error>'); |
50
|
|
|
} else { |
51
|
|
|
if ($bundleVersion->needUpdate()) { |
52
|
|
|
$output->writeln('Installed version : <error>' . $bundleVersion->getInstalledVersion()->asString() . '</error> (run php \'app/console bundle:update ' . $name . '\' to update to ' . $bundleVersion->getVersion()->asString() . ')'); |
53
|
|
|
} else { |
54
|
|
|
$output->writeln('Installed version : <info>' . $bundleVersion->getInstalledVersion()->asString() . '</info>'); |
55
|
|
|
} |
56
|
|
|
$output->writeln('Installation date : ' . $bundleVersion->getInstallationDate()->format('Y-m-d H:i:s')); |
57
|
|
|
$updateDate = ($bundleVersion->getUpdateDate() === null) ? 'none' : $bundleVersion->getInstallationDate()->format('Y-m-d H:i:s'); |
58
|
|
|
$output->writeln('Last update date : ' . $updateDate); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|