@@ -22,109 +22,109 @@ |
||
22 | 22 | class ActionItemManager |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * @var Collection $action_items |
|
27 | - */ |
|
28 | - private $action_items; |
|
29 | - |
|
30 | - /** |
|
31 | - * @type CapabilitiesChecker $capabilities_checker |
|
32 | - */ |
|
33 | - private $capabilities_checker; |
|
34 | - |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * CapChecker constructor |
|
39 | - * |
|
40 | - * @param CapabilitiesChecker $capabilities_checker |
|
41 | - */ |
|
42 | - public function __construct( CapabilitiesChecker $capabilities_checker ) |
|
43 | - { |
|
44 | - $this->capabilities_checker = $capabilities_checker; |
|
45 | - add_action( |
|
46 | - 'admin_notices', |
|
47 | - // 'in_admin_header', |
|
48 | - array( $this,'processConditionChecks' ) |
|
49 | - ); |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - |
|
54 | - /** |
|
55 | - * @return Collection |
|
56 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
57 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
58 | - * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
59 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
60 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
61 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
62 | - */ |
|
63 | - protected function loadActionItemCollection() |
|
64 | - { |
|
65 | - if ( ! $this->action_items instanceof Collection ) { |
|
66 | - $loader = new CollectionLoader( |
|
67 | - new CollectionDetails( |
|
68 | - // collection name |
|
69 | - 'action_items', |
|
70 | - // collection interface |
|
71 | - '\EventEspresso\core\services\action_items\ActionItemInterface', |
|
72 | - // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
73 | - array('EventEspresso\core\domain\services\action_items'), |
|
74 | - // filepaths to classes to add |
|
75 | - array(), |
|
76 | - // filemask to use if parsing folder for files to add |
|
77 | - '', |
|
78 | - // what to use as identifier for collection entities |
|
79 | - // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | - CollectionDetails::ID_CLASS_NAME |
|
81 | - ) |
|
82 | - ); |
|
83 | - $this->action_items = $loader->getCollection(); |
|
84 | - } |
|
85 | - return $this->action_items; |
|
86 | - } |
|
87 | - |
|
88 | - |
|
89 | - |
|
90 | - public function setConditionCheckHooks() |
|
91 | - { |
|
92 | - foreach ( $this->loadActionItemCollection() as $action_item ) { |
|
93 | - /** @var ActionItemInterface $action_item */ |
|
94 | - if ( $action_item instanceof RequiresCapCheckInterface ) { |
|
95 | - $this->capabilities_checker->processCapCheck( |
|
96 | - $action_item->getCapCheck() |
|
97 | - ); |
|
98 | - } |
|
99 | - $action_item->setConditionCheckHooks(); |
|
100 | - } |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - |
|
105 | - public function processConditionChecks() |
|
106 | - { |
|
107 | - foreach ( $this->loadActionItemCollection() as $action_item ) { |
|
108 | - /** @var ActionItemInterface $action_item */ |
|
109 | - if ( ! $action_item->conditionPassed() ) { |
|
110 | - continue; |
|
111 | - } |
|
112 | - $notice = \EEH_HTML::div( |
|
113 | - \EEH_HTML::link( |
|
114 | - $action_item->getActionItemUrl(), |
|
115 | - $action_item->getActionItemButtonText(), |
|
116 | - '', '', 'button button-primary', 'float:right; margin:.25em 0 .25em 2em;' |
|
117 | - ) . |
|
118 | - \EEH_HTML::p( |
|
119 | - $action_item->getActionItemNotice() |
|
120 | - ), |
|
121 | - 'message', |
|
122 | - 'ee-action-item-notice-dv updated notice', |
|
123 | - 'border-left-color:gold;' |
|
124 | - ); |
|
125 | - echo $notice; |
|
126 | - } |
|
127 | - } |
|
25 | + /** |
|
26 | + * @var Collection $action_items |
|
27 | + */ |
|
28 | + private $action_items; |
|
29 | + |
|
30 | + /** |
|
31 | + * @type CapabilitiesChecker $capabilities_checker |
|
32 | + */ |
|
33 | + private $capabilities_checker; |
|
34 | + |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * CapChecker constructor |
|
39 | + * |
|
40 | + * @param CapabilitiesChecker $capabilities_checker |
|
41 | + */ |
|
42 | + public function __construct( CapabilitiesChecker $capabilities_checker ) |
|
43 | + { |
|
44 | + $this->capabilities_checker = $capabilities_checker; |
|
45 | + add_action( |
|
46 | + 'admin_notices', |
|
47 | + // 'in_admin_header', |
|
48 | + array( $this,'processConditionChecks' ) |
|
49 | + ); |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + |
|
54 | + /** |
|
55 | + * @return Collection |
|
56 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
57 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
58 | + * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
59 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
60 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
61 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
62 | + */ |
|
63 | + protected function loadActionItemCollection() |
|
64 | + { |
|
65 | + if ( ! $this->action_items instanceof Collection ) { |
|
66 | + $loader = new CollectionLoader( |
|
67 | + new CollectionDetails( |
|
68 | + // collection name |
|
69 | + 'action_items', |
|
70 | + // collection interface |
|
71 | + '\EventEspresso\core\services\action_items\ActionItemInterface', |
|
72 | + // FQCNs for classes to add (all classes within that namespace will be loaded) |
|
73 | + array('EventEspresso\core\domain\services\action_items'), |
|
74 | + // filepaths to classes to add |
|
75 | + array(), |
|
76 | + // filemask to use if parsing folder for files to add |
|
77 | + '', |
|
78 | + // what to use as identifier for collection entities |
|
79 | + // using CLASS NAME prevents duplicates (works like a singleton) |
|
80 | + CollectionDetails::ID_CLASS_NAME |
|
81 | + ) |
|
82 | + ); |
|
83 | + $this->action_items = $loader->getCollection(); |
|
84 | + } |
|
85 | + return $this->action_items; |
|
86 | + } |
|
87 | + |
|
88 | + |
|
89 | + |
|
90 | + public function setConditionCheckHooks() |
|
91 | + { |
|
92 | + foreach ( $this->loadActionItemCollection() as $action_item ) { |
|
93 | + /** @var ActionItemInterface $action_item */ |
|
94 | + if ( $action_item instanceof RequiresCapCheckInterface ) { |
|
95 | + $this->capabilities_checker->processCapCheck( |
|
96 | + $action_item->getCapCheck() |
|
97 | + ); |
|
98 | + } |
|
99 | + $action_item->setConditionCheckHooks(); |
|
100 | + } |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + |
|
105 | + public function processConditionChecks() |
|
106 | + { |
|
107 | + foreach ( $this->loadActionItemCollection() as $action_item ) { |
|
108 | + /** @var ActionItemInterface $action_item */ |
|
109 | + if ( ! $action_item->conditionPassed() ) { |
|
110 | + continue; |
|
111 | + } |
|
112 | + $notice = \EEH_HTML::div( |
|
113 | + \EEH_HTML::link( |
|
114 | + $action_item->getActionItemUrl(), |
|
115 | + $action_item->getActionItemButtonText(), |
|
116 | + '', '', 'button button-primary', 'float:right; margin:.25em 0 .25em 2em;' |
|
117 | + ) . |
|
118 | + \EEH_HTML::p( |
|
119 | + $action_item->getActionItemNotice() |
|
120 | + ), |
|
121 | + 'message', |
|
122 | + 'ee-action-item-notice-dv updated notice', |
|
123 | + 'border-left-color:gold;' |
|
124 | + ); |
|
125 | + echo $notice; |
|
126 | + } |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | // End of file ActionItemManager.php |