1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace EventEspresso\core\domain; |
4
|
|
|
|
5
|
|
|
use EventEspresso\core\exceptions\InvalidDataTypeException; |
6
|
|
|
use EventEspresso\core\exceptions\InvalidInterfaceException; |
7
|
|
|
use InvalidArgumentException; |
8
|
|
|
use EventEspresso\core\services\loaders\LoaderFactory; |
9
|
|
|
|
10
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
11
|
|
|
|
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Class DomainFactory |
16
|
|
|
* Factory class for generating addon Domain objects |
17
|
|
|
* |
18
|
|
|
* @package EventEspresso\core\domain |
19
|
|
|
* @author Brent Christensen |
20
|
|
|
* @since 4.9.50 |
21
|
|
|
*/ |
22
|
|
|
class DomainFactory |
23
|
|
|
{ |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* @param string $domain_fcqn [required] Fully Qualified Class Name for the Domain class |
27
|
|
|
* @param array $arguments [required] array of arguments to be passed to the Domain class constructor. |
28
|
|
|
* must include the following two elements as a minimum: |
29
|
|
|
* array( |
30
|
|
|
* $plugin_file, // full server path to the addon main file (__FILE__) |
31
|
|
|
* $version, // standard version string like #.#.# |
32
|
|
|
* ) |
33
|
|
|
* @return mixed |
34
|
|
|
* @throws InvalidArgumentException |
35
|
|
|
* @throws InvalidDataTypeException |
36
|
|
|
* @throws InvalidInterfaceException |
37
|
|
|
*/ |
38
|
|
|
public static function create($domain_fcqn = '', array $arguments) |
39
|
|
|
{ |
40
|
|
|
if(!isset($arguments[0], $arguments[1])) { |
41
|
|
|
throw new InvalidArgumentException( |
42
|
|
|
esc_html__( |
43
|
|
|
'You need to pass at least two arguments, representing the addon plugin file and version, in order to generate a Domain class', |
44
|
|
|
'event_espresso' |
45
|
|
|
) |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
$loader = LoaderFactory::getLoader(); |
49
|
|
|
return $loader->getShared($domain_fcqn, $arguments); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
} |
53
|
|
|
// Location: DomainFactory.php |
54
|
|
|
|