|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the Setup package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) Sitewards GmbH |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Sitewards\Setup; |
|
10
|
|
|
|
|
11
|
|
|
use Symfony\Component\Console\Application as SymfonyApplication; |
|
12
|
|
|
use Symfony\Component\Filesystem\Filesystem; |
|
13
|
|
|
|
|
14
|
|
|
use Doctrine\Common\Annotations\AnnotationRegistry; |
|
15
|
|
|
use JMS\Serializer\SerializerBuilder; |
|
16
|
|
|
use JMS\Serializer\Serializer; |
|
17
|
|
|
|
|
18
|
|
|
use Sitewards\Setup\Application\BridgeInterface; |
|
19
|
|
|
use Sitewards\Setup\Command\Page\Export; |
|
20
|
|
|
use Sitewards\Setup\Service\Page\JsonFilesystemExporter; |
|
21
|
|
|
use Sitewards\Setup\Command\Page\Import; |
|
22
|
|
|
use Sitewards\Setup\Service\Page\JsonFilesystemImporter; |
|
23
|
|
|
|
|
24
|
|
|
class Application extends SymfonyApplication |
|
25
|
|
|
{ |
|
26
|
|
|
const APPLICATION_NAME = 'Sitewards Setup'; |
|
27
|
|
|
const APPLICATION_VERSION = '2.0.1'; |
|
28
|
|
|
|
|
29
|
|
|
/** @var BridgeInterface */ |
|
30
|
|
|
private $applicationBridge; |
|
31
|
|
|
|
|
32
|
|
|
/** @var Serializer */ |
|
33
|
|
|
private $serializer; |
|
34
|
|
|
|
|
35
|
|
|
public function __construct(BridgeInterface $applicationBridge) |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct(self::APPLICATION_NAME, self::APPLICATION_VERSION); |
|
38
|
|
|
$this->applicationBridge = $applicationBridge; |
|
39
|
|
|
$this->initSerializer(); |
|
40
|
|
|
$this->initCommands(); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
private function initSerializer() |
|
44
|
|
|
{ |
|
45
|
|
|
AnnotationRegistry::registerAutoloadNamespace( |
|
46
|
|
|
'JMS\Serializer\Annotation', |
|
47
|
|
|
'vendor/jms/serializer/src' |
|
48
|
|
|
); |
|
49
|
|
|
|
|
50
|
|
|
$this->serializer = SerializerBuilder::create()->build(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @throws \LogicException |
|
55
|
|
|
*/ |
|
56
|
|
|
private function initCommands() |
|
57
|
|
|
{ |
|
58
|
|
|
$exporter = new JsonFilesystemExporter( |
|
59
|
|
|
$this->applicationBridge->getPageRepository(), |
|
60
|
|
|
$this->serializer, |
|
61
|
|
|
new Filesystem() |
|
62
|
|
|
); |
|
63
|
|
|
|
|
64
|
|
|
$this->add( |
|
65
|
|
|
new Export($exporter) |
|
66
|
|
|
); |
|
67
|
|
|
|
|
68
|
|
|
$importer = new JsonFilesystemImporter( |
|
69
|
|
|
$this->applicationBridge->getPageRepository(), |
|
70
|
|
|
$this->serializer |
|
71
|
|
|
); |
|
72
|
|
|
|
|
73
|
|
|
$this->add( |
|
74
|
|
|
new Import($importer) |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|