Skip to content

Commit 36b68cb

Browse files
committed
[FEATURE] AddConfiguration->getLocalHost method.
1 parent ff78d79 commit 36b68cb

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ master
66
~~~~~
77

88
a) [TASK][BREAKING] Rename getCurrentInstance to getLocalInstance
9+
b) [FEATURE] AddConfiguration->getLocalHost method.
910

1011

1112
2.0.0

src/Configuration.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,30 @@
44

55
use Deployer\Deployer;
66
use Deployer\Host\Host;
7+
use Deployer\Task\Context;
78

89
class Configuration
910
{
10-
public static function getHost($hostName) : Host
11+
public static function getHost($hostName): Host
1112
{
12-
if(isset(Deployer::get()->hosts[$hostName])) {
13+
if (isset(Deployer::get()->hosts[$hostName])) {
1314
return Deployer::get()->hosts[$hostName];
1415
} else {
1516
throw new \RuntimeException('Name of host "' . $hostName . '" is not on hosts list:' .
1617
implode(',', array_keys(Deployer::get()->hosts)) . "\n" . 'Please check case sensitive.',
1718
1500717628491);
1819
}
1920
}
21+
22+
public static function getLocalHost(): Host
23+
{
24+
$defaultStage = Context::get()->getConfig()->get('default_stage');
25+
if (isset(Deployer::get()->hosts[$defaultStage])) {
26+
return Deployer::get()->hosts[$defaultStage];
27+
} else {
28+
throw new \RuntimeException('Name of host "' . $defaultStage . '" is not on hosts list:' .
29+
implode(',', array_keys(Deployer::get()->hosts)) . "\n" . 'Please check case sensitive.',
30+
1500717628491);
31+
}
32+
}
2033
}

0 commit comments

Comments
 (0)