Repository navigation
Expand file tree
/
Copy pathRemoteSymlinkHandler.php
More file actions
45 lines (39 loc) · 1.61 KB
/
Copy pathRemoteSymlinkHandler.php
File metadata and controls
45 lines (39 loc) · 1.61 KB
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
<?php
namespace DigipolisGent\Robo\Helpers\EventHandler\DefaultHandler;
use DigipolisGent\CommandBuilder\CommandBuilder;
use DigipolisGent\Robo\Helpers\Util\RemoteConfig;
use DigipolisGent\Robo\Task\Deploy\Ssh\Auth\KeyFile;
use Symfony\Component\EventDispatcher\GenericEvent;
class RemoteSymlinkHandler extends PreSymlinkHandler
{
use \DigipolisGent\Robo\Helpers\Traits\RemoteSwitchPreviousTrait;
/**
* {@inheritDoc}
*/
public function handle(GenericEvent $event)
{
/** @var RemoteConfig $remoteConfig */
$remoteConfig = $event->getArgument('remoteConfig');
$remoteSettings = $remoteConfig->getRemoteSettings();
$timeouts = $event->getArgument('timeouts');
$auth = new KeyFile($remoteConfig->getUser(), $remoteConfig->getPrivateKeyFile());
$collection = $this->collectionBuilder();
foreach ($remoteSettings['symlinks'] as $link) {
$preIndividualSymlinkTask = $this->preIndividualSymlinkTask($remoteConfig, $link, $timeouts['symlink']);
if ($preIndividualSymlinkTask) {
$collection->addTask($preIndividualSymlinkTask);
}
list($target, $linkname) = explode(':', $link);
$collection->taskSsh($remoteConfig->getHost(), $auth)
->exec(
(string) CommandBuilder::create('ln')
->addFlag('s')
->addFlag('T')
->addFlag('f')
->addArgument($target)
->addArgument($linkname)
);
}
return $collection;
}
}