1
|
|
|
<?php |
2
|
|
|
namespace EventEspresso\core\services\container; |
3
|
|
|
|
4
|
|
|
use EventEspresso\core\services\container\exceptions\ServiceNotFoundException; |
5
|
|
|
|
6
|
|
|
defined('EVENT_ESPRESSO_VERSION') || exit; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class CoffeeMill |
12
|
|
|
* Factory class for creating new classes via the CoffeeShop Dependency Injection Container |
13
|
|
|
* |
14
|
|
|
* @package Event Espresso |
15
|
|
|
* @author Brent Christensen |
16
|
|
|
* @since 4.9.27 |
17
|
|
|
*/ |
18
|
|
|
class CoffeeMill |
19
|
|
|
{ |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @var CoffeeShop $coffee_shop |
23
|
|
|
*/ |
24
|
|
|
private static $coffee_shop; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @return mixed |
30
|
|
|
*/ |
31
|
|
|
public static function getCoffeeShop() |
32
|
|
|
{ |
33
|
|
|
return self::$coffee_shop; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param CoffeeShop $coffee_shop |
40
|
|
|
*/ |
41
|
|
|
public static function setCoffeeShop(CoffeeShop $coffee_shop) |
42
|
|
|
{ |
43
|
|
|
self::$coffee_shop = $coffee_shop; |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
|
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @param string $identifier |
50
|
|
|
* @param array $arguments |
51
|
|
|
* @param string $type |
52
|
|
|
* @return mixed |
53
|
|
|
* @throws ServiceNotFoundException |
54
|
|
|
*/ |
55
|
|
|
public static function createNew($identifier, $arguments = array(), $type = CoffeeMaker::BREW_NEW) |
56
|
|
|
{ |
57
|
|
|
return self::$coffee_shop->brew($identifier, $arguments, $type); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
|
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* IMPORTANT!!! |
64
|
|
|
* Usage of this method is discouraged as it promotes service location. |
65
|
|
|
* It's current use is only as a stop gap measure until the CoffeeShop |
66
|
|
|
* Dependency Injection Container can be implemented properly for all classes. |
67
|
|
|
* If it is at all possible, inject your dependencies via your class constructor. |
68
|
|
|
* This method WILL BE DEPRECATED at some point in the near future. |
69
|
|
|
* |
70
|
|
|
* @param string $identifier |
71
|
|
|
* @param array $arguments |
72
|
|
|
* @param string $type |
73
|
|
|
* @return mixed |
74
|
|
|
* @throws ServiceNotFoundException |
75
|
|
|
*/ |
76
|
|
|
public static function getService($identifier, $arguments = array(), $type = CoffeeMaker::BREW_SHARED) |
77
|
|
|
{ |
78
|
|
|
return self::$coffee_shop->brew($identifier, $arguments, $type); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
} |
82
|
|
|
// End of file CoffeeMill.php |
83
|
|
|
// Location: core/services/container/CoffeeMill.php |