1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace SixtyEightPublishers\i18n\Profile; |
6
|
|
|
|
7
|
|
|
use Nette\SmartObject; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* @method void onLanguageChange(ActiveProfile $profile) |
11
|
|
|
* @method void onCountryChange(ActiveProfile $profile) |
12
|
|
|
* @method void onCurrencyChange(ActiveProfile $profile) |
13
|
|
|
*/ |
14
|
|
|
final class ActiveProfileChangeNotifier |
15
|
|
|
{ |
16
|
|
|
use SmartObject; |
17
|
|
|
|
18
|
|
|
/** @var NULL|callable[] */ |
19
|
|
|
public $onLanguageChange; |
20
|
|
|
|
21
|
|
|
/** @var NULL|callable[] */ |
22
|
|
|
public $onCountryChange; |
23
|
|
|
|
24
|
|
|
/** @var NULL|callable[] */ |
25
|
|
|
public $onCurrencyChange; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param callable $listener |
29
|
|
|
* |
30
|
|
|
* @return void |
31
|
|
|
*/ |
32
|
|
|
public function addOnLanguageChangeListener(callable $listener): void |
33
|
|
|
{ |
34
|
|
|
$this->onLanguageChange[] = $listener; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param callable $listener |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function addOnCountryChangeListener(callable $listener): void |
43
|
|
|
{ |
44
|
|
|
$this->onCountryChange[] = $listener; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param callable $listener |
49
|
|
|
* |
50
|
|
|
* @return void |
51
|
|
|
*/ |
52
|
|
|
public function addOnCurrencyChangeListener(callable $listener): void |
53
|
|
|
{ |
54
|
|
|
$this->onCurrencyChange[] = $listener; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @internal |
59
|
|
|
* @param \SixtyEightPublishers\i18n\Profile\ActiveProfile $profile |
60
|
|
|
* |
61
|
|
|
* @return void |
62
|
|
|
*/ |
63
|
|
|
public function notifyOnLanguageChange(ActiveProfile $profile): void |
64
|
|
|
{ |
65
|
|
|
$this->onLanguageChange($profile); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @internal |
70
|
|
|
* @param \SixtyEightPublishers\i18n\Profile\ActiveProfile $profile |
71
|
|
|
* |
72
|
|
|
* @return void |
73
|
|
|
*/ |
74
|
|
|
public function notifyOnCountryChange(ActiveProfile $profile): void |
75
|
|
|
{ |
76
|
|
|
$this->onCountryChange($profile); |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @internal |
81
|
|
|
* @param \SixtyEightPublishers\i18n\Profile\ActiveProfile $profile |
82
|
|
|
* |
83
|
|
|
* @return void |
84
|
|
|
*/ |
85
|
|
|
public function notifyOnCurrencyChange(ActiveProfile $profile): void |
86
|
|
|
{ |
87
|
|
|
$this->onCurrencyChange($profile); |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|