@@ -5,95 +5,95 @@ |
||
5 | 5 | class LegacyModelApi |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @var string path to EE_* entity classes |
|
10 | - */ |
|
11 | - private $entity_classes; |
|
12 | - |
|
13 | - /** |
|
14 | - * @var string path to EEM_* entity model classes |
|
15 | - */ |
|
16 | - private $entity_models; |
|
17 | - |
|
18 | - /** |
|
19 | - * @var string path to EEE_* entity class extensions |
|
20 | - */ |
|
21 | - private $entity_class_extensions; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var string path to EEME_* entity model class extensions |
|
25 | - */ |
|
26 | - private $entity_model_extensions; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * @return string |
|
31 | - */ |
|
32 | - public function entityClasses(): string |
|
33 | - { |
|
34 | - return $this->entity_classes; |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - * @param string $entity_classes |
|
40 | - */ |
|
41 | - public function addEntityClasses(string $entity_classes): void |
|
42 | - { |
|
43 | - $this->entity_classes = $entity_classes; |
|
44 | - } |
|
45 | - |
|
46 | - |
|
47 | - /** |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function entityModels(): string |
|
51 | - { |
|
52 | - return $this->entity_models; |
|
53 | - } |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * @param string $entity_models |
|
58 | - */ |
|
59 | - public function addEntityModels(string $entity_models): void |
|
60 | - { |
|
61 | - $this->entity_models = $entity_models; |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - /** |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function entityClassExtensions(): string |
|
69 | - { |
|
70 | - return $this->entity_class_extensions; |
|
71 | - } |
|
72 | - |
|
73 | - |
|
74 | - /** |
|
75 | - * @param string $entity_class_extensions |
|
76 | - */ |
|
77 | - public function addEntityClassExtensions(string $entity_class_extensions): void |
|
78 | - { |
|
79 | - $this->entity_class_extensions = $entity_class_extensions; |
|
80 | - } |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @return string |
|
85 | - */ |
|
86 | - public function entityModelExtensions(): string |
|
87 | - { |
|
88 | - return $this->entity_model_extensions; |
|
89 | - } |
|
90 | - |
|
91 | - |
|
92 | - /** |
|
93 | - * @param string $entity_model_extensions |
|
94 | - */ |
|
95 | - public function addEntityModelExtensions(string $entity_model_extensions): void |
|
96 | - { |
|
97 | - $this->entity_model_extensions = $entity_model_extensions; |
|
98 | - } |
|
8 | + /** |
|
9 | + * @var string path to EE_* entity classes |
|
10 | + */ |
|
11 | + private $entity_classes; |
|
12 | + |
|
13 | + /** |
|
14 | + * @var string path to EEM_* entity model classes |
|
15 | + */ |
|
16 | + private $entity_models; |
|
17 | + |
|
18 | + /** |
|
19 | + * @var string path to EEE_* entity class extensions |
|
20 | + */ |
|
21 | + private $entity_class_extensions; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var string path to EEME_* entity model class extensions |
|
25 | + */ |
|
26 | + private $entity_model_extensions; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * @return string |
|
31 | + */ |
|
32 | + public function entityClasses(): string |
|
33 | + { |
|
34 | + return $this->entity_classes; |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + * @param string $entity_classes |
|
40 | + */ |
|
41 | + public function addEntityClasses(string $entity_classes): void |
|
42 | + { |
|
43 | + $this->entity_classes = $entity_classes; |
|
44 | + } |
|
45 | + |
|
46 | + |
|
47 | + /** |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function entityModels(): string |
|
51 | + { |
|
52 | + return $this->entity_models; |
|
53 | + } |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * @param string $entity_models |
|
58 | + */ |
|
59 | + public function addEntityModels(string $entity_models): void |
|
60 | + { |
|
61 | + $this->entity_models = $entity_models; |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + /** |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function entityClassExtensions(): string |
|
69 | + { |
|
70 | + return $this->entity_class_extensions; |
|
71 | + } |
|
72 | + |
|
73 | + |
|
74 | + /** |
|
75 | + * @param string $entity_class_extensions |
|
76 | + */ |
|
77 | + public function addEntityClassExtensions(string $entity_class_extensions): void |
|
78 | + { |
|
79 | + $this->entity_class_extensions = $entity_class_extensions; |
|
80 | + } |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @return string |
|
85 | + */ |
|
86 | + public function entityModelExtensions(): string |
|
87 | + { |
|
88 | + return $this->entity_model_extensions; |
|
89 | + } |
|
90 | + |
|
91 | + |
|
92 | + /** |
|
93 | + * @param string $entity_model_extensions |
|
94 | + */ |
|
95 | + public function addEntityModelExtensions(string $entity_model_extensions): void |
|
96 | + { |
|
97 | + $this->entity_model_extensions = $entity_model_extensions; |
|
98 | + } |
|
99 | 99 | } |
@@ -8,26 +8,26 @@ |
||
8 | 8 | |
9 | 9 | class RegisterAddon |
10 | 10 | { |
11 | - /** |
|
12 | - * @param AddonApiV1 $addon |
|
13 | - * @throws EE_Error |
|
14 | - */ |
|
15 | - public function register(AddonApiV1 $addon) |
|
16 | - { |
|
17 | - EE_Register_Addon::register( |
|
18 | - $addon->fqcn(), |
|
19 | - [ |
|
20 | - 'version' => $addon->version(), |
|
21 | - 'plugin_slug' => $addon->slug(), |
|
22 | - 'min_core_version' => $addon->minCoreVersion(), |
|
23 | - 'min_wp_version' => $addon->minWpVersion(), |
|
24 | - 'main_file_path' => $addon->mainFile(), |
|
25 | - 'dms_paths' => [$addon->dataMigrationScripts()], |
|
26 | - 'class_paths' => [$addon->entityClasses()], |
|
27 | - 'model_paths' => [$addon->entityModels()], |
|
28 | - 'class_extension_paths' => [$addon->entityClassExtensions()], |
|
29 | - 'model_extension_paths' => [$addon->entityModelExtensions()], |
|
30 | - ] |
|
31 | - ); |
|
32 | - } |
|
11 | + /** |
|
12 | + * @param AddonApiV1 $addon |
|
13 | + * @throws EE_Error |
|
14 | + */ |
|
15 | + public function register(AddonApiV1 $addon) |
|
16 | + { |
|
17 | + EE_Register_Addon::register( |
|
18 | + $addon->fqcn(), |
|
19 | + [ |
|
20 | + 'version' => $addon->version(), |
|
21 | + 'plugin_slug' => $addon->slug(), |
|
22 | + 'min_core_version' => $addon->minCoreVersion(), |
|
23 | + 'min_wp_version' => $addon->minWpVersion(), |
|
24 | + 'main_file_path' => $addon->mainFile(), |
|
25 | + 'dms_paths' => [$addon->dataMigrationScripts()], |
|
26 | + 'class_paths' => [$addon->entityClasses()], |
|
27 | + 'model_paths' => [$addon->entityModels()], |
|
28 | + 'class_extension_paths' => [$addon->entityClassExtensions()], |
|
29 | + 'model_extension_paths' => [$addon->entityModelExtensions()], |
|
30 | + ] |
|
31 | + ); |
|
32 | + } |
|
33 | 33 | } |
@@ -7,135 +7,135 @@ |
||
7 | 7 | class AddonApi extends AddonApiVersion |
8 | 8 | { |
9 | 9 | |
10 | - /** |
|
11 | - * @var DataMigrationApi |
|
12 | - */ |
|
13 | - private $data_migration_api; |
|
14 | - |
|
15 | - /** |
|
16 | - * @var LegacyModelApi |
|
17 | - */ |
|
18 | - private $legacy_model_api; |
|
19 | - |
|
20 | - |
|
21 | - /** |
|
22 | - * Bootstrap constructor. |
|
23 | - * |
|
24 | - * @param string $slug |
|
25 | - * @param string $name |
|
26 | - * @param string $namespace |
|
27 | - * @param string $version |
|
28 | - * @param string $min_core_version |
|
29 | - * @param string $main_file |
|
30 | - */ |
|
31 | - public function __construct( |
|
32 | - string $slug, |
|
33 | - string $name, |
|
34 | - string $namespace, |
|
35 | - string $version, |
|
36 | - string $min_core_version, |
|
37 | - string $main_file |
|
38 | - ) { |
|
39 | - parent::__construct( |
|
40 | - $slug, |
|
41 | - $name, |
|
42 | - $namespace, |
|
43 | - $version, |
|
44 | - $min_core_version, |
|
45 | - $main_file, |
|
46 | - AddonApiVersion::V1 |
|
47 | - ); |
|
48 | - $this->legacy_model_api = new LegacyModelApi(); |
|
49 | - $this->data_migration_api = new DataMigrationApi(); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @return string |
|
55 | - */ |
|
56 | - public function dataMigrationScripts(): string |
|
57 | - { |
|
58 | - return $this->data_migration_api->dataMigrationScripts(); |
|
59 | - } |
|
60 | - |
|
61 | - |
|
62 | - /** |
|
63 | - * @param string $data_migration_scripts |
|
64 | - */ |
|
65 | - public function addDataMigrationScripts(string $data_migration_scripts): void |
|
66 | - { |
|
67 | - $this->data_migration_api->addDataMigrationScripts($data_migration_scripts); |
|
68 | - } |
|
69 | - |
|
70 | - |
|
71 | - /** |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function entityClasses(): string |
|
75 | - { |
|
76 | - return $this->legacy_model_api->entityClasses(); |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - /** |
|
81 | - * @param string $entity_classes |
|
82 | - */ |
|
83 | - public function addEntityClasses(string $entity_classes): void |
|
84 | - { |
|
85 | - $this->legacy_model_api->addEntityClasses($entity_classes); |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - /** |
|
90 | - * @return string |
|
91 | - */ |
|
92 | - public function entityModels(): string |
|
93 | - { |
|
94 | - return $this->legacy_model_api->entityModels(); |
|
95 | - } |
|
96 | - |
|
97 | - |
|
98 | - /** |
|
99 | - * @param string $entity_models |
|
100 | - */ |
|
101 | - public function addEntityModels(string $entity_models): void |
|
102 | - { |
|
103 | - $this->legacy_model_api->addEntityModels($entity_models); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function entityClassExtensions(): string |
|
111 | - { |
|
112 | - return $this->legacy_model_api->entityClassExtensions(); |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - /** |
|
117 | - * @param string $entity_class_extensions |
|
118 | - */ |
|
119 | - public function addEntityClassExtensions(string $entity_class_extensions): void |
|
120 | - { |
|
121 | - $this->legacy_model_api->addEntityClassExtensions($entity_class_extensions); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return string |
|
127 | - */ |
|
128 | - public function entityModelExtensions(): string |
|
129 | - { |
|
130 | - return $this->legacy_model_api->entityModelExtensions(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @param string $entity_model_extensions |
|
136 | - */ |
|
137 | - public function addEntityModelExtensions(string $entity_model_extensions): void |
|
138 | - { |
|
139 | - $this->legacy_model_api->addEntityModelExtensions($entity_model_extensions); |
|
140 | - } |
|
10 | + /** |
|
11 | + * @var DataMigrationApi |
|
12 | + */ |
|
13 | + private $data_migration_api; |
|
14 | + |
|
15 | + /** |
|
16 | + * @var LegacyModelApi |
|
17 | + */ |
|
18 | + private $legacy_model_api; |
|
19 | + |
|
20 | + |
|
21 | + /** |
|
22 | + * Bootstrap constructor. |
|
23 | + * |
|
24 | + * @param string $slug |
|
25 | + * @param string $name |
|
26 | + * @param string $namespace |
|
27 | + * @param string $version |
|
28 | + * @param string $min_core_version |
|
29 | + * @param string $main_file |
|
30 | + */ |
|
31 | + public function __construct( |
|
32 | + string $slug, |
|
33 | + string $name, |
|
34 | + string $namespace, |
|
35 | + string $version, |
|
36 | + string $min_core_version, |
|
37 | + string $main_file |
|
38 | + ) { |
|
39 | + parent::__construct( |
|
40 | + $slug, |
|
41 | + $name, |
|
42 | + $namespace, |
|
43 | + $version, |
|
44 | + $min_core_version, |
|
45 | + $main_file, |
|
46 | + AddonApiVersion::V1 |
|
47 | + ); |
|
48 | + $this->legacy_model_api = new LegacyModelApi(); |
|
49 | + $this->data_migration_api = new DataMigrationApi(); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @return string |
|
55 | + */ |
|
56 | + public function dataMigrationScripts(): string |
|
57 | + { |
|
58 | + return $this->data_migration_api->dataMigrationScripts(); |
|
59 | + } |
|
60 | + |
|
61 | + |
|
62 | + /** |
|
63 | + * @param string $data_migration_scripts |
|
64 | + */ |
|
65 | + public function addDataMigrationScripts(string $data_migration_scripts): void |
|
66 | + { |
|
67 | + $this->data_migration_api->addDataMigrationScripts($data_migration_scripts); |
|
68 | + } |
|
69 | + |
|
70 | + |
|
71 | + /** |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function entityClasses(): string |
|
75 | + { |
|
76 | + return $this->legacy_model_api->entityClasses(); |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + /** |
|
81 | + * @param string $entity_classes |
|
82 | + */ |
|
83 | + public function addEntityClasses(string $entity_classes): void |
|
84 | + { |
|
85 | + $this->legacy_model_api->addEntityClasses($entity_classes); |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + /** |
|
90 | + * @return string |
|
91 | + */ |
|
92 | + public function entityModels(): string |
|
93 | + { |
|
94 | + return $this->legacy_model_api->entityModels(); |
|
95 | + } |
|
96 | + |
|
97 | + |
|
98 | + /** |
|
99 | + * @param string $entity_models |
|
100 | + */ |
|
101 | + public function addEntityModels(string $entity_models): void |
|
102 | + { |
|
103 | + $this->legacy_model_api->addEntityModels($entity_models); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function entityClassExtensions(): string |
|
111 | + { |
|
112 | + return $this->legacy_model_api->entityClassExtensions(); |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + /** |
|
117 | + * @param string $entity_class_extensions |
|
118 | + */ |
|
119 | + public function addEntityClassExtensions(string $entity_class_extensions): void |
|
120 | + { |
|
121 | + $this->legacy_model_api->addEntityClassExtensions($entity_class_extensions); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return string |
|
127 | + */ |
|
128 | + public function entityModelExtensions(): string |
|
129 | + { |
|
130 | + return $this->legacy_model_api->entityModelExtensions(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @param string $entity_model_extensions |
|
136 | + */ |
|
137 | + public function addEntityModelExtensions(string $entity_model_extensions): void |
|
138 | + { |
|
139 | + $this->legacy_model_api->addEntityModelExtensions($entity_model_extensions); |
|
140 | + } |
|
141 | 141 | } |
@@ -5,26 +5,26 @@ |
||
5 | 5 | class DataMigrationApi |
6 | 6 | { |
7 | 7 | |
8 | - /** |
|
9 | - * @var string path to DMS folder |
|
10 | - */ |
|
11 | - private $data_migration_scripts; |
|
8 | + /** |
|
9 | + * @var string path to DMS folder |
|
10 | + */ |
|
11 | + private $data_migration_scripts; |
|
12 | 12 | |
13 | 13 | |
14 | - /** |
|
15 | - * @return string |
|
16 | - */ |
|
17 | - public function dataMigrationScripts(): string |
|
18 | - { |
|
19 | - return $this->data_migration_scripts; |
|
20 | - } |
|
14 | + /** |
|
15 | + * @return string |
|
16 | + */ |
|
17 | + public function dataMigrationScripts(): string |
|
18 | + { |
|
19 | + return $this->data_migration_scripts; |
|
20 | + } |
|
21 | 21 | |
22 | 22 | |
23 | - /** |
|
24 | - * @param string $data_migration_scripts |
|
25 | - */ |
|
26 | - public function addDataMigrationScripts(string $data_migration_scripts): void |
|
27 | - { |
|
28 | - $this->data_migration_scripts = $data_migration_scripts; |
|
29 | - } |
|
23 | + /** |
|
24 | + * @param string $data_migration_scripts |
|
25 | + */ |
|
26 | + public function addDataMigrationScripts(string $data_migration_scripts): void |
|
27 | + { |
|
28 | + $this->data_migration_scripts = $data_migration_scripts; |
|
29 | + } |
|
30 | 30 | } |
@@ -31,14 +31,14 @@ |
||
31 | 31 | */ |
32 | 32 | public function __construct(string $file_path) |
33 | 33 | { |
34 | - if (! is_string($file_path)) { |
|
34 | + if ( ! is_string($file_path)) { |
|
35 | 35 | throw new InvalidDataTypeException( |
36 | 36 | '$file_path', |
37 | 37 | $file_path, |
38 | 38 | 'string' |
39 | 39 | ); |
40 | 40 | } |
41 | - if (! is_readable($file_path)) { |
|
41 | + if ( ! is_readable($file_path)) { |
|
42 | 42 | throw new InvalidFilePathException($file_path); |
43 | 43 | } |
44 | 44 | $this->file_path = $file_path; |
@@ -15,40 +15,40 @@ |
||
15 | 15 | */ |
16 | 16 | class FilePath |
17 | 17 | { |
18 | - /** |
|
19 | - * @var string file_path |
|
20 | - */ |
|
21 | - private $file_path; |
|
18 | + /** |
|
19 | + * @var string file_path |
|
20 | + */ |
|
21 | + private $file_path; |
|
22 | 22 | |
23 | 23 | |
24 | - /** |
|
25 | - * FilePath constructor. |
|
26 | - * |
|
27 | - * @param string $file_path |
|
28 | - * @throws InvalidDataTypeException |
|
29 | - * @throws InvalidFilePathException |
|
30 | - */ |
|
31 | - public function __construct(string $file_path) |
|
32 | - { |
|
33 | - if (! is_string($file_path)) { |
|
34 | - throw new InvalidDataTypeException( |
|
35 | - '$file_path', |
|
36 | - $file_path, |
|
37 | - 'string' |
|
38 | - ); |
|
39 | - } |
|
40 | - if (! is_readable($file_path)) { |
|
41 | - throw new InvalidFilePathException($file_path); |
|
42 | - } |
|
43 | - $this->file_path = $file_path; |
|
44 | - } |
|
24 | + /** |
|
25 | + * FilePath constructor. |
|
26 | + * |
|
27 | + * @param string $file_path |
|
28 | + * @throws InvalidDataTypeException |
|
29 | + * @throws InvalidFilePathException |
|
30 | + */ |
|
31 | + public function __construct(string $file_path) |
|
32 | + { |
|
33 | + if (! is_string($file_path)) { |
|
34 | + throw new InvalidDataTypeException( |
|
35 | + '$file_path', |
|
36 | + $file_path, |
|
37 | + 'string' |
|
38 | + ); |
|
39 | + } |
|
40 | + if (! is_readable($file_path)) { |
|
41 | + throw new InvalidFilePathException($file_path); |
|
42 | + } |
|
43 | + $this->file_path = $file_path; |
|
44 | + } |
|
45 | 45 | |
46 | 46 | |
47 | - /** |
|
48 | - * @return string |
|
49 | - */ |
|
50 | - public function __toString(): string |
|
51 | - { |
|
52 | - return $this->file_path; |
|
53 | - } |
|
47 | + /** |
|
48 | + * @return string |
|
49 | + */ |
|
50 | + public function __toString(): string |
|
51 | + { |
|
52 | + return $this->file_path; |
|
53 | + } |
|
54 | 54 | } |
@@ -33,14 +33,14 @@ |
||
33 | 33 | */ |
34 | 34 | public function __construct(string $fully_qualified_name) |
35 | 35 | { |
36 | - if (! is_string($fully_qualified_name)) { |
|
36 | + if ( ! is_string($fully_qualified_name)) { |
|
37 | 37 | throw new InvalidDataTypeException( |
38 | 38 | '$fully_qualified_name', |
39 | 39 | $fully_qualified_name, |
40 | 40 | 'string' |
41 | 41 | ); |
42 | 42 | } |
43 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
44 | 44 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
45 | 45 | throw new InvalidInterfaceException($fully_qualified_name); |
46 | 46 | } |
@@ -16,53 +16,53 @@ |
||
16 | 16 | */ |
17 | 17 | class FullyQualifiedName |
18 | 18 | { |
19 | - /** |
|
20 | - * @var string $fully_qualified_name |
|
21 | - */ |
|
22 | - private $fully_qualified_name; |
|
19 | + /** |
|
20 | + * @var string $fully_qualified_name |
|
21 | + */ |
|
22 | + private $fully_qualified_name; |
|
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * FullyQualifiedName constructor. |
|
27 | - * |
|
28 | - * @param string $fully_qualified_name |
|
29 | - * @throws InvalidClassException |
|
30 | - * @throws InvalidInterfaceException |
|
31 | - * @throws InvalidDataTypeException |
|
32 | - */ |
|
33 | - public function __construct(string $fully_qualified_name) |
|
34 | - { |
|
35 | - if (! is_string($fully_qualified_name)) { |
|
36 | - throw new InvalidDataTypeException( |
|
37 | - '$fully_qualified_name', |
|
38 | - $fully_qualified_name, |
|
39 | - 'string' |
|
40 | - ); |
|
41 | - } |
|
42 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | - } |
|
46 | - throw new InvalidClassException($fully_qualified_name); |
|
47 | - } |
|
48 | - $this->fully_qualified_name = $fully_qualified_name; |
|
49 | - } |
|
25 | + /** |
|
26 | + * FullyQualifiedName constructor. |
|
27 | + * |
|
28 | + * @param string $fully_qualified_name |
|
29 | + * @throws InvalidClassException |
|
30 | + * @throws InvalidInterfaceException |
|
31 | + * @throws InvalidDataTypeException |
|
32 | + */ |
|
33 | + public function __construct(string $fully_qualified_name) |
|
34 | + { |
|
35 | + if (! is_string($fully_qualified_name)) { |
|
36 | + throw new InvalidDataTypeException( |
|
37 | + '$fully_qualified_name', |
|
38 | + $fully_qualified_name, |
|
39 | + 'string' |
|
40 | + ); |
|
41 | + } |
|
42 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
43 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
44 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
45 | + } |
|
46 | + throw new InvalidClassException($fully_qualified_name); |
|
47 | + } |
|
48 | + $this->fully_qualified_name = $fully_qualified_name; |
|
49 | + } |
|
50 | 50 | |
51 | 51 | |
52 | - /** |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function string(): string |
|
56 | - { |
|
57 | - return $this->fully_qualified_name; |
|
58 | - } |
|
52 | + /** |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function string(): string |
|
56 | + { |
|
57 | + return $this->fully_qualified_name; |
|
58 | + } |
|
59 | 59 | |
60 | 60 | |
61 | - /** |
|
62 | - * @return string |
|
63 | - */ |
|
64 | - public function __toString(): string |
|
65 | - { |
|
66 | - return $this->fully_qualified_name; |
|
67 | - } |
|
61 | + /** |
|
62 | + * @return string |
|
63 | + */ |
|
64 | + public function __toString(): string |
|
65 | + { |
|
66 | + return $this->fully_qualified_name; |
|
67 | + } |
|
68 | 68 | } |
@@ -22,101 +22,101 @@ |
||
22 | 22 | */ |
23 | 23 | class DomainFactory |
24 | 24 | { |
25 | - /** |
|
26 | - * @var DomainInterface[] |
|
27 | - */ |
|
28 | - protected static $domains = []; |
|
25 | + /** |
|
26 | + * @var DomainInterface[] |
|
27 | + */ |
|
28 | + protected static $domains = []; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | - * @param string $main_file [required] path to the main plugin file |
|
34 | - * @param string $version [required] version string for the plugin |
|
35 | - * @return DomainInterface |
|
36 | - * @throws DomainException |
|
37 | - * @throws InvalidArgumentException |
|
38 | - * @throws InvalidDataTypeException |
|
39 | - * @throws InvalidInterfaceException |
|
40 | - */ |
|
41 | - public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | - { |
|
43 | - $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | - return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | - } |
|
31 | + /** |
|
32 | + * @param string $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
33 | + * @param string $main_file [required] path to the main plugin file |
|
34 | + * @param string $version [required] version string for the plugin |
|
35 | + * @return DomainInterface |
|
36 | + * @throws DomainException |
|
37 | + * @throws InvalidArgumentException |
|
38 | + * @throws InvalidDataTypeException |
|
39 | + * @throws InvalidInterfaceException |
|
40 | + */ |
|
41 | + public static function create(string $domain_fqcn, string $main_file, string $version): DomainInterface |
|
42 | + { |
|
43 | + $fqcn = new FullyQualifiedName($domain_fqcn); |
|
44 | + return DomainFactory::getDomain($fqcn->string(), [$main_file, $version]); |
|
45 | + } |
|
46 | 46 | |
47 | 47 | |
48 | - /** |
|
49 | - * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | - * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | - * constructor. Must at least include the following two value objects: |
|
52 | - * [ |
|
53 | - * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | - * EventEspresso\core\domain\values\Version $version |
|
55 | - * ] |
|
56 | - * @return DomainInterface |
|
57 | - * @throws DomainException |
|
58 | - * @throws InvalidArgumentException |
|
59 | - * @throws InvalidDataTypeException |
|
60 | - * @throws InvalidInterfaceException |
|
61 | - */ |
|
62 | - public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | - { |
|
64 | - return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | - } |
|
48 | + /** |
|
49 | + * @param FullyQualifiedName $domain_fqcn [required] Fully Qualified Class Name for the Domain class |
|
50 | + * @param array $arguments [required] array of arguments to be passed to the Domain class |
|
51 | + * constructor. Must at least include the following two value objects: |
|
52 | + * [ |
|
53 | + * EventEspresso\core\domain\values\FilePath $plugin_file |
|
54 | + * EventEspresso\core\domain\values\Version $version |
|
55 | + * ] |
|
56 | + * @return DomainInterface |
|
57 | + * @throws DomainException |
|
58 | + * @throws InvalidArgumentException |
|
59 | + * @throws InvalidDataTypeException |
|
60 | + * @throws InvalidInterfaceException |
|
61 | + */ |
|
62 | + public static function getShared(FullyQualifiedName $domain_fqcn, array $arguments): DomainInterface |
|
63 | + { |
|
64 | + return DomainFactory::getDomain($domain_fqcn->string(), $arguments); |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return DomainInterface |
|
70 | - * @throws DomainException |
|
71 | - * @throws InvalidArgumentException |
|
72 | - * @throws InvalidDataTypeException |
|
73 | - * @throws InvalidFilePathException |
|
74 | - * @throws InvalidInterfaceException |
|
75 | - */ |
|
76 | - public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | - { |
|
78 | - $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | - DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | - } |
|
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
83 | - } |
|
68 | + /** |
|
69 | + * @return DomainInterface |
|
70 | + * @throws DomainException |
|
71 | + * @throws InvalidArgumentException |
|
72 | + * @throws InvalidDataTypeException |
|
73 | + * @throws InvalidFilePathException |
|
74 | + * @throws InvalidInterfaceException |
|
75 | + */ |
|
76 | + public static function getEventEspressoCoreDomain(): DomainInterface |
|
77 | + { |
|
78 | + $fqcn = 'EventEspresso\core\domain\Domain'; |
|
79 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
80 | + DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
|
81 | + } |
|
82 | + return DomainFactory::$domains[ $fqcn ]; |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param string $fqcn |
|
88 | - * @param array $arguments |
|
89 | - * @return DomainInterface |
|
90 | - */ |
|
91 | - private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | - { |
|
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
95 | - throw new InvalidArgumentException( |
|
96 | - esc_html__( |
|
97 | - 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | - 'event_espresso' |
|
99 | - ) |
|
100 | - ); |
|
101 | - } |
|
102 | - $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | - $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | - $domain = new $fqcn($filepath, $version); |
|
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | - throw new DomainException( |
|
107 | - sprintf( |
|
108 | - esc_html__( |
|
109 | - 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | - 'event_espresso' |
|
111 | - ), |
|
112 | - $fqcn |
|
113 | - ) |
|
114 | - ); |
|
115 | - } |
|
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | - // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | - LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | - } |
|
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
121 | - } |
|
86 | + /** |
|
87 | + * @param string $fqcn |
|
88 | + * @param array $arguments |
|
89 | + * @return DomainInterface |
|
90 | + */ |
|
91 | + private static function getDomain(string $fqcn, array $arguments): DomainInterface |
|
92 | + { |
|
93 | + if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | + if (! isset($arguments[0], $arguments[1])) { |
|
95 | + throw new InvalidArgumentException( |
|
96 | + esc_html__( |
|
97 | + 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
|
98 | + 'event_espresso' |
|
99 | + ) |
|
100 | + ); |
|
101 | + } |
|
102 | + $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
|
103 | + $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
|
104 | + $domain = new $fqcn($filepath, $version); |
|
105 | + if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | + throw new DomainException( |
|
107 | + sprintf( |
|
108 | + esc_html__( |
|
109 | + 'The requested Domain class "%1$s" could not be loaded.', |
|
110 | + 'event_espresso' |
|
111 | + ), |
|
112 | + $fqcn |
|
113 | + ) |
|
114 | + ); |
|
115 | + } |
|
116 | + DomainFactory::$domains[ $fqcn ] = $domain; |
|
117 | + // we still need to share this with the core loader to facilitate automatic dependency injection |
|
118 | + LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
|
119 | + } |
|
120 | + return DomainFactory::$domains[ $fqcn ]; |
|
121 | + } |
|
122 | 122 | } |
@@ -76,10 +76,10 @@ discard block |
||
76 | 76 | public static function getEventEspressoCoreDomain(): DomainInterface |
77 | 77 | { |
78 | 78 | $fqcn = 'EventEspresso\core\domain\Domain'; |
79 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
79 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
80 | 80 | DomainFactory::getDomain($fqcn, [EVENT_ESPRESSO_MAIN_FILE, espresso_version()]); |
81 | 81 | } |
82 | - return DomainFactory::$domains[ $fqcn ]; |
|
82 | + return DomainFactory::$domains[$fqcn]; |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | */ |
91 | 91 | private static function getDomain(string $fqcn, array $arguments): DomainInterface |
92 | 92 | { |
93 | - if (! isset(DomainFactory::$domains[ $fqcn ])) { |
|
94 | - if (! isset($arguments[0], $arguments[1])) { |
|
93 | + if ( ! isset(DomainFactory::$domains[$fqcn])) { |
|
94 | + if ( ! isset($arguments[0], $arguments[1])) { |
|
95 | 95 | throw new InvalidArgumentException( |
96 | 96 | esc_html__( |
97 | 97 | 'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | $filepath = $arguments[0] instanceof FilePath ? $arguments[0] : new FilePath($arguments[0]); |
103 | 103 | $version = $arguments[1] instanceof Version ? $arguments[1] : Version::fromString($arguments[1]); |
104 | 104 | $domain = new $fqcn($filepath, $version); |
105 | - if (! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
105 | + if ( ! $domain instanceof DomainBase || ! $domain instanceof $fqcn) { |
|
106 | 106 | throw new DomainException( |
107 | 107 | sprintf( |
108 | 108 | esc_html__( |
@@ -113,10 +113,10 @@ discard block |
||
113 | 113 | ) |
114 | 114 | ); |
115 | 115 | } |
116 | - DomainFactory::$domains[ $fqcn ] = $domain; |
|
116 | + DomainFactory::$domains[$fqcn] = $domain; |
|
117 | 117 | // we still need to share this with the core loader to facilitate automatic dependency injection |
118 | 118 | LoaderFactory::getLoader()->share($fqcn, $domain, [$filepath, $version, $domain->assetNamespace()]); |
119 | 119 | } |
120 | - return DomainFactory::$domains[ $fqcn ]; |
|
120 | + return DomainFactory::$domains[$fqcn]; |
|
121 | 121 | } |
122 | 122 | } |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
91 | 91 | { |
92 | - if (! $this->initialized) { |
|
92 | + if ( ! $this->initialized) { |
|
93 | 93 | $this->plugin_basename = plugin_basename($this->pluginFile()); |
94 | 94 | $this->plugin_path = plugin_dir_path($this->pluginFile()); |
95 | 95 | $this->plugin_url = plugin_dir_url($this->pluginFile()); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
108 | 108 | { |
109 | - if (! $this->asset_namespace) { |
|
109 | + if ( ! $this->asset_namespace) { |
|
110 | 110 | $this->asset_namespace = sanitize_key( |
111 | 111 | // convert directory separators to dashes and remove file extension |
112 | 112 | str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | private function setDistributionAssetsPath() |
123 | 123 | { |
124 | 124 | $assets_folder_paths = [ |
125 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
126 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path.DomainBase::ASSETS_FOLDER, |
|
126 | + $this->plugin_path.'src/'.DomainBase::ASSETS_FOLDER, |
|
127 | 127 | ]; |
128 | 128 | foreach ($assets_folder_paths as $assets_folder_path) { |
129 | 129 | if (is_readable($assets_folder_path)) { |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | public function pluginPath($additional_path = ''): string |
170 | 170 | { |
171 | 171 | return is_string($additional_path) && $additional_path !== '' |
172 | - ? $this->plugin_path . $additional_path |
|
172 | + ? $this->plugin_path.$additional_path |
|
173 | 173 | : $this->plugin_path; |
174 | 174 | } |
175 | 175 | |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | public function pluginUrl($additional_path = ''): string |
182 | 182 | { |
183 | 183 | return is_string($additional_path) && $additional_path !== '' |
184 | - ? $this->plugin_url . $additional_path |
|
184 | + ? $this->plugin_url.$additional_path |
|
185 | 185 | : $this->plugin_url; |
186 | 186 | } |
187 | 187 | |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | public function distributionAssetsPath($additional_path = ''): string |
221 | 221 | { |
222 | 222 | return is_string($additional_path) && $additional_path !== '' |
223 | - ? $this->assets_path . $additional_path |
|
223 | + ? $this->assets_path.$additional_path |
|
224 | 224 | : $this->assets_path; |
225 | 225 | } |
226 | 226 | |
@@ -232,8 +232,8 @@ discard block |
||
232 | 232 | public function distributionAssetsUrl($additional_path = ''): string |
233 | 233 | { |
234 | 234 | return is_string($additional_path) && $additional_path !== '' |
235 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
236 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
235 | + ? $this->plugin_url.DomainBase::ASSETS_FOLDER.$additional_path |
|
236 | + : $this->plugin_url.DomainBase::ASSETS_FOLDER; |
|
237 | 237 | } |
238 | 238 | |
239 | 239 |
@@ -16,231 +16,231 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class DomainBase implements DomainInterface |
18 | 18 | { |
19 | - const ASSETS_FOLDER = 'assets/'; |
|
20 | - |
|
21 | - /** |
|
22 | - * Equivalent to `__FILE__` for main plugin file. |
|
23 | - * |
|
24 | - * @var FilePath |
|
25 | - */ |
|
26 | - private $plugin_file; |
|
27 | - |
|
28 | - /** |
|
29 | - * String indicating version for plugin |
|
30 | - * |
|
31 | - * @var string |
|
32 | - */ |
|
33 | - private $version; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var string $plugin_basename |
|
37 | - */ |
|
38 | - private $plugin_basename; |
|
39 | - |
|
40 | - /** |
|
41 | - * @var string $plugin_path |
|
42 | - */ |
|
43 | - private $plugin_path; |
|
44 | - |
|
45 | - /** |
|
46 | - * @var string $plugin_url |
|
47 | - */ |
|
48 | - private $plugin_url; |
|
49 | - |
|
50 | - /** |
|
51 | - * @var string $asset_namespace |
|
52 | - */ |
|
53 | - private $asset_namespace; |
|
54 | - |
|
55 | - /** |
|
56 | - * @var string $assets_path |
|
57 | - */ |
|
58 | - private $assets_path; |
|
59 | - |
|
60 | - /** |
|
61 | - * @var bool |
|
62 | - */ |
|
63 | - protected $initialized = false; |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Initializes internal properties. |
|
68 | - * |
|
69 | - * @param FilePath $plugin_file |
|
70 | - * @param Version $version |
|
71 | - * @param string $asset_namespace |
|
72 | - */ |
|
73 | - public function __construct( |
|
74 | - FilePath $plugin_file, |
|
75 | - Version $version, |
|
76 | - string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | - ) { |
|
78 | - $this->plugin_file = $plugin_file; |
|
79 | - $this->version = $version; |
|
80 | - $this->initialize($asset_namespace); |
|
81 | - } |
|
82 | - |
|
83 | - |
|
84 | - /** |
|
85 | - * @param string $asset_namespace |
|
86 | - * @return void |
|
87 | - * @since 5.0.0.p |
|
88 | - */ |
|
89 | - public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | - { |
|
91 | - if (! $this->initialized) { |
|
92 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | - $this->setAssetNamespace($asset_namespace); |
|
96 | - $this->setDistributionAssetsPath(); |
|
97 | - $this->initialized = true; |
|
98 | - } |
|
99 | - } |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * @param string $asset_namespace |
|
104 | - * @return void |
|
105 | - */ |
|
106 | - public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | - { |
|
108 | - if (! $this->asset_namespace) { |
|
109 | - $this->asset_namespace = sanitize_key( |
|
110 | - // convert directory separators to dashes and remove file extension |
|
111 | - str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | - ); |
|
113 | - } |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @throws DomainException |
|
119 | - * @since 5.0.0.p |
|
120 | - */ |
|
121 | - private function setDistributionAssetsPath() |
|
122 | - { |
|
123 | - $assets_folder_paths = [ |
|
124 | - $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | - $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | - ]; |
|
127 | - foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | - if (is_readable($assets_folder_path)) { |
|
129 | - $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | - // once we find a valid path, just break out of loop |
|
131 | - break; |
|
132 | - } |
|
133 | - } |
|
134 | - } |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * @return string |
|
139 | - */ |
|
140 | - public function pluginFile(): string |
|
141 | - { |
|
142 | - return (string) $this->plugin_file; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return FilePath |
|
148 | - */ |
|
149 | - public function pluginFileObject(): FilePath |
|
150 | - { |
|
151 | - return $this->plugin_file; |
|
152 | - } |
|
153 | - |
|
154 | - |
|
155 | - /** |
|
156 | - * @return string |
|
157 | - */ |
|
158 | - public function pluginBasename(): string |
|
159 | - { |
|
160 | - return $this->plugin_basename; |
|
161 | - } |
|
162 | - |
|
163 | - |
|
164 | - /** |
|
165 | - * @param string $additional_path |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - public function pluginPath($additional_path = ''): string |
|
169 | - { |
|
170 | - return is_string($additional_path) && $additional_path !== '' |
|
171 | - ? $this->plugin_path . $additional_path |
|
172 | - : $this->plugin_path; |
|
173 | - } |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * @param string $additional_path |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function pluginUrl($additional_path = ''): string |
|
181 | - { |
|
182 | - return is_string($additional_path) && $additional_path !== '' |
|
183 | - ? $this->plugin_url . $additional_path |
|
184 | - : $this->plugin_url; |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * @return string |
|
190 | - */ |
|
191 | - public function version(): string |
|
192 | - { |
|
193 | - return (string) $this->version; |
|
194 | - } |
|
195 | - |
|
196 | - |
|
197 | - /** |
|
198 | - * @return Version |
|
199 | - */ |
|
200 | - public function versionValueObject() |
|
201 | - { |
|
202 | - return $this->version; |
|
203 | - } |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * @return string |
|
208 | - */ |
|
209 | - public function distributionAssetsFolder(): string |
|
210 | - { |
|
211 | - return DomainBase::ASSETS_FOLDER; |
|
212 | - } |
|
213 | - |
|
214 | - |
|
215 | - /** |
|
216 | - * @param string $additional_path |
|
217 | - * @return string |
|
218 | - */ |
|
219 | - public function distributionAssetsPath($additional_path = ''): string |
|
220 | - { |
|
221 | - return is_string($additional_path) && $additional_path !== '' |
|
222 | - ? $this->assets_path . $additional_path |
|
223 | - : $this->assets_path; |
|
224 | - } |
|
225 | - |
|
226 | - |
|
227 | - /** |
|
228 | - * @param string $additional_path |
|
229 | - * @return string |
|
230 | - */ |
|
231 | - public function distributionAssetsUrl($additional_path = ''): string |
|
232 | - { |
|
233 | - return is_string($additional_path) && $additional_path !== '' |
|
234 | - ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | - : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - /** |
|
240 | - * @return string |
|
241 | - */ |
|
242 | - public function assetNamespace(): string |
|
243 | - { |
|
244 | - return $this->asset_namespace; |
|
245 | - } |
|
19 | + const ASSETS_FOLDER = 'assets/'; |
|
20 | + |
|
21 | + /** |
|
22 | + * Equivalent to `__FILE__` for main plugin file. |
|
23 | + * |
|
24 | + * @var FilePath |
|
25 | + */ |
|
26 | + private $plugin_file; |
|
27 | + |
|
28 | + /** |
|
29 | + * String indicating version for plugin |
|
30 | + * |
|
31 | + * @var string |
|
32 | + */ |
|
33 | + private $version; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var string $plugin_basename |
|
37 | + */ |
|
38 | + private $plugin_basename; |
|
39 | + |
|
40 | + /** |
|
41 | + * @var string $plugin_path |
|
42 | + */ |
|
43 | + private $plugin_path; |
|
44 | + |
|
45 | + /** |
|
46 | + * @var string $plugin_url |
|
47 | + */ |
|
48 | + private $plugin_url; |
|
49 | + |
|
50 | + /** |
|
51 | + * @var string $asset_namespace |
|
52 | + */ |
|
53 | + private $asset_namespace; |
|
54 | + |
|
55 | + /** |
|
56 | + * @var string $assets_path |
|
57 | + */ |
|
58 | + private $assets_path; |
|
59 | + |
|
60 | + /** |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | + protected $initialized = false; |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Initializes internal properties. |
|
68 | + * |
|
69 | + * @param FilePath $plugin_file |
|
70 | + * @param Version $version |
|
71 | + * @param string $asset_namespace |
|
72 | + */ |
|
73 | + public function __construct( |
|
74 | + FilePath $plugin_file, |
|
75 | + Version $version, |
|
76 | + string $asset_namespace = Domain::ASSET_NAMESPACE |
|
77 | + ) { |
|
78 | + $this->plugin_file = $plugin_file; |
|
79 | + $this->version = $version; |
|
80 | + $this->initialize($asset_namespace); |
|
81 | + } |
|
82 | + |
|
83 | + |
|
84 | + /** |
|
85 | + * @param string $asset_namespace |
|
86 | + * @return void |
|
87 | + * @since 5.0.0.p |
|
88 | + */ |
|
89 | + public function initialize($asset_namespace = Domain::ASSET_NAMESPACE) |
|
90 | + { |
|
91 | + if (! $this->initialized) { |
|
92 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
93 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
94 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
95 | + $this->setAssetNamespace($asset_namespace); |
|
96 | + $this->setDistributionAssetsPath(); |
|
97 | + $this->initialized = true; |
|
98 | + } |
|
99 | + } |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * @param string $asset_namespace |
|
104 | + * @return void |
|
105 | + */ |
|
106 | + public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE) |
|
107 | + { |
|
108 | + if (! $this->asset_namespace) { |
|
109 | + $this->asset_namespace = sanitize_key( |
|
110 | + // convert directory separators to dashes and remove file extension |
|
111 | + str_replace(['/', '.php'], ['-', ''], $asset_namespace) |
|
112 | + ); |
|
113 | + } |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @throws DomainException |
|
119 | + * @since 5.0.0.p |
|
120 | + */ |
|
121 | + private function setDistributionAssetsPath() |
|
122 | + { |
|
123 | + $assets_folder_paths = [ |
|
124 | + $this->plugin_path . DomainBase::ASSETS_FOLDER, |
|
125 | + $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER, |
|
126 | + ]; |
|
127 | + foreach ($assets_folder_paths as $assets_folder_path) { |
|
128 | + if (is_readable($assets_folder_path)) { |
|
129 | + $this->assets_path = trailingslashit($assets_folder_path); |
|
130 | + // once we find a valid path, just break out of loop |
|
131 | + break; |
|
132 | + } |
|
133 | + } |
|
134 | + } |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * @return string |
|
139 | + */ |
|
140 | + public function pluginFile(): string |
|
141 | + { |
|
142 | + return (string) $this->plugin_file; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return FilePath |
|
148 | + */ |
|
149 | + public function pluginFileObject(): FilePath |
|
150 | + { |
|
151 | + return $this->plugin_file; |
|
152 | + } |
|
153 | + |
|
154 | + |
|
155 | + /** |
|
156 | + * @return string |
|
157 | + */ |
|
158 | + public function pluginBasename(): string |
|
159 | + { |
|
160 | + return $this->plugin_basename; |
|
161 | + } |
|
162 | + |
|
163 | + |
|
164 | + /** |
|
165 | + * @param string $additional_path |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + public function pluginPath($additional_path = ''): string |
|
169 | + { |
|
170 | + return is_string($additional_path) && $additional_path !== '' |
|
171 | + ? $this->plugin_path . $additional_path |
|
172 | + : $this->plugin_path; |
|
173 | + } |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * @param string $additional_path |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function pluginUrl($additional_path = ''): string |
|
181 | + { |
|
182 | + return is_string($additional_path) && $additional_path !== '' |
|
183 | + ? $this->plugin_url . $additional_path |
|
184 | + : $this->plugin_url; |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * @return string |
|
190 | + */ |
|
191 | + public function version(): string |
|
192 | + { |
|
193 | + return (string) $this->version; |
|
194 | + } |
|
195 | + |
|
196 | + |
|
197 | + /** |
|
198 | + * @return Version |
|
199 | + */ |
|
200 | + public function versionValueObject() |
|
201 | + { |
|
202 | + return $this->version; |
|
203 | + } |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * @return string |
|
208 | + */ |
|
209 | + public function distributionAssetsFolder(): string |
|
210 | + { |
|
211 | + return DomainBase::ASSETS_FOLDER; |
|
212 | + } |
|
213 | + |
|
214 | + |
|
215 | + /** |
|
216 | + * @param string $additional_path |
|
217 | + * @return string |
|
218 | + */ |
|
219 | + public function distributionAssetsPath($additional_path = ''): string |
|
220 | + { |
|
221 | + return is_string($additional_path) && $additional_path !== '' |
|
222 | + ? $this->assets_path . $additional_path |
|
223 | + : $this->assets_path; |
|
224 | + } |
|
225 | + |
|
226 | + |
|
227 | + /** |
|
228 | + * @param string $additional_path |
|
229 | + * @return string |
|
230 | + */ |
|
231 | + public function distributionAssetsUrl($additional_path = ''): string |
|
232 | + { |
|
233 | + return is_string($additional_path) && $additional_path !== '' |
|
234 | + ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path |
|
235 | + : $this->plugin_url . DomainBase::ASSETS_FOLDER; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + /** |
|
240 | + * @return string |
|
241 | + */ |
|
242 | + public function assetNamespace(): string |
|
243 | + { |
|
244 | + return $this->asset_namespace; |
|
245 | + } |
|
246 | 246 | } |
@@ -3,25 +3,25 @@ |
||
3 | 3 | </p> |
4 | 4 | <p> |
5 | 5 | <?php |
6 | - printf( |
|
7 | - esc_html__( |
|
8 | - 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | - 'event_espresso' |
|
10 | - ), |
|
11 | - '<em>', |
|
12 | - '</em>' |
|
13 | - ); |
|
14 | - ?> |
|
6 | + printf( |
|
7 | + esc_html__( |
|
8 | + 'Message Templates are the %1$sformat%2$s of the messages going out. Think of them as a “form letter”. Templates tell the Messages system how to style your messages and the content (information) they will have when they are delivered.', |
|
9 | + 'event_espresso' |
|
10 | + ), |
|
11 | + '<em>', |
|
12 | + '</em>' |
|
13 | + ); |
|
14 | + ?> |
|
15 | 15 | </p> |
16 | 16 | <p> |
17 | 17 | <?php esc_html_e( |
18 | - 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | - 'event_espresso' |
|
20 | - ); ?> |
|
18 | + 'There is a template created for each Messenger / Message Type and context combination. For example, messages that are sent for Payment Confirmation have a template for Event Administrator and a different one for Primary Registrant. Whereas, messages that are sent for the Registration confirmation have 3 templates: one for Event Administrator, one for the Primary Registrant, and another for each additional Registrant(s).', |
|
19 | + 'event_espresso' |
|
20 | + ); ?> |
|
21 | 21 | </p> |
22 | 22 | <p> |
23 | 23 | <?php esc_html_e( |
24 | - 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With the Event Espresso Messages system, every Messenger, Message Type, and context will have a global template created with some default content on creation. You have the ability to edit the global template that will be used for all events you create. Additionally, you have the ability to create custom templates for each event on the edit event page for the event (in a metabox labelled "Notifications").', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |