Skip to content

Commit 8e24399

Browse files
committed
Add a PostProcessConfig class
1 parent d56179a commit 8e24399

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/PostProcessConfig.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace StaticDeploy;
4+
5+
final class PostProcessConfig {
6+
7+
public readonly ?string $destination_url;
8+
public readonly ?array $hosts_to_rewrite;
9+
public readonly ?string $site_url;
10+
11+
public function __construct() {
12+
if ( Options::getValue( 'skipURLRewrite' ) === '1' ) {
13+
$this->destination_url = null;
14+
$this->hosts_to_rewrite = null;
15+
$this->site_url = null;
16+
return;
17+
}
18+
19+
$this->destination_url = apply_filters(
20+
Controller::getHookName( 'set_destination_url' ),
21+
Options::getValue( 'deploymentURL' )
22+
);
23+
$this->hosts_to_rewrite = Options::getLineDelimitedBlobValue( 'hostsToRewrite' );
24+
$this->site_url = apply_filters(
25+
Controller::getHookName( 'set_wordpress_site_url' ),
26+
untrailingslashit( SiteInfo::getUrl( 'site' ) )
27+
);
28+
}
29+
30+
/**
31+
* @return array<string, ?string>
32+
*/
33+
public function toArray(): array
34+
{
35+
$arr = [];
36+
37+
if ( $this->destination_url ) {
38+
$arr['destination_url'] = $this->destination_url;
39+
}
40+
41+
if ( $this->hosts_to_rewrite ) {
42+
$arr['hosts_to_rewrite'] = $this->hosts_to_rewrite;
43+
}
44+
45+
if ( $this->site_url ) {
46+
$arr['site_url'] = $this->site_url;
47+
}
48+
49+
return $arr;
50+
}
51+
}

0 commit comments

Comments
 (0)