forked from TYPO3/Surf
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ImportSiteTask.php
80 lines (73 loc) · 2.69 KB
/
ImportSiteTask.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace TYPO3\Surf\Task\Neos\Neos;
/* *
* This script belongs to the TYPO3 project "TYPO3 Surf" *
* *
* */
use TYPO3\Surf\Application\Neos\Flow;
use TYPO3\Surf\Domain\Model\Application;
use TYPO3\Surf\Domain\Model\Deployment;
use TYPO3\Surf\Domain\Model\Node;
use TYPO3\Surf\Domain\Model\Task;
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareInterface;
use TYPO3\Surf\Domain\Service\ShellCommandServiceAwareTrait;
use TYPO3\Surf\Exception\InvalidConfigurationException;
/**
* Task for importing content into Neos
*
*/
class ImportSiteTask extends Task implements ShellCommandServiceAwareInterface
{
use ShellCommandServiceAwareTrait;
/**
* Execute this task
*
* @param Node $node
* @param Application $application
* @param Deployment $deployment
* @param array $options
* @return void
* @throws InvalidConfigurationException
*/
public function execute(Node $node, Application $application, Deployment $deployment, array $options = array())
{
if (!$application instanceof Flow) {
throw new InvalidConfigurationException(sprintf('Flow application needed for ImportSiteTask, got "%s"', get_class($application)), 1358863473);
}
if (!isset($options['sitePackageKey'])) {
throw new InvalidConfigurationException(sprintf('"sitePackageKey" option not set for application "%s"', $application->getName()), 1312312646);
}
$targetPath = $deployment->getApplicationReleasePath($application);
$arguments = [
'--package-key',
$options['sitePackageKey']
];
$this->shell->executeOrSimulate($application->buildCommand($targetPath, 'site:import', $arguments), $node, $deployment);
}
/**
* Simulate this task
*
* @param Node $node
* @param Application $application
* @param Deployment $deployment
* @param array $options
* @return void
*/
public function simulate(Node $node, Application $application, Deployment $deployment, array $options = array())
{
$this->execute($node, $application, $deployment, $options);
}
/**
* Rollback the task
*
* @param Node $node
* @param Application $application
* @param Deployment $deployment
* @param array $options
* @return void
*/
public function rollback(Node $node, Application $application, Deployment $deployment, array $options = array())
{
// TODO Implement rollback
}
}