1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain; |
4
|
|
|
|
5
|
|
|
use DomainException; |
6
|
|
|
use EventEspresso\core\domain\values\FilePath; |
7
|
|
|
use EventEspresso\core\domain\values\Version; |
8
|
|
|
use InvalidArgumentException; |
9
|
|
|
|
10
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit('No direct access allowed'); |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* DomainBase Class |
15
|
|
|
* A container for all domain data related to the plugin |
16
|
|
|
* |
17
|
|
|
* @package EventEspresso\core\domain |
18
|
|
|
* @author Darren Ethier |
19
|
|
|
* @since 4.9.38 |
20
|
|
|
*/ |
21
|
|
|
abstract class DomainBase implements DomainInterface |
22
|
|
|
{ |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Equivalent to `__FILE__` for main plugin file. |
26
|
|
|
* |
27
|
|
|
* @var FilePath |
28
|
|
|
*/ |
29
|
|
|
private $plugin_file; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* String indicating version for plugin |
33
|
|
|
* |
34
|
|
|
* @var string |
35
|
|
|
*/ |
36
|
|
|
private $version; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @var string $plugin_basename |
40
|
|
|
*/ |
41
|
|
|
private $plugin_basename; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var string $plugin_path |
45
|
|
|
*/ |
46
|
|
|
private $plugin_path; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @var string $plugin_url |
50
|
|
|
*/ |
51
|
|
|
private $plugin_url; |
52
|
|
|
|
53
|
|
|
|
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Initializes internal properties. |
57
|
|
|
* |
58
|
|
|
* @param FilePath $plugin_file |
59
|
|
|
* @param Version $version |
60
|
|
|
* @throws InvalidArgumentException |
61
|
|
|
* @throws DomainException |
62
|
|
|
*/ |
63
|
|
|
public function __construct(FilePath $plugin_file, Version $version) |
64
|
|
|
{ |
65
|
|
|
$this->plugin_file = $plugin_file; |
66
|
|
|
$this->version = $version; |
67
|
|
|
$this->plugin_basename = plugin_basename($this->pluginFile()); |
68
|
|
|
$this->plugin_path = plugin_dir_path($this->pluginFile()); |
69
|
|
|
$this->plugin_url = plugin_dir_url($this->pluginFile()); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return string |
75
|
|
|
*/ |
76
|
|
|
public function pluginFile() |
77
|
|
|
{ |
78
|
|
|
return (string) $this->plugin_file; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
|
82
|
|
|
|
83
|
|
|
/** |
84
|
|
|
* @return string |
85
|
|
|
*/ |
86
|
|
|
public function pluginBasename() |
87
|
|
|
{ |
88
|
|
|
return $this->plugin_basename; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
|
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @return string |
95
|
|
|
*/ |
96
|
|
|
public function pluginPath() |
97
|
|
|
{ |
98
|
|
|
return $this->plugin_path; |
99
|
|
|
} |
100
|
|
|
|
101
|
|
|
|
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* @return string |
105
|
|
|
*/ |
106
|
|
|
public function pluginUrl() |
107
|
|
|
{ |
108
|
|
|
return $this->plugin_url; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
|
112
|
|
|
|
113
|
|
|
/** |
114
|
|
|
* @return string |
115
|
|
|
*/ |
116
|
|
|
public function version() |
117
|
|
|
{ |
118
|
|
|
return (string) $this->version; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* @return Version |
125
|
|
|
*/ |
126
|
|
|
public function versionValueObject() |
127
|
|
|
{ |
128
|
|
|
return $this->version; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
|
132
|
|
|
} |
133
|
|
|
|