AddressServiceFactory.php
1.36 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
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace ACA\WC\Editing\Order;
use ACA\WC\Editing;
use ACA\WC\Type\AddressType;
use ACP;
final class AddressServiceFactory
{
private $address_type;
public function __construct(AddressType $address_type)
{
$this->address_type = $address_type;
}
public function create(string $property): ?ACP\Editing\Service
{
switch ($property) {
case 'address_1':
case 'address_2':
case 'city':
case 'company':
case 'country':
case 'email':
case 'first_name':
case 'last_name':
case 'postcode':
case 'phone':
case 'state':
return new ACP\Editing\Service\Basic(
$this->create_view($property),
new Editing\Storage\Order\AddressField($this->address_type, $property)
);
case 'full_name':
default:
return null;
}
}
public function create_view(string $property): ACP\Editing\View
{
switch ($property) {
case 'country':
return new ACP\Editing\View\Select(WC()->countries->get_countries());
case 'email':
return new ACP\Editing\View\Email();
default:
return new ACP\Editing\View\Text();
}
}
}