@@ -14,41 +14,41 @@ |
||
14 | 14 | */ |
15 | 15 | class SessionLifespanOption extends WordPressOption |
16 | 16 | { |
17 | - const DEFAULT_LIFESPAN = HOUR_IN_SECONDS; |
|
18 | - |
|
19 | - const OPTION_NAME = 'ee-session-lifespan'; |
|
20 | - |
|
21 | - |
|
22 | - /** |
|
23 | - * SessionLifespanOption constructor. |
|
24 | - */ |
|
25 | - public function __construct() |
|
26 | - { |
|
27 | - parent::__construct( |
|
28 | - SessionLifespanOption::OPTION_NAME, |
|
29 | - SessionLifespanOption::DEFAULT_LIFESPAN, |
|
30 | - false |
|
31 | - ); |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - /** |
|
36 | - * @return false|mixed|void |
|
37 | - */ |
|
38 | - public function getSessionLifespan() |
|
39 | - { |
|
40 | - return $this->loadOption(); |
|
41 | - } |
|
42 | - |
|
43 | - /** |
|
44 | - * @param int $value |
|
45 | - * @return false|mixed|void |
|
46 | - */ |
|
47 | - public function setSessionLifespan(int $value) |
|
48 | - { |
|
49 | - if ($value <= 0) { |
|
50 | - $value = SessionLifespanOption::DEFAULT_LIFESPAN; |
|
51 | - } |
|
52 | - return $this->updateOption($value); |
|
53 | - } |
|
17 | + const DEFAULT_LIFESPAN = HOUR_IN_SECONDS; |
|
18 | + |
|
19 | + const OPTION_NAME = 'ee-session-lifespan'; |
|
20 | + |
|
21 | + |
|
22 | + /** |
|
23 | + * SessionLifespanOption constructor. |
|
24 | + */ |
|
25 | + public function __construct() |
|
26 | + { |
|
27 | + parent::__construct( |
|
28 | + SessionLifespanOption::OPTION_NAME, |
|
29 | + SessionLifespanOption::DEFAULT_LIFESPAN, |
|
30 | + false |
|
31 | + ); |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + /** |
|
36 | + * @return false|mixed|void |
|
37 | + */ |
|
38 | + public function getSessionLifespan() |
|
39 | + { |
|
40 | + return $this->loadOption(); |
|
41 | + } |
|
42 | + |
|
43 | + /** |
|
44 | + * @param int $value |
|
45 | + * @return false|mixed|void |
|
46 | + */ |
|
47 | + public function setSessionLifespan(int $value) |
|
48 | + { |
|
49 | + if ($value <= 0) { |
|
50 | + $value = SessionLifespanOption::DEFAULT_LIFESPAN; |
|
51 | + } |
|
52 | + return $this->updateOption($value); |
|
53 | + } |
|
54 | 54 | } |
@@ -19,96 +19,96 @@ |
||
19 | 19 | */ |
20 | 20 | class SessionLifespan |
21 | 21 | { |
22 | - /** |
|
23 | - * how long an EE session lasts in seconds |
|
24 | - * default session lifespan of 1 hour (for not so instant IPNs) |
|
25 | - * |
|
26 | - * @var int $lifespan |
|
27 | - */ |
|
28 | - private $lifespan; |
|
22 | + /** |
|
23 | + * how long an EE session lasts in seconds |
|
24 | + * default session lifespan of 1 hour (for not so instant IPNs) |
|
25 | + * |
|
26 | + * @var int $lifespan |
|
27 | + */ |
|
28 | + private $lifespan; |
|
29 | 29 | |
30 | 30 | |
31 | - /** |
|
32 | - * SessionLifespan constructor. |
|
33 | - * |
|
34 | - * @param SessionLifespanOption $session_lifespan_option |
|
35 | - * @throws DomainException |
|
36 | - */ |
|
37 | - public function __construct(SessionLifespanOption $session_lifespan_option) |
|
38 | - { |
|
39 | - $this->setLifespan($session_lifespan_option->getSessionLifespan()); |
|
40 | - } |
|
31 | + /** |
|
32 | + * SessionLifespan constructor. |
|
33 | + * |
|
34 | + * @param SessionLifespanOption $session_lifespan_option |
|
35 | + * @throws DomainException |
|
36 | + */ |
|
37 | + public function __construct(SessionLifespanOption $session_lifespan_option) |
|
38 | + { |
|
39 | + $this->setLifespan($session_lifespan_option->getSessionLifespan()); |
|
40 | + } |
|
41 | 41 | |
42 | 42 | |
43 | - /** |
|
44 | - * @param int $lifespan |
|
45 | - * @throws DomainException |
|
46 | - */ |
|
47 | - protected function setLifespan($lifespan) |
|
48 | - { |
|
49 | - if ($lifespan < 60) { |
|
50 | - throw new DomainException( |
|
51 | - esc_html__( |
|
52 | - 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
53 | - 'event_espresso' |
|
54 | - ) |
|
55 | - ); |
|
56 | - } |
|
57 | - $this->lifespan = apply_filters( |
|
58 | - 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
59 | - // apply legacy filter for now but add doing it wrong notice in future |
|
60 | - apply_filters( |
|
61 | - 'FHEE__EE_Session__construct___lifespan', |
|
62 | - $lifespan |
|
63 | - ) |
|
64 | - ) + 1; |
|
65 | - } |
|
43 | + /** |
|
44 | + * @param int $lifespan |
|
45 | + * @throws DomainException |
|
46 | + */ |
|
47 | + protected function setLifespan($lifespan) |
|
48 | + { |
|
49 | + if ($lifespan < 60) { |
|
50 | + throw new DomainException( |
|
51 | + esc_html__( |
|
52 | + 'The session lifespan needs to be at least 60 seconds, and even that is extremely short', |
|
53 | + 'event_espresso' |
|
54 | + ) |
|
55 | + ); |
|
56 | + } |
|
57 | + $this->lifespan = apply_filters( |
|
58 | + 'FHEE__EventEspresso_core_domain_values_session_SessionLifespan__setLifespan___lifespan', |
|
59 | + // apply legacy filter for now but add doing it wrong notice in future |
|
60 | + apply_filters( |
|
61 | + 'FHEE__EE_Session__construct___lifespan', |
|
62 | + $lifespan |
|
63 | + ) |
|
64 | + ) + 1; |
|
65 | + } |
|
66 | 66 | |
67 | 67 | |
68 | - /** |
|
69 | - * @return int |
|
70 | - */ |
|
71 | - public function inSeconds() |
|
72 | - { |
|
73 | - return $this->lifespan; |
|
74 | - } |
|
68 | + /** |
|
69 | + * @return int |
|
70 | + */ |
|
71 | + public function inSeconds() |
|
72 | + { |
|
73 | + return $this->lifespan; |
|
74 | + } |
|
75 | 75 | |
76 | 76 | |
77 | - /** |
|
78 | - * @param string $separator |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function inHoursMinutesSeconds($separator = ':') |
|
82 | - { |
|
83 | - return sprintf( |
|
84 | - '%02d%s%02d%s%02d', |
|
85 | - floor($this->lifespan / 3600), |
|
86 | - $separator, |
|
87 | - ($this->lifespan / 60) % 60, |
|
88 | - $separator, |
|
89 | - $this->lifespan % 60 |
|
90 | - ); |
|
91 | - } |
|
77 | + /** |
|
78 | + * @param string $separator |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function inHoursMinutesSeconds($separator = ':') |
|
82 | + { |
|
83 | + return sprintf( |
|
84 | + '%02d%s%02d%s%02d', |
|
85 | + floor($this->lifespan / 3600), |
|
86 | + $separator, |
|
87 | + ($this->lifespan / 60) % 60, |
|
88 | + $separator, |
|
89 | + $this->lifespan % 60 |
|
90 | + ); |
|
91 | + } |
|
92 | 92 | |
93 | 93 | |
94 | - /** |
|
95 | - * Returns a timestamp for when the session would expire based on this lifespan |
|
96 | - * |
|
97 | - * @param bool $utc If true, displays expiration in UTC |
|
98 | - * If false, displays expiration in local time |
|
99 | - * @return int |
|
100 | - */ |
|
101 | - public function expiration($utc = true) |
|
102 | - { |
|
103 | - return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
104 | - } |
|
94 | + /** |
|
95 | + * Returns a timestamp for when the session would expire based on this lifespan |
|
96 | + * |
|
97 | + * @param bool $utc If true, displays expiration in UTC |
|
98 | + * If false, displays expiration in local time |
|
99 | + * @return int |
|
100 | + */ |
|
101 | + public function expiration($utc = true) |
|
102 | + { |
|
103 | + return (int) current_time('timestamp', $utc) - $this->lifespan; |
|
104 | + } |
|
105 | 105 | |
106 | 106 | |
107 | - /** |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function __toString() |
|
111 | - { |
|
112 | - return (string) $this->inSeconds(); |
|
113 | - } |
|
107 | + /** |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function __toString() |
|
111 | + { |
|
112 | + return (string) $this->inSeconds(); |
|
113 | + } |
|
114 | 114 | } |
@@ -12,44 +12,44 @@ |
||
12 | 12 | |
13 | 13 | class SessionLifespanForm extends EE_Form_Section_Proper |
14 | 14 | { |
15 | - /** |
|
16 | - * SessionLifespanForm constructor. |
|
17 | - * |
|
18 | - * @param SessionLifespanOption $session_lifespan_option |
|
19 | - * @throws EE_Error |
|
20 | - */ |
|
21 | - public function __construct(SessionLifespanOption $session_lifespan_option) |
|
22 | - { |
|
23 | - parent::__construct([ |
|
24 | - 'name' => 'session_lifespan', |
|
25 | - 'html_id' => 'session_lifespan', |
|
26 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
27 | - 'subsections' => apply_filters( |
|
28 | - 'FHEE__EventEspresso_caffeinated_admin_extend_registration_form_forms_SessionLifespanForm__construct__form_subsections', |
|
29 | - [ |
|
30 | - 'session_lifespan_hdr' => new EE_Form_Section_HTML( |
|
31 | - EEH_HTML::h2(esc_html__('Session Settings', 'event_espresso')) |
|
32 | - ), |
|
33 | - 'session_lifespan' => new EE_Select_Input( |
|
34 | - [ |
|
35 | - 300 => esc_html__('Five Minutes', 'event_espresso'), |
|
36 | - 900 => esc_html__('Fifteen Minutes', 'event_espresso'), |
|
37 | - 1800 => esc_html__('Thirty Minutes', 'event_espresso'), |
|
38 | - 3600 => esc_html__('One Hour', 'event_espresso'), |
|
39 | - 7200 => esc_html__('Two Hours', 'event_espresso'), |
|
40 | - ], |
|
41 | - [ |
|
42 | - 'html_label_text' => esc_html__('Session Lifespan', 'event_espresso'), |
|
43 | - 'html_help_text' => esc_html__( |
|
44 | - 'Controls how long a user has to complete the registration form. Defaults to 1 hour.', |
|
45 | - 'event_espresso' |
|
46 | - ), |
|
47 | - 'default' => $session_lifespan_option->getSessionLifespan(), |
|
48 | - 'required' => false, |
|
49 | - ] |
|
50 | - ), |
|
51 | - ] |
|
52 | - ), |
|
53 | - ]); |
|
54 | - } |
|
15 | + /** |
|
16 | + * SessionLifespanForm constructor. |
|
17 | + * |
|
18 | + * @param SessionLifespanOption $session_lifespan_option |
|
19 | + * @throws EE_Error |
|
20 | + */ |
|
21 | + public function __construct(SessionLifespanOption $session_lifespan_option) |
|
22 | + { |
|
23 | + parent::__construct([ |
|
24 | + 'name' => 'session_lifespan', |
|
25 | + 'html_id' => 'session_lifespan', |
|
26 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
27 | + 'subsections' => apply_filters( |
|
28 | + 'FHEE__EventEspresso_caffeinated_admin_extend_registration_form_forms_SessionLifespanForm__construct__form_subsections', |
|
29 | + [ |
|
30 | + 'session_lifespan_hdr' => new EE_Form_Section_HTML( |
|
31 | + EEH_HTML::h2(esc_html__('Session Settings', 'event_espresso')) |
|
32 | + ), |
|
33 | + 'session_lifespan' => new EE_Select_Input( |
|
34 | + [ |
|
35 | + 300 => esc_html__('Five Minutes', 'event_espresso'), |
|
36 | + 900 => esc_html__('Fifteen Minutes', 'event_espresso'), |
|
37 | + 1800 => esc_html__('Thirty Minutes', 'event_espresso'), |
|
38 | + 3600 => esc_html__('One Hour', 'event_espresso'), |
|
39 | + 7200 => esc_html__('Two Hours', 'event_espresso'), |
|
40 | + ], |
|
41 | + [ |
|
42 | + 'html_label_text' => esc_html__('Session Lifespan', 'event_espresso'), |
|
43 | + 'html_help_text' => esc_html__( |
|
44 | + 'Controls how long a user has to complete the registration form. Defaults to 1 hour.', |
|
45 | + 'event_espresso' |
|
46 | + ), |
|
47 | + 'default' => $session_lifespan_option->getSessionLifespan(), |
|
48 | + 'required' => false, |
|
49 | + ] |
|
50 | + ), |
|
51 | + ] |
|
52 | + ), |
|
53 | + ]); |
|
54 | + } |
|
55 | 55 | } |
@@ -12,59 +12,59 @@ |
||
12 | 12 | |
13 | 13 | class SessionLifespanFormHandler |
14 | 14 | { |
15 | - /** |
|
16 | - * @var SessionLifespanOption |
|
17 | - */ |
|
18 | - private $session_lifespan_option; |
|
15 | + /** |
|
16 | + * @var SessionLifespanOption |
|
17 | + */ |
|
18 | + private $session_lifespan_option; |
|
19 | 19 | |
20 | 20 | |
21 | - /** |
|
22 | - * SessionLifespanForm constructor. |
|
23 | - * |
|
24 | - * @param SessionLifespanOption $session_lifespan_option |
|
25 | - */ |
|
26 | - public function __construct(SessionLifespanOption $session_lifespan_option) |
|
27 | - { |
|
28 | - $this->session_lifespan_option = $session_lifespan_option; |
|
29 | - } |
|
21 | + /** |
|
22 | + * SessionLifespanForm constructor. |
|
23 | + * |
|
24 | + * @param SessionLifespanOption $session_lifespan_option |
|
25 | + */ |
|
26 | + public function __construct(SessionLifespanOption $session_lifespan_option) |
|
27 | + { |
|
28 | + $this->session_lifespan_option = $session_lifespan_option; |
|
29 | + } |
|
30 | 30 | |
31 | 31 | |
32 | - public function process(SessionLifespanForm $form) |
|
33 | - { |
|
34 | - try { |
|
35 | - // if not displaying a form, then check for form submission |
|
36 | - if ($form->was_submitted()) { |
|
37 | - // capture form data |
|
38 | - $form->receive_form_submission(); |
|
39 | - // validate form data |
|
40 | - if ($form->is_valid()) { |
|
41 | - // grab validated data from form |
|
42 | - $valid_data = $form->valid_data(); |
|
43 | - if (isset($valid_data['session_lifespan'])) { |
|
44 | - $session_lifespan = (int) $valid_data['session_lifespan']; |
|
45 | - $this->session_lifespan_option->setSessionLifespan($session_lifespan); |
|
46 | - } else { |
|
47 | - EE_Error::add_error( |
|
48 | - esc_html__( |
|
49 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
50 | - 'event_espresso' |
|
51 | - ), |
|
52 | - __FILE__, |
|
53 | - __FUNCTION__, |
|
54 | - __LINE__ |
|
55 | - ); |
|
56 | - } |
|
57 | - } elseif ($form->submission_error_message() !== '') { |
|
58 | - EE_Error::add_error( |
|
59 | - $form->submission_error_message(), |
|
60 | - __FILE__, |
|
61 | - __FUNCTION__, |
|
62 | - __LINE__ |
|
63 | - ); |
|
64 | - } |
|
65 | - } |
|
66 | - } catch (EE_Error $e) { |
|
67 | - $e->get_error(); |
|
68 | - } |
|
69 | - } |
|
32 | + public function process(SessionLifespanForm $form) |
|
33 | + { |
|
34 | + try { |
|
35 | + // if not displaying a form, then check for form submission |
|
36 | + if ($form->was_submitted()) { |
|
37 | + // capture form data |
|
38 | + $form->receive_form_submission(); |
|
39 | + // validate form data |
|
40 | + if ($form->is_valid()) { |
|
41 | + // grab validated data from form |
|
42 | + $valid_data = $form->valid_data(); |
|
43 | + if (isset($valid_data['session_lifespan'])) { |
|
44 | + $session_lifespan = (int) $valid_data['session_lifespan']; |
|
45 | + $this->session_lifespan_option->setSessionLifespan($session_lifespan); |
|
46 | + } else { |
|
47 | + EE_Error::add_error( |
|
48 | + esc_html__( |
|
49 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
50 | + 'event_espresso' |
|
51 | + ), |
|
52 | + __FILE__, |
|
53 | + __FUNCTION__, |
|
54 | + __LINE__ |
|
55 | + ); |
|
56 | + } |
|
57 | + } elseif ($form->submission_error_message() !== '') { |
|
58 | + EE_Error::add_error( |
|
59 | + $form->submission_error_message(), |
|
60 | + __FILE__, |
|
61 | + __FUNCTION__, |
|
62 | + __LINE__ |
|
63 | + ); |
|
64 | + } |
|
65 | + } |
|
66 | + } catch (EE_Error $e) { |
|
67 | + $e->get_error(); |
|
68 | + } |
|
69 | + } |
|
70 | 70 | } |
@@ -17,1460 +17,1460 @@ |
||
17 | 17 | */ |
18 | 18 | class Extend_Registration_Form_Admin_Page extends Registration_Form_Admin_Page |
19 | 19 | { |
20 | - /** |
|
21 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
22 | - */ |
|
23 | - public function __construct($routing = true) |
|
24 | - { |
|
25 | - define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
26 | - define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
27 | - define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
28 | - define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
29 | - define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
30 | - parent::__construct($routing); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * @return void |
|
36 | - */ |
|
37 | - protected function _extend_page_config() |
|
38 | - { |
|
39 | - $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
40 | - $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
41 | - ? $this->_req_data['QST_ID'] : 0; |
|
42 | - $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
43 | - ? $this->_req_data['QSG_ID'] : 0; |
|
44 | - |
|
45 | - $new_page_routes = array( |
|
46 | - 'question_groups' => array( |
|
47 | - 'func' => '_question_groups_overview_list_table', |
|
48 | - 'capability' => 'ee_read_question_groups', |
|
49 | - ), |
|
50 | - 'add_question' => array( |
|
51 | - 'func' => '_edit_question', |
|
52 | - 'capability' => 'ee_edit_questions', |
|
53 | - ), |
|
54 | - 'insert_question' => array( |
|
55 | - 'func' => '_insert_or_update_question', |
|
56 | - 'args' => array('new_question' => true), |
|
57 | - 'capability' => 'ee_edit_questions', |
|
58 | - 'noheader' => true, |
|
59 | - ), |
|
60 | - 'duplicate_question' => array( |
|
61 | - 'func' => '_duplicate_question', |
|
62 | - 'capability' => 'ee_edit_questions', |
|
63 | - 'noheader' => true, |
|
64 | - ), |
|
65 | - 'trash_question' => array( |
|
66 | - 'func' => '_trash_question', |
|
67 | - 'capability' => 'ee_delete_question', |
|
68 | - 'obj_id' => $qst_id, |
|
69 | - 'noheader' => true, |
|
70 | - ), |
|
71 | - |
|
72 | - 'restore_question' => array( |
|
73 | - 'func' => '_trash_or_restore_questions', |
|
74 | - 'capability' => 'ee_delete_question', |
|
75 | - 'obj_id' => $qst_id, |
|
76 | - 'args' => array('trash' => false), |
|
77 | - 'noheader' => true, |
|
78 | - ), |
|
79 | - |
|
80 | - 'delete_question' => array( |
|
81 | - 'func' => '_delete_question', |
|
82 | - 'capability' => 'ee_delete_question', |
|
83 | - 'obj_id' => $qst_id, |
|
84 | - 'noheader' => true, |
|
85 | - ), |
|
86 | - |
|
87 | - 'trash_questions' => array( |
|
88 | - 'func' => '_trash_or_restore_questions', |
|
89 | - 'capability' => 'ee_delete_questions', |
|
90 | - 'args' => array('trash' => true), |
|
91 | - 'noheader' => true, |
|
92 | - ), |
|
93 | - |
|
94 | - 'restore_questions' => array( |
|
95 | - 'func' => '_trash_or_restore_questions', |
|
96 | - 'capability' => 'ee_delete_questions', |
|
97 | - 'args' => array('trash' => false), |
|
98 | - 'noheader' => true, |
|
99 | - ), |
|
100 | - |
|
101 | - 'delete_questions' => array( |
|
102 | - 'func' => '_delete_questions', |
|
103 | - 'args' => array(), |
|
104 | - 'capability' => 'ee_delete_questions', |
|
105 | - 'noheader' => true, |
|
106 | - ), |
|
107 | - |
|
108 | - 'add_question_group' => array( |
|
109 | - 'func' => '_edit_question_group', |
|
110 | - 'capability' => 'ee_edit_question_groups', |
|
111 | - ), |
|
112 | - |
|
113 | - 'edit_question_group' => array( |
|
114 | - 'func' => '_edit_question_group', |
|
115 | - 'capability' => 'ee_edit_question_group', |
|
116 | - 'obj_id' => $qsg_id, |
|
117 | - 'args' => array('edit'), |
|
118 | - ), |
|
119 | - |
|
120 | - 'delete_question_groups' => array( |
|
121 | - 'func' => '_delete_question_groups', |
|
122 | - 'capability' => 'ee_delete_question_groups', |
|
123 | - 'noheader' => true, |
|
124 | - ), |
|
125 | - |
|
126 | - 'delete_question_group' => array( |
|
127 | - 'func' => '_delete_question_groups', |
|
128 | - 'capability' => 'ee_delete_question_group', |
|
129 | - 'obj_id' => $qsg_id, |
|
130 | - 'noheader' => true, |
|
131 | - ), |
|
132 | - |
|
133 | - 'trash_question_group' => array( |
|
134 | - 'func' => '_trash_or_restore_question_groups', |
|
135 | - 'args' => array('trash' => true), |
|
136 | - 'capability' => 'ee_delete_question_group', |
|
137 | - 'obj_id' => $qsg_id, |
|
138 | - 'noheader' => true, |
|
139 | - ), |
|
140 | - |
|
141 | - 'restore_question_group' => array( |
|
142 | - 'func' => '_trash_or_restore_question_groups', |
|
143 | - 'args' => array('trash' => false), |
|
144 | - 'capability' => 'ee_delete_question_group', |
|
145 | - 'obj_id' => $qsg_id, |
|
146 | - 'noheader' => true, |
|
147 | - ), |
|
148 | - |
|
149 | - 'insert_question_group' => array( |
|
150 | - 'func' => '_insert_or_update_question_group', |
|
151 | - 'args' => array('new_question_group' => true), |
|
152 | - 'capability' => 'ee_edit_question_groups', |
|
153 | - 'noheader' => true, |
|
154 | - ), |
|
155 | - |
|
156 | - 'update_question_group' => array( |
|
157 | - 'func' => '_insert_or_update_question_group', |
|
158 | - 'args' => array('new_question_group' => false), |
|
159 | - 'capability' => 'ee_edit_question_group', |
|
160 | - 'obj_id' => $qsg_id, |
|
161 | - 'noheader' => true, |
|
162 | - ), |
|
163 | - |
|
164 | - 'trash_question_groups' => array( |
|
165 | - 'func' => '_trash_or_restore_question_groups', |
|
166 | - 'args' => array('trash' => true), |
|
167 | - 'capability' => 'ee_delete_question_groups', |
|
168 | - 'noheader' => array('trash' => false), |
|
169 | - ), |
|
170 | - |
|
171 | - 'restore_question_groups' => array( |
|
172 | - 'func' => '_trash_or_restore_question_groups', |
|
173 | - 'args' => array('trash' => false), |
|
174 | - 'capability' => 'ee_delete_question_groups', |
|
175 | - 'noheader' => true, |
|
176 | - ), |
|
177 | - |
|
178 | - |
|
179 | - 'espresso_update_question_group_order' => array( |
|
180 | - 'func' => 'update_question_group_order', |
|
181 | - 'capability' => 'ee_edit_question_groups', |
|
182 | - 'noheader' => true, |
|
183 | - ), |
|
184 | - |
|
185 | - 'view_reg_form_settings' => array( |
|
186 | - 'func' => '_reg_form_settings', |
|
187 | - 'capability' => 'manage_options', |
|
188 | - ), |
|
189 | - |
|
190 | - 'update_reg_form_settings' => array( |
|
191 | - 'func' => '_update_reg_form_settings', |
|
192 | - 'capability' => 'manage_options', |
|
193 | - 'noheader' => true, |
|
194 | - ), |
|
195 | - ); |
|
196 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
197 | - |
|
198 | - $new_page_config = array( |
|
199 | - |
|
200 | - 'question_groups' => array( |
|
201 | - 'nav' => array( |
|
202 | - 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
203 | - 'icon' => 'dashicons-forms', |
|
204 | - 'order' => 20, |
|
205 | - ), |
|
206 | - 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
207 | - 'help_tabs' => array( |
|
208 | - 'registration_form_question_groups_help_tab' => array( |
|
209 | - 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
210 | - 'filename' => 'registration_form_question_groups', |
|
211 | - ), |
|
212 | - 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
213 | - 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
214 | - 'filename' => 'registration_form_question_groups_table_column_headings', |
|
215 | - ), |
|
216 | - 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
217 | - 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
218 | - 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
219 | - ), |
|
220 | - ), |
|
221 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
222 | - 'require_nonce' => false, |
|
223 | - ), |
|
224 | - |
|
225 | - 'add_question' => array( |
|
226 | - 'nav' => array( |
|
227 | - 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | - 'icon' => 'dashicons-plus-alt', |
|
229 | - 'order' => 15, |
|
230 | - 'persistent' => false, |
|
231 | - ), |
|
232 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
233 | - 'help_tabs' => array( |
|
234 | - 'registration_form_add_question_help_tab' => array( |
|
235 | - 'title' => esc_html__('Add Question', 'event_espresso'), |
|
236 | - 'filename' => 'registration_form_add_question', |
|
237 | - ), |
|
238 | - ), |
|
239 | - 'require_nonce' => false, |
|
240 | - ), |
|
241 | - |
|
242 | - 'add_question_group' => array( |
|
243 | - 'nav' => array( |
|
244 | - 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
245 | - 'icon' => 'dashicons-plus-alt', |
|
246 | - 'order' => 25, |
|
247 | - 'persistent' => false, |
|
248 | - ), |
|
249 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
250 | - 'help_tabs' => array( |
|
251 | - 'registration_form_add_question_group_help_tab' => array( |
|
252 | - 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
253 | - 'filename' => 'registration_form_add_question_group', |
|
254 | - ), |
|
255 | - ), |
|
256 | - 'require_nonce' => false, |
|
257 | - ), |
|
258 | - |
|
259 | - 'edit_question_group' => array( |
|
260 | - 'nav' => array( |
|
261 | - 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
262 | - 'icon' => 'dashicons-edit-large', |
|
263 | - 'order' => 25, |
|
264 | - 'persistent' => false, |
|
265 | - 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
266 | - array('question_group_id' => $this->_req_data['question_group_id']), |
|
267 | - $this->_current_page_view_url |
|
268 | - ) : $this->_admin_base_url, |
|
269 | - ), |
|
270 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
271 | - 'help_tabs' => array( |
|
272 | - 'registration_form_edit_question_group_help_tab' => array( |
|
273 | - 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
274 | - 'filename' => 'registration_form_edit_question_group', |
|
275 | - ), |
|
276 | - ), |
|
277 | - 'require_nonce' => false, |
|
278 | - ), |
|
279 | - |
|
280 | - 'view_reg_form_settings' => array( |
|
281 | - 'nav' => array( |
|
282 | - 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
283 | - 'icon' => 'dashicons-admin-generic', |
|
284 | - 'order' => 40, |
|
285 | - ), |
|
286 | - 'labels' => array( |
|
287 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
288 | - ), |
|
289 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
290 | - 'help_tabs' => array( |
|
291 | - 'registration_form_reg_form_settings_help_tab' => array( |
|
292 | - 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
293 | - 'filename' => 'registration_form_reg_form_settings', |
|
294 | - ), |
|
295 | - ), |
|
296 | - 'require_nonce' => false, |
|
297 | - ), |
|
298 | - |
|
299 | - ); |
|
300 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
301 | - |
|
302 | - // change the list table we're going to use so it's the NEW list table! |
|
303 | - $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
304 | - |
|
305 | - |
|
306 | - // additional labels |
|
307 | - $new_labels = array( |
|
308 | - 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
309 | - 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
310 | - 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
311 | - 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
312 | - 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
313 | - ); |
|
314 | - $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
315 | - } |
|
316 | - |
|
317 | - |
|
318 | - /** |
|
319 | - * @return void |
|
320 | - */ |
|
321 | - protected function _ajax_hooks() |
|
322 | - { |
|
323 | - add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * @return void |
|
329 | - */ |
|
330 | - public function load_scripts_styles_question_groups() |
|
331 | - { |
|
332 | - wp_enqueue_script('espresso_ajax_table_sorting'); |
|
333 | - } |
|
334 | - |
|
335 | - |
|
336 | - /** |
|
337 | - * @return void |
|
338 | - */ |
|
339 | - public function load_scripts_styles_add_question_group() |
|
340 | - { |
|
341 | - $this->load_scripts_styles_forms(); |
|
342 | - $this->load_sortable_question_script(); |
|
343 | - } |
|
344 | - |
|
345 | - |
|
346 | - /** |
|
347 | - * @return void |
|
348 | - */ |
|
349 | - public function load_scripts_styles_edit_question_group() |
|
350 | - { |
|
351 | - $this->load_scripts_styles_forms(); |
|
352 | - $this->load_sortable_question_script(); |
|
353 | - } |
|
354 | - |
|
355 | - |
|
356 | - /** |
|
357 | - * registers and enqueues script for questions |
|
358 | - * |
|
359 | - * @return void |
|
360 | - */ |
|
361 | - public function load_sortable_question_script() |
|
362 | - { |
|
363 | - wp_register_script( |
|
364 | - 'ee-question-sortable', |
|
365 | - REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
366 | - array('jquery-ui-sortable'), |
|
367 | - EVENT_ESPRESSO_VERSION, |
|
368 | - true |
|
369 | - ); |
|
370 | - wp_enqueue_script('ee-question-sortable'); |
|
371 | - } |
|
372 | - |
|
373 | - |
|
374 | - /** |
|
375 | - * @return void |
|
376 | - */ |
|
377 | - protected function _set_list_table_views_default() |
|
378 | - { |
|
379 | - $this->_views = array( |
|
380 | - 'all' => array( |
|
381 | - 'slug' => 'all', |
|
382 | - 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
383 | - 'count' => 0, |
|
384 | - 'bulk_action' => array( |
|
385 | - 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
386 | - ), |
|
387 | - ), |
|
388 | - ); |
|
389 | - |
|
390 | - if ( |
|
391 | - EE_Registry::instance()->CAP->current_user_can( |
|
392 | - 'ee_delete_questions', |
|
393 | - 'espresso_registration_form_trash_questions' |
|
394 | - ) |
|
395 | - ) { |
|
396 | - $this->_views['trash'] = array( |
|
397 | - 'slug' => 'trash', |
|
398 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
399 | - 'count' => 0, |
|
400 | - 'bulk_action' => array( |
|
401 | - 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
402 | - 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
403 | - ), |
|
404 | - ); |
|
405 | - } |
|
406 | - } |
|
407 | - |
|
408 | - |
|
409 | - /** |
|
410 | - * @return void |
|
411 | - */ |
|
412 | - protected function _set_list_table_views_question_groups() |
|
413 | - { |
|
414 | - $this->_views = array( |
|
415 | - 'all' => array( |
|
416 | - 'slug' => 'all', |
|
417 | - 'label' => esc_html__('All', 'event_espresso'), |
|
418 | - 'count' => 0, |
|
419 | - 'bulk_action' => array( |
|
420 | - 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
421 | - ), |
|
422 | - ), |
|
423 | - ); |
|
424 | - |
|
425 | - if ( |
|
426 | - EE_Registry::instance()->CAP->current_user_can( |
|
427 | - 'ee_delete_question_groups', |
|
428 | - 'espresso_registration_form_trash_question_groups' |
|
429 | - ) |
|
430 | - ) { |
|
431 | - $this->_views['trash'] = array( |
|
432 | - 'slug' => 'trash', |
|
433 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
434 | - 'count' => 0, |
|
435 | - 'bulk_action' => array( |
|
436 | - 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
437 | - 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
438 | - ), |
|
439 | - ); |
|
440 | - } |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * @return void |
|
446 | - * @throws EE_Error |
|
447 | - * @throws InvalidArgumentException |
|
448 | - * @throws InvalidDataTypeException |
|
449 | - * @throws InvalidInterfaceException |
|
450 | - */ |
|
451 | - protected function _questions_overview_list_table() |
|
452 | - { |
|
453 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
454 | - 'add_question', |
|
455 | - 'add_question', |
|
456 | - array(), |
|
457 | - 'add-new-h2' |
|
458 | - ); |
|
459 | - parent::_questions_overview_list_table(); |
|
460 | - } |
|
461 | - |
|
462 | - |
|
463 | - /** |
|
464 | - * @return void |
|
465 | - * @throws DomainException |
|
466 | - * @throws EE_Error |
|
467 | - * @throws InvalidArgumentException |
|
468 | - * @throws InvalidDataTypeException |
|
469 | - * @throws InvalidInterfaceException |
|
470 | - */ |
|
471 | - protected function _question_groups_overview_list_table() |
|
472 | - { |
|
473 | - $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
474 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
475 | - 'add_question_group', |
|
476 | - 'add_question_group', |
|
477 | - array(), |
|
478 | - 'add-new-h2' |
|
479 | - ); |
|
480 | - $this->display_admin_list_table_page_with_sidebar(); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * @return void |
|
486 | - * @throws EE_Error |
|
487 | - * @throws InvalidArgumentException |
|
488 | - * @throws InvalidDataTypeException |
|
489 | - * @throws InvalidInterfaceException |
|
490 | - */ |
|
491 | - protected function _delete_question() |
|
492 | - { |
|
493 | - $success = $this->_delete_items($this->_question_model); |
|
494 | - $this->_redirect_after_action( |
|
495 | - $success, |
|
496 | - $this->_question_model->item_name($success), |
|
497 | - 'deleted', |
|
498 | - array('action' => 'default', 'status' => 'all') |
|
499 | - ); |
|
500 | - } |
|
501 | - |
|
502 | - |
|
503 | - /** |
|
504 | - * @return void |
|
505 | - * @throws EE_Error |
|
506 | - * @throws InvalidArgumentException |
|
507 | - * @throws InvalidDataTypeException |
|
508 | - * @throws InvalidInterfaceException |
|
509 | - */ |
|
510 | - protected function _delete_questions() |
|
511 | - { |
|
512 | - $success = $this->_delete_items($this->_question_model); |
|
513 | - $this->_redirect_after_action( |
|
514 | - $success, |
|
515 | - $this->_question_model->item_name($success), |
|
516 | - 'deleted permanently', |
|
517 | - array('action' => 'default', 'status' => 'trash') |
|
518 | - ); |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - /** |
|
523 | - * Performs the deletion of a single or multiple questions or question groups. |
|
524 | - * |
|
525 | - * @param EEM_Soft_Delete_Base $model |
|
526 | - * @return int number of items deleted permanently |
|
527 | - * @throws EE_Error |
|
528 | - * @throws InvalidArgumentException |
|
529 | - * @throws InvalidDataTypeException |
|
530 | - * @throws InvalidInterfaceException |
|
531 | - */ |
|
532 | - private function _delete_items(EEM_Soft_Delete_Base $model) |
|
533 | - { |
|
534 | - $success = 0; |
|
535 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
536 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
537 | - // if array has more than one element than success message should be plural |
|
538 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
539 | - // cycle thru bulk action checkboxes |
|
540 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
541 | - if (! $this->_delete_item($ID, $model)) { |
|
542 | - $success = 0; |
|
543 | - } |
|
544 | - } |
|
545 | - } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
546 | - $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
547 | - } elseif (! empty($this->_req_data['QST_ID'])) { |
|
548 | - $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
549 | - } else { |
|
550 | - EE_Error::add_error( |
|
551 | - sprintf( |
|
552 | - esc_html__( |
|
553 | - "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
554 | - "event_espresso" |
|
555 | - ) |
|
556 | - ), |
|
557 | - __FILE__, |
|
558 | - __FUNCTION__, |
|
559 | - __LINE__ |
|
560 | - ); |
|
561 | - } |
|
562 | - return $success; |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - /** |
|
567 | - * Deletes the specified question (and its associated question options) or question group |
|
568 | - * |
|
569 | - * @param int $id |
|
570 | - * @param EEM_Soft_Delete_Base $model |
|
571 | - * @return boolean |
|
572 | - * @throws EE_Error |
|
573 | - * @throws InvalidArgumentException |
|
574 | - * @throws InvalidDataTypeException |
|
575 | - * @throws InvalidInterfaceException |
|
576 | - */ |
|
577 | - protected function _delete_item($id, $model) |
|
578 | - { |
|
579 | - if ($model instanceof EEM_Question) { |
|
580 | - EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
581 | - } |
|
582 | - return $model->delete_permanently_by_ID(absint($id)); |
|
583 | - } |
|
584 | - |
|
585 | - |
|
586 | - /****************************** QUESTION GROUPS ******************************/ |
|
587 | - |
|
588 | - |
|
589 | - /** |
|
590 | - * @param string $type |
|
591 | - * @return void |
|
592 | - * @throws DomainException |
|
593 | - * @throws EE_Error |
|
594 | - * @throws InvalidArgumentException |
|
595 | - * @throws InvalidDataTypeException |
|
596 | - * @throws InvalidInterfaceException |
|
597 | - */ |
|
598 | - protected function _edit_question_group($type = 'add') |
|
599 | - { |
|
600 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
601 | - $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
602 | - ? absint($this->_req_data['QSG_ID']) |
|
603 | - : false; |
|
604 | - |
|
605 | - switch ($this->_req_action) { |
|
606 | - case 'add_question_group': |
|
607 | - $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
608 | - break; |
|
609 | - case 'edit_question_group': |
|
610 | - $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
611 | - break; |
|
612 | - default: |
|
613 | - $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
614 | - } |
|
615 | - // add ID to title if editing |
|
616 | - $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
617 | - if ($ID) { |
|
618 | - /** @var EE_Question_Group $questionGroup */ |
|
619 | - $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
620 | - $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
621 | - $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
622 | - } else { |
|
623 | - /** @var EE_Question_Group $questionGroup */ |
|
624 | - $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
625 | - $questionGroup->set_order_to_latest(); |
|
626 | - $this->_set_add_edit_form_tags('insert_question_group'); |
|
627 | - } |
|
628 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
629 | - $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
630 | - $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
631 | - $this->_template_args['question_group'] = $questionGroup; |
|
632 | - |
|
633 | - $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
634 | - $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
635 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
636 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
637 | - $this->_template_args, |
|
638 | - true |
|
639 | - ); |
|
640 | - |
|
641 | - // the details template wrapper |
|
642 | - $this->display_admin_page_with_sidebar(); |
|
643 | - } |
|
644 | - |
|
645 | - |
|
646 | - /** |
|
647 | - * @return void |
|
648 | - * @throws EE_Error |
|
649 | - * @throws InvalidArgumentException |
|
650 | - * @throws InvalidDataTypeException |
|
651 | - * @throws InvalidInterfaceException |
|
652 | - */ |
|
653 | - protected function _delete_question_groups() |
|
654 | - { |
|
655 | - $success = $this->_delete_items($this->_question_group_model); |
|
656 | - $this->_redirect_after_action( |
|
657 | - $success, |
|
658 | - $this->_question_group_model->item_name($success), |
|
659 | - 'deleted permanently', |
|
660 | - array('action' => 'question_groups', 'status' => 'trash') |
|
661 | - ); |
|
662 | - } |
|
663 | - |
|
664 | - |
|
665 | - /** |
|
666 | - * @param bool $new_question_group |
|
667 | - * @throws EE_Error |
|
668 | - * @throws InvalidArgumentException |
|
669 | - * @throws InvalidDataTypeException |
|
670 | - * @throws InvalidInterfaceException |
|
671 | - */ |
|
672 | - protected function _insert_or_update_question_group($new_question_group = true) |
|
673 | - { |
|
674 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
675 | - $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
676 | - |
|
677 | - // make sure identifier is unique |
|
678 | - $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
679 | - $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']]; |
|
680 | - if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
681 | - $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
682 | - } |
|
683 | - $identifier_exists = ! empty($identifier_value) |
|
684 | - ? $this->_question_group_model->count([$where_values]) > 0 |
|
685 | - : false; |
|
686 | - if ($identifier_exists) { |
|
687 | - $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
688 | - } |
|
689 | - |
|
690 | - if ($new_question_group) { |
|
691 | - $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
692 | - $success = $QSG_ID ? 1 : 0; |
|
693 | - if ($success === 0) { |
|
694 | - EE_Error::add_error( |
|
695 | - esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
696 | - __FILE__, |
|
697 | - __FUNCTION__, |
|
698 | - __LINE__ |
|
699 | - ); |
|
700 | - $this->_redirect_after_action( |
|
701 | - false, |
|
702 | - '', |
|
703 | - '', |
|
704 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
705 | - true |
|
706 | - ); |
|
707 | - } |
|
708 | - } else { |
|
709 | - $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
710 | - unset($set_column_values['QSG_ID']); |
|
711 | - $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
712 | - } |
|
713 | - |
|
714 | - $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
715 | - EEM_Attendee::system_question_phone |
|
716 | - ); |
|
717 | - // update the existing related questions |
|
718 | - // BUT FIRST... delete the phone question from the Question_Group_Question |
|
719 | - // if it is being added to this question group (therefore removed from the existing group) |
|
720 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
721 | - // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
722 | - EEM_Question_Group_Question::instance()->delete( |
|
723 | - array( |
|
724 | - array( |
|
725 | - 'QST_ID' => $phone_question_id, |
|
726 | - 'QSG_ID' => array('!=', $QSG_ID), |
|
727 | - ), |
|
728 | - ) |
|
729 | - ); |
|
730 | - } |
|
731 | - /** @type EE_Question_Group $question_group */ |
|
732 | - $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
733 | - $questions = $question_group->questions(); |
|
734 | - // make sure system phone question is added to list of questions for this group |
|
735 | - if (! isset($questions[ $phone_question_id ])) { |
|
736 | - $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
737 | - } |
|
738 | - |
|
739 | - foreach ($questions as $question_ID => $question) { |
|
740 | - // first we always check for order. |
|
741 | - if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
742 | - // update question order |
|
743 | - $question_group->update_question_order( |
|
744 | - $question_ID, |
|
745 | - $this->_req_data['question_orders'][ $question_ID ] |
|
746 | - ); |
|
747 | - } |
|
748 | - |
|
749 | - // then we always check if adding or removing. |
|
750 | - if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
751 | - $question_group->add_question($question_ID); |
|
752 | - } else { |
|
753 | - // not found, remove it (but only if not a system question for the personal group |
|
754 | - // with the exception of lname system question - we allow removal of it) |
|
755 | - if ( |
|
756 | - in_array( |
|
757 | - $question->system_ID(), |
|
758 | - EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
759 | - $question_group->system_group() |
|
760 | - ) |
|
761 | - ) |
|
762 | - ) { |
|
763 | - continue; |
|
764 | - } else { |
|
765 | - $question_group->remove_question($question_ID); |
|
766 | - } |
|
767 | - } |
|
768 | - } |
|
769 | - // save new related questions |
|
770 | - if (isset($this->_req_data['questions'])) { |
|
771 | - foreach ($this->_req_data['questions'] as $QST_ID) { |
|
772 | - $question_group->add_question($QST_ID); |
|
773 | - if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
774 | - $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
775 | - } |
|
776 | - } |
|
777 | - } |
|
778 | - |
|
779 | - if ($success !== false) { |
|
780 | - $msg = $new_question_group |
|
781 | - ? sprintf( |
|
782 | - esc_html__('The %s has been created', 'event_espresso'), |
|
783 | - $this->_question_group_model->item_name() |
|
784 | - ) |
|
785 | - : sprintf( |
|
786 | - esc_html__( |
|
787 | - 'The %s has been updated', |
|
788 | - 'event_espresso' |
|
789 | - ), |
|
790 | - $this->_question_group_model->item_name() |
|
791 | - ); |
|
792 | - EE_Error::add_success($msg); |
|
793 | - } |
|
794 | - $this->_redirect_after_action( |
|
795 | - false, |
|
796 | - '', |
|
797 | - '', |
|
798 | - array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
799 | - true |
|
800 | - ); |
|
801 | - } |
|
802 | - |
|
803 | - |
|
804 | - /** |
|
805 | - * duplicates a question and all its question options and redirects to the new question. |
|
806 | - * |
|
807 | - * @return void |
|
808 | - * @throws EE_Error |
|
809 | - * @throws InvalidArgumentException |
|
810 | - * @throws ReflectionException |
|
811 | - * @throws InvalidDataTypeException |
|
812 | - * @throws InvalidInterfaceException |
|
813 | - */ |
|
814 | - public function _duplicate_question() |
|
815 | - { |
|
816 | - $question_ID = (int) $this->_req_data['QST_ID']; |
|
817 | - $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
818 | - if ($question instanceof EE_Question) { |
|
819 | - $new_question = $question->duplicate(); |
|
820 | - if ($new_question instanceof EE_Question) { |
|
821 | - $this->_redirect_after_action( |
|
822 | - true, |
|
823 | - esc_html__('Question', 'event_espresso'), |
|
824 | - esc_html__('Duplicated', 'event_espresso'), |
|
825 | - array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
826 | - true |
|
827 | - ); |
|
828 | - } else { |
|
829 | - global $wpdb; |
|
830 | - EE_Error::add_error( |
|
831 | - sprintf( |
|
832 | - esc_html__( |
|
833 | - 'Could not duplicate question with ID %1$d because: %2$s', |
|
834 | - 'event_espresso' |
|
835 | - ), |
|
836 | - $question_ID, |
|
837 | - $wpdb->last_error |
|
838 | - ), |
|
839 | - __FILE__, |
|
840 | - __FUNCTION__, |
|
841 | - __LINE__ |
|
842 | - ); |
|
843 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
844 | - } |
|
845 | - } else { |
|
846 | - EE_Error::add_error( |
|
847 | - sprintf( |
|
848 | - esc_html__( |
|
849 | - 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
850 | - 'event_espresso' |
|
851 | - ), |
|
852 | - $question_ID |
|
853 | - ), |
|
854 | - __FILE__, |
|
855 | - __FUNCTION__, |
|
856 | - __LINE__ |
|
857 | - ); |
|
858 | - $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
859 | - } |
|
860 | - } |
|
861 | - |
|
862 | - |
|
863 | - /** |
|
864 | - * @param bool $trash |
|
865 | - * @throws EE_Error |
|
866 | - */ |
|
867 | - protected function _trash_or_restore_question_groups($trash = true) |
|
868 | - { |
|
869 | - $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
870 | - } |
|
871 | - |
|
872 | - |
|
873 | - /** |
|
874 | - *_trash_question |
|
875 | - * |
|
876 | - * @return void |
|
877 | - * @throws EE_Error |
|
878 | - */ |
|
879 | - protected function _trash_question() |
|
880 | - { |
|
881 | - $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
882 | - $query_args = array('action' => 'default', 'status' => 'all'); |
|
883 | - $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
884 | - } |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * @param bool $trash |
|
889 | - * @throws EE_Error |
|
890 | - */ |
|
891 | - protected function _trash_or_restore_questions($trash = true) |
|
892 | - { |
|
893 | - $this->_trash_or_restore_items($this->_question_model, $trash); |
|
894 | - } |
|
895 | - |
|
896 | - |
|
897 | - /** |
|
898 | - * Internally used to delete or restore items, using the request data. Meant to be |
|
899 | - * flexible between question or question groups |
|
900 | - * |
|
901 | - * @param EEM_Soft_Delete_Base $model |
|
902 | - * @param boolean $trash whether to trash or restore |
|
903 | - * @throws EE_Error |
|
904 | - */ |
|
905 | - private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
906 | - { |
|
907 | - |
|
908 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
909 | - |
|
910 | - $success = 1; |
|
911 | - // Checkboxes |
|
912 | - // echo "trash $trash"; |
|
913 | - // var_dump($this->_req_data['checkbox']);die; |
|
914 | - if (isset($this->_req_data['checkbox'])) { |
|
915 | - if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
916 | - // if array has more than one element than success message should be plural |
|
917 | - $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
918 | - // cycle thru bulk action checkboxes |
|
919 | - while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
920 | - if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
921 | - $success = 0; |
|
922 | - } |
|
923 | - } |
|
924 | - } else { |
|
925 | - // grab single id and delete |
|
926 | - $ID = absint($this->_req_data['checkbox']); |
|
927 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
928 | - $success = 0; |
|
929 | - } |
|
930 | - } |
|
931 | - } else { |
|
932 | - // delete via trash link |
|
933 | - // grab single id and delete |
|
934 | - $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
935 | - if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
936 | - $success = 0; |
|
937 | - } |
|
938 | - } |
|
939 | - |
|
940 | - |
|
941 | - $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
942 | - // echo "action :$action"; |
|
943 | - // $action = 'questions' ? 'default' : $action; |
|
944 | - if ($trash) { |
|
945 | - $action_desc = 'trashed'; |
|
946 | - $status = 'trash'; |
|
947 | - } else { |
|
948 | - $action_desc = 'restored'; |
|
949 | - $status = 'all'; |
|
950 | - } |
|
951 | - $this->_redirect_after_action( |
|
952 | - $success, |
|
953 | - $model->item_name($success), |
|
954 | - $action_desc, |
|
955 | - array('action' => $action, 'status' => $status) |
|
956 | - ); |
|
957 | - } |
|
958 | - |
|
959 | - |
|
960 | - /** |
|
961 | - * @param $per_page |
|
962 | - * @param int $current_page |
|
963 | - * @param bool|false $count |
|
964 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
965 | - * @throws EE_Error |
|
966 | - * @throws InvalidArgumentException |
|
967 | - * @throws InvalidDataTypeException |
|
968 | - * @throws InvalidInterfaceException |
|
969 | - */ |
|
970 | - public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
971 | - { |
|
972 | - $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
973 | - |
|
974 | - if ($count) { |
|
975 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
976 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
977 | - $results = $this->_question_model->count_deleted($where); |
|
978 | - } else { |
|
979 | - // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
980 | - $results = $this->_question_model->get_all_deleted($query_params); |
|
981 | - } |
|
982 | - return $results; |
|
983 | - } |
|
984 | - |
|
985 | - |
|
986 | - /** |
|
987 | - * @param $per_page |
|
988 | - * @param int $current_page |
|
989 | - * @param bool|false $count |
|
990 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
991 | - * @throws EE_Error |
|
992 | - * @throws InvalidArgumentException |
|
993 | - * @throws InvalidDataTypeException |
|
994 | - * @throws InvalidInterfaceException |
|
995 | - */ |
|
996 | - public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
997 | - { |
|
998 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
999 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1000 | - if ($count) { |
|
1001 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1002 | - $results = $questionGroupModel->count($where); |
|
1003 | - } else { |
|
1004 | - $results = $questionGroupModel->get_all($query_params); |
|
1005 | - } |
|
1006 | - return $results; |
|
1007 | - } |
|
1008 | - |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * @param $per_page |
|
1012 | - * @param int $current_page |
|
1013 | - * @param bool $count |
|
1014 | - * @return EE_Soft_Delete_Base_Class[]|int |
|
1015 | - * @throws EE_Error |
|
1016 | - * @throws InvalidArgumentException |
|
1017 | - * @throws InvalidDataTypeException |
|
1018 | - * @throws InvalidInterfaceException |
|
1019 | - */ |
|
1020 | - public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1021 | - { |
|
1022 | - $questionGroupModel = EEM_Question_Group::instance(); |
|
1023 | - $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1024 | - if ($count) { |
|
1025 | - $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1026 | - $query_params['limit'] = null; |
|
1027 | - $results = $questionGroupModel->count_deleted($where); |
|
1028 | - } else { |
|
1029 | - $results = $questionGroupModel->get_all_deleted($query_params); |
|
1030 | - } |
|
1031 | - return $results; |
|
1032 | - } |
|
1033 | - |
|
1034 | - |
|
1035 | - /** |
|
1036 | - * method for performing updates to question order |
|
1037 | - * |
|
1038 | - * @return void results array |
|
1039 | - * @throws EE_Error |
|
1040 | - * @throws InvalidArgumentException |
|
1041 | - * @throws InvalidDataTypeException |
|
1042 | - * @throws InvalidInterfaceException |
|
1043 | - */ |
|
1044 | - public function update_question_group_order() |
|
1045 | - { |
|
1046 | - |
|
1047 | - $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1048 | - |
|
1049 | - // grab our row IDs |
|
1050 | - $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1051 | - ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1052 | - : array(); |
|
1053 | - |
|
1054 | - $perpage = ! empty($this->_req_data['perpage']) |
|
1055 | - ? (int) $this->_req_data['perpage'] |
|
1056 | - : null; |
|
1057 | - $curpage = ! empty($this->_req_data['curpage']) |
|
1058 | - ? (int) $this->_req_data['curpage'] |
|
1059 | - : null; |
|
1060 | - |
|
1061 | - if (! empty($row_ids)) { |
|
1062 | - // figure out where we start the row_id count at for the current page. |
|
1063 | - $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1064 | - |
|
1065 | - $row_count = count($row_ids); |
|
1066 | - for ($i = 0; $i < $row_count; $i++) { |
|
1067 | - // Update the questions when re-ordering |
|
1068 | - $updated = EEM_Question_Group::instance()->update( |
|
1069 | - array('QSG_order' => $qsgcount), |
|
1070 | - array(array('QSG_ID' => $row_ids[ $i ])) |
|
1071 | - ); |
|
1072 | - if ($updated === false) { |
|
1073 | - $success = false; |
|
1074 | - } |
|
1075 | - $qsgcount++; |
|
1076 | - } |
|
1077 | - } else { |
|
1078 | - $success = false; |
|
1079 | - } |
|
1080 | - |
|
1081 | - $errors = ! $success |
|
1082 | - ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1083 | - : false; |
|
1084 | - |
|
1085 | - echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1086 | - die(); |
|
1087 | - } |
|
1088 | - |
|
1089 | - |
|
1090 | - |
|
1091 | - /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1092 | - |
|
1093 | - |
|
1094 | - /** |
|
1095 | - * @throws DomainException |
|
1096 | - * @throws EE_Error |
|
1097 | - * @throws InvalidArgumentException |
|
1098 | - * @throws InvalidDataTypeException |
|
1099 | - * @throws InvalidInterfaceException |
|
1100 | - */ |
|
1101 | - protected function _reg_form_settings() |
|
1102 | - { |
|
1103 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
1104 | - add_action( |
|
1105 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1106 | - array($this, 'email_validation_settings_form'), |
|
1107 | - 2 |
|
1108 | - ); |
|
1109 | - add_action( |
|
1110 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1111 | - array($this, 'copy_attendee_info_settings_form'), |
|
1112 | - 4 |
|
1113 | - ); |
|
1114 | - add_action( |
|
1115 | - 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1116 | - array($this, 'setSessionLifespan'), |
|
1117 | - 4.9 |
|
1118 | - ); |
|
1119 | - $this->_template_args = (array) apply_filters( |
|
1120 | - 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1121 | - $this->_template_args |
|
1122 | - ); |
|
1123 | - $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1124 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1125 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1126 | - REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1127 | - $this->_template_args, |
|
1128 | - true |
|
1129 | - ); |
|
1130 | - $this->display_admin_page_with_sidebar(); |
|
1131 | - } |
|
1132 | - |
|
1133 | - |
|
1134 | - /** |
|
1135 | - * @return void |
|
1136 | - * @throws EE_Error |
|
1137 | - * @throws InvalidArgumentException |
|
1138 | - * @throws ReflectionException |
|
1139 | - * @throws InvalidDataTypeException |
|
1140 | - * @throws InvalidInterfaceException |
|
1141 | - */ |
|
1142 | - protected function _update_reg_form_settings() |
|
1143 | - { |
|
1144 | - EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1145 | - EE_Registry::instance()->CFG->registration |
|
1146 | - ); |
|
1147 | - EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1148 | - EE_Registry::instance()->CFG->registration |
|
1149 | - ); |
|
1150 | - $this->updateSessionLifespan(); |
|
1151 | - EE_Registry::instance()->CFG->registration = apply_filters( |
|
1152 | - 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1153 | - EE_Registry::instance()->CFG->registration |
|
1154 | - ); |
|
1155 | - $success = $this->_update_espresso_configuration( |
|
1156 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1157 | - EE_Registry::instance()->CFG, |
|
1158 | - __FILE__, |
|
1159 | - __FUNCTION__, |
|
1160 | - __LINE__ |
|
1161 | - ); |
|
1162 | - $this->_redirect_after_action( |
|
1163 | - $success, |
|
1164 | - esc_html__('Registration Form Options', 'event_espresso'), |
|
1165 | - 'updated', |
|
1166 | - array('action' => 'view_reg_form_settings') |
|
1167 | - ); |
|
1168 | - } |
|
1169 | - |
|
1170 | - |
|
1171 | - /** |
|
1172 | - * @return void |
|
1173 | - * @throws EE_Error |
|
1174 | - * @throws InvalidArgumentException |
|
1175 | - * @throws InvalidDataTypeException |
|
1176 | - * @throws InvalidInterfaceException |
|
1177 | - */ |
|
1178 | - public function copy_attendee_info_settings_form() |
|
1179 | - { |
|
1180 | - echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1181 | - } |
|
1182 | - |
|
1183 | - /** |
|
1184 | - * _copy_attendee_info_settings_form |
|
1185 | - * |
|
1186 | - * @access protected |
|
1187 | - * @return EE_Form_Section_Proper |
|
1188 | - * @throws \EE_Error |
|
1189 | - */ |
|
1190 | - protected function _copy_attendee_info_settings_form() |
|
1191 | - { |
|
1192 | - return new EE_Form_Section_Proper( |
|
1193 | - array( |
|
1194 | - 'name' => 'copy_attendee_info_settings', |
|
1195 | - 'html_id' => 'copy_attendee_info_settings', |
|
1196 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1197 | - 'subsections' => apply_filters( |
|
1198 | - 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1199 | - array( |
|
1200 | - 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1201 | - EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1202 | - ), |
|
1203 | - 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1204 | - array( |
|
1205 | - 'html_label_text' => esc_html__( |
|
1206 | - 'Allow copy #1 attendee info to extra attendees?', |
|
1207 | - 'event_espresso' |
|
1208 | - ), |
|
1209 | - 'html_help_text' => esc_html__( |
|
1210 | - 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1211 | - 'event_espresso' |
|
1212 | - ), |
|
1213 | - 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1214 | - 'required' => false, |
|
1215 | - 'display_html_label_text' => false, |
|
1216 | - ) |
|
1217 | - ), |
|
1218 | - ) |
|
1219 | - ), |
|
1220 | - ) |
|
1221 | - ); |
|
1222 | - } |
|
1223 | - |
|
1224 | - /** |
|
1225 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1226 | - * @return EE_Registration_Config |
|
1227 | - * @throws EE_Error |
|
1228 | - * @throws InvalidArgumentException |
|
1229 | - * @throws ReflectionException |
|
1230 | - * @throws InvalidDataTypeException |
|
1231 | - * @throws InvalidInterfaceException |
|
1232 | - */ |
|
1233 | - public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1234 | - { |
|
1235 | - $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1236 | - try { |
|
1237 | - $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1238 | - // if not displaying a form, then check for form submission |
|
1239 | - if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1240 | - // capture form data |
|
1241 | - $copy_attendee_info_settings_form->receive_form_submission(); |
|
1242 | - // validate form data |
|
1243 | - if ($copy_attendee_info_settings_form->is_valid()) { |
|
1244 | - // grab validated data from form |
|
1245 | - $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1246 | - if (isset($valid_data['copy_attendee_info'])) { |
|
1247 | - $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1248 | - } else { |
|
1249 | - EE_Error::add_error( |
|
1250 | - esc_html__( |
|
1251 | - 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1252 | - 'event_espresso' |
|
1253 | - ), |
|
1254 | - __FILE__, |
|
1255 | - __FUNCTION__, |
|
1256 | - __LINE__ |
|
1257 | - ); |
|
1258 | - } |
|
1259 | - } elseif ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1260 | - EE_Error::add_error( |
|
1261 | - $copy_attendee_info_settings_form->submission_error_message(), |
|
1262 | - __FILE__, |
|
1263 | - __FUNCTION__, |
|
1264 | - __LINE__ |
|
1265 | - ); |
|
1266 | - } |
|
1267 | - } |
|
1268 | - } catch (EE_Error $e) { |
|
1269 | - $e->get_error(); |
|
1270 | - } |
|
1271 | - return $EE_Registration_Config; |
|
1272 | - } |
|
1273 | - |
|
1274 | - |
|
1275 | - /** |
|
1276 | - * @return void |
|
1277 | - * @throws EE_Error |
|
1278 | - * @throws InvalidArgumentException |
|
1279 | - * @throws InvalidDataTypeException |
|
1280 | - * @throws InvalidInterfaceException |
|
1281 | - */ |
|
1282 | - public function email_validation_settings_form() |
|
1283 | - { |
|
1284 | - echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1285 | - } |
|
1286 | - |
|
1287 | - |
|
1288 | - /** |
|
1289 | - * _email_validation_settings_form |
|
1290 | - * |
|
1291 | - * @access protected |
|
1292 | - * @return EE_Form_Section_Proper |
|
1293 | - * @throws \EE_Error |
|
1294 | - */ |
|
1295 | - protected function _email_validation_settings_form() |
|
1296 | - { |
|
1297 | - return new EE_Form_Section_Proper( |
|
1298 | - array( |
|
1299 | - 'name' => 'email_validation_settings', |
|
1300 | - 'html_id' => 'email_validation_settings', |
|
1301 | - 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1302 | - 'subsections' => apply_filters( |
|
1303 | - 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1304 | - array( |
|
1305 | - 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1306 | - EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1307 | - ), |
|
1308 | - 'email_validation_level' => new EE_Select_Input( |
|
1309 | - array( |
|
1310 | - 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1311 | - 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1312 | - 'i18n' => esc_html__('International', 'event_espresso'), |
|
1313 | - 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1314 | - ), |
|
1315 | - array( |
|
1316 | - 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1317 | - . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1318 | - 'html_help_text' => esc_html__( |
|
1319 | - 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1320 | - 'event_espresso' |
|
1321 | - ), |
|
1322 | - 'default' => isset( |
|
1323 | - EE_Registry::instance()->CFG->registration->email_validation_level |
|
1324 | - ) |
|
1325 | - ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1326 | - : 'wp_default', |
|
1327 | - 'required' => false, |
|
1328 | - ) |
|
1329 | - ), |
|
1330 | - ) |
|
1331 | - ), |
|
1332 | - ) |
|
1333 | - ); |
|
1334 | - } |
|
1335 | - |
|
1336 | - |
|
1337 | - /** |
|
1338 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1339 | - * @return EE_Registration_Config |
|
1340 | - * @throws EE_Error |
|
1341 | - * @throws InvalidArgumentException |
|
1342 | - * @throws ReflectionException |
|
1343 | - * @throws InvalidDataTypeException |
|
1344 | - * @throws InvalidInterfaceException |
|
1345 | - */ |
|
1346 | - public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1347 | - { |
|
1348 | - $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1349 | - try { |
|
1350 | - $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1351 | - // if not displaying a form, then check for form submission |
|
1352 | - if ($email_validation_settings_form->was_submitted()) { |
|
1353 | - // capture form data |
|
1354 | - $email_validation_settings_form->receive_form_submission(); |
|
1355 | - // validate form data |
|
1356 | - if ($email_validation_settings_form->is_valid()) { |
|
1357 | - // grab validated data from form |
|
1358 | - $valid_data = $email_validation_settings_form->valid_data(); |
|
1359 | - if (isset($valid_data['email_validation_level'])) { |
|
1360 | - $email_validation_level = $valid_data['email_validation_level']; |
|
1361 | - // now if they want to use international email addresses |
|
1362 | - if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1363 | - // in case we need to reset their email validation level, |
|
1364 | - // make sure that the previous value wasn't already set to one of the i18n options. |
|
1365 | - if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1366 | - // if so, then reset it back to "basic" since that is the only other option that, |
|
1367 | - // despite offering poor validation, supports i18n email addresses |
|
1368 | - $prev_email_validation_level = 'basic'; |
|
1369 | - } |
|
1370 | - // confirm our i18n email validation will work on the server |
|
1371 | - if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1372 | - // or reset email validation level to previous value |
|
1373 | - $email_validation_level = $prev_email_validation_level; |
|
1374 | - } |
|
1375 | - } |
|
1376 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1377 | - } else { |
|
1378 | - EE_Error::add_error( |
|
1379 | - esc_html__( |
|
1380 | - 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1381 | - 'event_espresso' |
|
1382 | - ), |
|
1383 | - __FILE__, |
|
1384 | - __FUNCTION__, |
|
1385 | - __LINE__ |
|
1386 | - ); |
|
1387 | - } |
|
1388 | - } elseif ($email_validation_settings_form->submission_error_message() !== '') { |
|
1389 | - EE_Error::add_error( |
|
1390 | - $email_validation_settings_form->submission_error_message(), |
|
1391 | - __FILE__, |
|
1392 | - __FUNCTION__, |
|
1393 | - __LINE__ |
|
1394 | - ); |
|
1395 | - } |
|
1396 | - } |
|
1397 | - } catch (EE_Error $e) { |
|
1398 | - $e->get_error(); |
|
1399 | - } |
|
1400 | - return $EE_Registration_Config; |
|
1401 | - } |
|
1402 | - |
|
1403 | - |
|
1404 | - /** |
|
1405 | - * confirms that the server's PHP version has the PCRE module enabled, |
|
1406 | - * and that the PCRE version works with our i18n email validation |
|
1407 | - * |
|
1408 | - * @param EE_Registration_Config $EE_Registration_Config |
|
1409 | - * @param string $email_validation_level |
|
1410 | - * @return bool |
|
1411 | - */ |
|
1412 | - private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1413 | - { |
|
1414 | - // first check that PCRE is enabled |
|
1415 | - if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1416 | - EE_Error::add_error( |
|
1417 | - sprintf( |
|
1418 | - esc_html__( |
|
1419 | - 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1420 | - 'event_espresso' |
|
1421 | - ), |
|
1422 | - '<br />' |
|
1423 | - ), |
|
1424 | - __FILE__, |
|
1425 | - __FUNCTION__, |
|
1426 | - __LINE__ |
|
1427 | - ); |
|
1428 | - return false; |
|
1429 | - } else { |
|
1430 | - // PCRE support is enabled, but let's still |
|
1431 | - // perform a test to see if the server will support it. |
|
1432 | - // but first, save the updated validation level to the config, |
|
1433 | - // so that the validation strategy picks it up. |
|
1434 | - // this will get bumped back down if it doesn't work |
|
1435 | - $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1436 | - try { |
|
1437 | - $email_validator = new EE_Email_Validation_Strategy(); |
|
1438 | - $i18n_email_address = apply_filters( |
|
1439 | - 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1440 | - 'jägerjü[email protected]' |
|
1441 | - ); |
|
1442 | - $email_validator->validate($i18n_email_address); |
|
1443 | - } catch (Exception $e) { |
|
1444 | - EE_Error::add_error( |
|
1445 | - sprintf( |
|
1446 | - esc_html__( |
|
1447 | - 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1448 | - 'event_espresso' |
|
1449 | - ), |
|
1450 | - '<br />', |
|
1451 | - '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1452 | - ), |
|
1453 | - __FILE__, |
|
1454 | - __FUNCTION__, |
|
1455 | - __LINE__ |
|
1456 | - ); |
|
1457 | - return false; |
|
1458 | - } |
|
1459 | - } |
|
1460 | - return true; |
|
1461 | - } |
|
1462 | - |
|
1463 | - |
|
1464 | - public function setSessionLifespan() |
|
1465 | - { |
|
1466 | - $session_lifespan_form = $this->loader->getNew(SessionLifespanForm::class); |
|
1467 | - echo wp_kses($session_lifespan_form->get_html(), AllowedTags::getWithFormTags()); |
|
1468 | - } |
|
1469 | - |
|
1470 | - |
|
1471 | - public function updateSessionLifespan() |
|
1472 | - { |
|
1473 | - $handler = $this->loader->getNew(SessionLifespanFormHandler::class); |
|
1474 | - $handler->process($this->loader->getNew(SessionLifespanForm::class)); |
|
1475 | - } |
|
20 | + /** |
|
21 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
22 | + */ |
|
23 | + public function __construct($routing = true) |
|
24 | + { |
|
25 | + define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form/'); |
|
26 | + define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets/'); |
|
27 | + define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/'); |
|
28 | + define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates/'); |
|
29 | + define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/'); |
|
30 | + parent::__construct($routing); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * @return void |
|
36 | + */ |
|
37 | + protected function _extend_page_config() |
|
38 | + { |
|
39 | + $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN; |
|
40 | + $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) |
|
41 | + ? $this->_req_data['QST_ID'] : 0; |
|
42 | + $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) |
|
43 | + ? $this->_req_data['QSG_ID'] : 0; |
|
44 | + |
|
45 | + $new_page_routes = array( |
|
46 | + 'question_groups' => array( |
|
47 | + 'func' => '_question_groups_overview_list_table', |
|
48 | + 'capability' => 'ee_read_question_groups', |
|
49 | + ), |
|
50 | + 'add_question' => array( |
|
51 | + 'func' => '_edit_question', |
|
52 | + 'capability' => 'ee_edit_questions', |
|
53 | + ), |
|
54 | + 'insert_question' => array( |
|
55 | + 'func' => '_insert_or_update_question', |
|
56 | + 'args' => array('new_question' => true), |
|
57 | + 'capability' => 'ee_edit_questions', |
|
58 | + 'noheader' => true, |
|
59 | + ), |
|
60 | + 'duplicate_question' => array( |
|
61 | + 'func' => '_duplicate_question', |
|
62 | + 'capability' => 'ee_edit_questions', |
|
63 | + 'noheader' => true, |
|
64 | + ), |
|
65 | + 'trash_question' => array( |
|
66 | + 'func' => '_trash_question', |
|
67 | + 'capability' => 'ee_delete_question', |
|
68 | + 'obj_id' => $qst_id, |
|
69 | + 'noheader' => true, |
|
70 | + ), |
|
71 | + |
|
72 | + 'restore_question' => array( |
|
73 | + 'func' => '_trash_or_restore_questions', |
|
74 | + 'capability' => 'ee_delete_question', |
|
75 | + 'obj_id' => $qst_id, |
|
76 | + 'args' => array('trash' => false), |
|
77 | + 'noheader' => true, |
|
78 | + ), |
|
79 | + |
|
80 | + 'delete_question' => array( |
|
81 | + 'func' => '_delete_question', |
|
82 | + 'capability' => 'ee_delete_question', |
|
83 | + 'obj_id' => $qst_id, |
|
84 | + 'noheader' => true, |
|
85 | + ), |
|
86 | + |
|
87 | + 'trash_questions' => array( |
|
88 | + 'func' => '_trash_or_restore_questions', |
|
89 | + 'capability' => 'ee_delete_questions', |
|
90 | + 'args' => array('trash' => true), |
|
91 | + 'noheader' => true, |
|
92 | + ), |
|
93 | + |
|
94 | + 'restore_questions' => array( |
|
95 | + 'func' => '_trash_or_restore_questions', |
|
96 | + 'capability' => 'ee_delete_questions', |
|
97 | + 'args' => array('trash' => false), |
|
98 | + 'noheader' => true, |
|
99 | + ), |
|
100 | + |
|
101 | + 'delete_questions' => array( |
|
102 | + 'func' => '_delete_questions', |
|
103 | + 'args' => array(), |
|
104 | + 'capability' => 'ee_delete_questions', |
|
105 | + 'noheader' => true, |
|
106 | + ), |
|
107 | + |
|
108 | + 'add_question_group' => array( |
|
109 | + 'func' => '_edit_question_group', |
|
110 | + 'capability' => 'ee_edit_question_groups', |
|
111 | + ), |
|
112 | + |
|
113 | + 'edit_question_group' => array( |
|
114 | + 'func' => '_edit_question_group', |
|
115 | + 'capability' => 'ee_edit_question_group', |
|
116 | + 'obj_id' => $qsg_id, |
|
117 | + 'args' => array('edit'), |
|
118 | + ), |
|
119 | + |
|
120 | + 'delete_question_groups' => array( |
|
121 | + 'func' => '_delete_question_groups', |
|
122 | + 'capability' => 'ee_delete_question_groups', |
|
123 | + 'noheader' => true, |
|
124 | + ), |
|
125 | + |
|
126 | + 'delete_question_group' => array( |
|
127 | + 'func' => '_delete_question_groups', |
|
128 | + 'capability' => 'ee_delete_question_group', |
|
129 | + 'obj_id' => $qsg_id, |
|
130 | + 'noheader' => true, |
|
131 | + ), |
|
132 | + |
|
133 | + 'trash_question_group' => array( |
|
134 | + 'func' => '_trash_or_restore_question_groups', |
|
135 | + 'args' => array('trash' => true), |
|
136 | + 'capability' => 'ee_delete_question_group', |
|
137 | + 'obj_id' => $qsg_id, |
|
138 | + 'noheader' => true, |
|
139 | + ), |
|
140 | + |
|
141 | + 'restore_question_group' => array( |
|
142 | + 'func' => '_trash_or_restore_question_groups', |
|
143 | + 'args' => array('trash' => false), |
|
144 | + 'capability' => 'ee_delete_question_group', |
|
145 | + 'obj_id' => $qsg_id, |
|
146 | + 'noheader' => true, |
|
147 | + ), |
|
148 | + |
|
149 | + 'insert_question_group' => array( |
|
150 | + 'func' => '_insert_or_update_question_group', |
|
151 | + 'args' => array('new_question_group' => true), |
|
152 | + 'capability' => 'ee_edit_question_groups', |
|
153 | + 'noheader' => true, |
|
154 | + ), |
|
155 | + |
|
156 | + 'update_question_group' => array( |
|
157 | + 'func' => '_insert_or_update_question_group', |
|
158 | + 'args' => array('new_question_group' => false), |
|
159 | + 'capability' => 'ee_edit_question_group', |
|
160 | + 'obj_id' => $qsg_id, |
|
161 | + 'noheader' => true, |
|
162 | + ), |
|
163 | + |
|
164 | + 'trash_question_groups' => array( |
|
165 | + 'func' => '_trash_or_restore_question_groups', |
|
166 | + 'args' => array('trash' => true), |
|
167 | + 'capability' => 'ee_delete_question_groups', |
|
168 | + 'noheader' => array('trash' => false), |
|
169 | + ), |
|
170 | + |
|
171 | + 'restore_question_groups' => array( |
|
172 | + 'func' => '_trash_or_restore_question_groups', |
|
173 | + 'args' => array('trash' => false), |
|
174 | + 'capability' => 'ee_delete_question_groups', |
|
175 | + 'noheader' => true, |
|
176 | + ), |
|
177 | + |
|
178 | + |
|
179 | + 'espresso_update_question_group_order' => array( |
|
180 | + 'func' => 'update_question_group_order', |
|
181 | + 'capability' => 'ee_edit_question_groups', |
|
182 | + 'noheader' => true, |
|
183 | + ), |
|
184 | + |
|
185 | + 'view_reg_form_settings' => array( |
|
186 | + 'func' => '_reg_form_settings', |
|
187 | + 'capability' => 'manage_options', |
|
188 | + ), |
|
189 | + |
|
190 | + 'update_reg_form_settings' => array( |
|
191 | + 'func' => '_update_reg_form_settings', |
|
192 | + 'capability' => 'manage_options', |
|
193 | + 'noheader' => true, |
|
194 | + ), |
|
195 | + ); |
|
196 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
197 | + |
|
198 | + $new_page_config = array( |
|
199 | + |
|
200 | + 'question_groups' => array( |
|
201 | + 'nav' => array( |
|
202 | + 'label' => esc_html__('Question Groups', 'event_espresso'), |
|
203 | + 'icon' => 'dashicons-forms', |
|
204 | + 'order' => 20, |
|
205 | + ), |
|
206 | + 'list_table' => 'Registration_Form_Question_Groups_Admin_List_Table', |
|
207 | + 'help_tabs' => array( |
|
208 | + 'registration_form_question_groups_help_tab' => array( |
|
209 | + 'title' => esc_html__('Question Groups', 'event_espresso'), |
|
210 | + 'filename' => 'registration_form_question_groups', |
|
211 | + ), |
|
212 | + 'registration_form_question_groups_table_column_headings_help_tab' => array( |
|
213 | + 'title' => esc_html__('Question Groups Table Column Headings', 'event_espresso'), |
|
214 | + 'filename' => 'registration_form_question_groups_table_column_headings', |
|
215 | + ), |
|
216 | + 'registration_form_question_groups_views_bulk_actions_search_help_tab' => array( |
|
217 | + 'title' => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'), |
|
218 | + 'filename' => 'registration_form_question_groups_views_bulk_actions_search', |
|
219 | + ), |
|
220 | + ), |
|
221 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
222 | + 'require_nonce' => false, |
|
223 | + ), |
|
224 | + |
|
225 | + 'add_question' => array( |
|
226 | + 'nav' => array( |
|
227 | + 'label' => esc_html__('Add Question', 'event_espresso'), |
|
228 | + 'icon' => 'dashicons-plus-alt', |
|
229 | + 'order' => 15, |
|
230 | + 'persistent' => false, |
|
231 | + ), |
|
232 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
233 | + 'help_tabs' => array( |
|
234 | + 'registration_form_add_question_help_tab' => array( |
|
235 | + 'title' => esc_html__('Add Question', 'event_espresso'), |
|
236 | + 'filename' => 'registration_form_add_question', |
|
237 | + ), |
|
238 | + ), |
|
239 | + 'require_nonce' => false, |
|
240 | + ), |
|
241 | + |
|
242 | + 'add_question_group' => array( |
|
243 | + 'nav' => array( |
|
244 | + 'label' => esc_html__('Add Question Group', 'event_espresso'), |
|
245 | + 'icon' => 'dashicons-plus-alt', |
|
246 | + 'order' => 25, |
|
247 | + 'persistent' => false, |
|
248 | + ), |
|
249 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
250 | + 'help_tabs' => array( |
|
251 | + 'registration_form_add_question_group_help_tab' => array( |
|
252 | + 'title' => esc_html__('Add Question Group', 'event_espresso'), |
|
253 | + 'filename' => 'registration_form_add_question_group', |
|
254 | + ), |
|
255 | + ), |
|
256 | + 'require_nonce' => false, |
|
257 | + ), |
|
258 | + |
|
259 | + 'edit_question_group' => array( |
|
260 | + 'nav' => array( |
|
261 | + 'label' => esc_html__('Edit Question Group', 'event_espresso'), |
|
262 | + 'icon' => 'dashicons-edit-large', |
|
263 | + 'order' => 25, |
|
264 | + 'persistent' => false, |
|
265 | + 'url' => isset($this->_req_data['question_group_id']) ? add_query_arg( |
|
266 | + array('question_group_id' => $this->_req_data['question_group_id']), |
|
267 | + $this->_current_page_view_url |
|
268 | + ) : $this->_admin_base_url, |
|
269 | + ), |
|
270 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
271 | + 'help_tabs' => array( |
|
272 | + 'registration_form_edit_question_group_help_tab' => array( |
|
273 | + 'title' => esc_html__('Edit Question Group', 'event_espresso'), |
|
274 | + 'filename' => 'registration_form_edit_question_group', |
|
275 | + ), |
|
276 | + ), |
|
277 | + 'require_nonce' => false, |
|
278 | + ), |
|
279 | + |
|
280 | + 'view_reg_form_settings' => array( |
|
281 | + 'nav' => array( |
|
282 | + 'label' => esc_html__('Reg Form Settings', 'event_espresso'), |
|
283 | + 'icon' => 'dashicons-admin-generic', |
|
284 | + 'order' => 40, |
|
285 | + ), |
|
286 | + 'labels' => array( |
|
287 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
288 | + ), |
|
289 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
290 | + 'help_tabs' => array( |
|
291 | + 'registration_form_reg_form_settings_help_tab' => array( |
|
292 | + 'title' => esc_html__('Registration Form Settings', 'event_espresso'), |
|
293 | + 'filename' => 'registration_form_reg_form_settings', |
|
294 | + ), |
|
295 | + ), |
|
296 | + 'require_nonce' => false, |
|
297 | + ), |
|
298 | + |
|
299 | + ); |
|
300 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
301 | + |
|
302 | + // change the list table we're going to use so it's the NEW list table! |
|
303 | + $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table'; |
|
304 | + |
|
305 | + |
|
306 | + // additional labels |
|
307 | + $new_labels = array( |
|
308 | + 'add_question' => esc_html__('Add New Question', 'event_espresso'), |
|
309 | + 'delete_question' => esc_html__('Delete Question', 'event_espresso'), |
|
310 | + 'add_question_group' => esc_html__('Add New Question Group', 'event_espresso'), |
|
311 | + 'edit_question_group' => esc_html__('Edit Question Group', 'event_espresso'), |
|
312 | + 'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'), |
|
313 | + ); |
|
314 | + $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels); |
|
315 | + } |
|
316 | + |
|
317 | + |
|
318 | + /** |
|
319 | + * @return void |
|
320 | + */ |
|
321 | + protected function _ajax_hooks() |
|
322 | + { |
|
323 | + add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order')); |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * @return void |
|
329 | + */ |
|
330 | + public function load_scripts_styles_question_groups() |
|
331 | + { |
|
332 | + wp_enqueue_script('espresso_ajax_table_sorting'); |
|
333 | + } |
|
334 | + |
|
335 | + |
|
336 | + /** |
|
337 | + * @return void |
|
338 | + */ |
|
339 | + public function load_scripts_styles_add_question_group() |
|
340 | + { |
|
341 | + $this->load_scripts_styles_forms(); |
|
342 | + $this->load_sortable_question_script(); |
|
343 | + } |
|
344 | + |
|
345 | + |
|
346 | + /** |
|
347 | + * @return void |
|
348 | + */ |
|
349 | + public function load_scripts_styles_edit_question_group() |
|
350 | + { |
|
351 | + $this->load_scripts_styles_forms(); |
|
352 | + $this->load_sortable_question_script(); |
|
353 | + } |
|
354 | + |
|
355 | + |
|
356 | + /** |
|
357 | + * registers and enqueues script for questions |
|
358 | + * |
|
359 | + * @return void |
|
360 | + */ |
|
361 | + public function load_sortable_question_script() |
|
362 | + { |
|
363 | + wp_register_script( |
|
364 | + 'ee-question-sortable', |
|
365 | + REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js', |
|
366 | + array('jquery-ui-sortable'), |
|
367 | + EVENT_ESPRESSO_VERSION, |
|
368 | + true |
|
369 | + ); |
|
370 | + wp_enqueue_script('ee-question-sortable'); |
|
371 | + } |
|
372 | + |
|
373 | + |
|
374 | + /** |
|
375 | + * @return void |
|
376 | + */ |
|
377 | + protected function _set_list_table_views_default() |
|
378 | + { |
|
379 | + $this->_views = array( |
|
380 | + 'all' => array( |
|
381 | + 'slug' => 'all', |
|
382 | + 'label' => esc_html__('View All Questions', 'event_espresso'), |
|
383 | + 'count' => 0, |
|
384 | + 'bulk_action' => array( |
|
385 | + 'trash_questions' => esc_html__('Trash', 'event_espresso'), |
|
386 | + ), |
|
387 | + ), |
|
388 | + ); |
|
389 | + |
|
390 | + if ( |
|
391 | + EE_Registry::instance()->CAP->current_user_can( |
|
392 | + 'ee_delete_questions', |
|
393 | + 'espresso_registration_form_trash_questions' |
|
394 | + ) |
|
395 | + ) { |
|
396 | + $this->_views['trash'] = array( |
|
397 | + 'slug' => 'trash', |
|
398 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
399 | + 'count' => 0, |
|
400 | + 'bulk_action' => array( |
|
401 | + 'delete_questions' => esc_html__('Delete Permanently', 'event_espresso'), |
|
402 | + 'restore_questions' => esc_html__('Restore', 'event_espresso'), |
|
403 | + ), |
|
404 | + ); |
|
405 | + } |
|
406 | + } |
|
407 | + |
|
408 | + |
|
409 | + /** |
|
410 | + * @return void |
|
411 | + */ |
|
412 | + protected function _set_list_table_views_question_groups() |
|
413 | + { |
|
414 | + $this->_views = array( |
|
415 | + 'all' => array( |
|
416 | + 'slug' => 'all', |
|
417 | + 'label' => esc_html__('All', 'event_espresso'), |
|
418 | + 'count' => 0, |
|
419 | + 'bulk_action' => array( |
|
420 | + 'trash_question_groups' => esc_html__('Trash', 'event_espresso'), |
|
421 | + ), |
|
422 | + ), |
|
423 | + ); |
|
424 | + |
|
425 | + if ( |
|
426 | + EE_Registry::instance()->CAP->current_user_can( |
|
427 | + 'ee_delete_question_groups', |
|
428 | + 'espresso_registration_form_trash_question_groups' |
|
429 | + ) |
|
430 | + ) { |
|
431 | + $this->_views['trash'] = array( |
|
432 | + 'slug' => 'trash', |
|
433 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
434 | + 'count' => 0, |
|
435 | + 'bulk_action' => array( |
|
436 | + 'delete_question_groups' => esc_html__('Delete Permanently', 'event_espresso'), |
|
437 | + 'restore_question_groups' => esc_html__('Restore', 'event_espresso'), |
|
438 | + ), |
|
439 | + ); |
|
440 | + } |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * @return void |
|
446 | + * @throws EE_Error |
|
447 | + * @throws InvalidArgumentException |
|
448 | + * @throws InvalidDataTypeException |
|
449 | + * @throws InvalidInterfaceException |
|
450 | + */ |
|
451 | + protected function _questions_overview_list_table() |
|
452 | + { |
|
453 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
454 | + 'add_question', |
|
455 | + 'add_question', |
|
456 | + array(), |
|
457 | + 'add-new-h2' |
|
458 | + ); |
|
459 | + parent::_questions_overview_list_table(); |
|
460 | + } |
|
461 | + |
|
462 | + |
|
463 | + /** |
|
464 | + * @return void |
|
465 | + * @throws DomainException |
|
466 | + * @throws EE_Error |
|
467 | + * @throws InvalidArgumentException |
|
468 | + * @throws InvalidDataTypeException |
|
469 | + * @throws InvalidInterfaceException |
|
470 | + */ |
|
471 | + protected function _question_groups_overview_list_table() |
|
472 | + { |
|
473 | + $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso'); |
|
474 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
475 | + 'add_question_group', |
|
476 | + 'add_question_group', |
|
477 | + array(), |
|
478 | + 'add-new-h2' |
|
479 | + ); |
|
480 | + $this->display_admin_list_table_page_with_sidebar(); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * @return void |
|
486 | + * @throws EE_Error |
|
487 | + * @throws InvalidArgumentException |
|
488 | + * @throws InvalidDataTypeException |
|
489 | + * @throws InvalidInterfaceException |
|
490 | + */ |
|
491 | + protected function _delete_question() |
|
492 | + { |
|
493 | + $success = $this->_delete_items($this->_question_model); |
|
494 | + $this->_redirect_after_action( |
|
495 | + $success, |
|
496 | + $this->_question_model->item_name($success), |
|
497 | + 'deleted', |
|
498 | + array('action' => 'default', 'status' => 'all') |
|
499 | + ); |
|
500 | + } |
|
501 | + |
|
502 | + |
|
503 | + /** |
|
504 | + * @return void |
|
505 | + * @throws EE_Error |
|
506 | + * @throws InvalidArgumentException |
|
507 | + * @throws InvalidDataTypeException |
|
508 | + * @throws InvalidInterfaceException |
|
509 | + */ |
|
510 | + protected function _delete_questions() |
|
511 | + { |
|
512 | + $success = $this->_delete_items($this->_question_model); |
|
513 | + $this->_redirect_after_action( |
|
514 | + $success, |
|
515 | + $this->_question_model->item_name($success), |
|
516 | + 'deleted permanently', |
|
517 | + array('action' => 'default', 'status' => 'trash') |
|
518 | + ); |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + /** |
|
523 | + * Performs the deletion of a single or multiple questions or question groups. |
|
524 | + * |
|
525 | + * @param EEM_Soft_Delete_Base $model |
|
526 | + * @return int number of items deleted permanently |
|
527 | + * @throws EE_Error |
|
528 | + * @throws InvalidArgumentException |
|
529 | + * @throws InvalidDataTypeException |
|
530 | + * @throws InvalidInterfaceException |
|
531 | + */ |
|
532 | + private function _delete_items(EEM_Soft_Delete_Base $model) |
|
533 | + { |
|
534 | + $success = 0; |
|
535 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
536 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
537 | + // if array has more than one element than success message should be plural |
|
538 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
539 | + // cycle thru bulk action checkboxes |
|
540 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
541 | + if (! $this->_delete_item($ID, $model)) { |
|
542 | + $success = 0; |
|
543 | + } |
|
544 | + } |
|
545 | + } elseif (! empty($this->_req_data['QSG_ID'])) { |
|
546 | + $success = $this->_delete_item($this->_req_data['QSG_ID'], $model); |
|
547 | + } elseif (! empty($this->_req_data['QST_ID'])) { |
|
548 | + $success = $this->_delete_item($this->_req_data['QST_ID'], $model); |
|
549 | + } else { |
|
550 | + EE_Error::add_error( |
|
551 | + sprintf( |
|
552 | + esc_html__( |
|
553 | + "No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.", |
|
554 | + "event_espresso" |
|
555 | + ) |
|
556 | + ), |
|
557 | + __FILE__, |
|
558 | + __FUNCTION__, |
|
559 | + __LINE__ |
|
560 | + ); |
|
561 | + } |
|
562 | + return $success; |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + /** |
|
567 | + * Deletes the specified question (and its associated question options) or question group |
|
568 | + * |
|
569 | + * @param int $id |
|
570 | + * @param EEM_Soft_Delete_Base $model |
|
571 | + * @return boolean |
|
572 | + * @throws EE_Error |
|
573 | + * @throws InvalidArgumentException |
|
574 | + * @throws InvalidDataTypeException |
|
575 | + * @throws InvalidInterfaceException |
|
576 | + */ |
|
577 | + protected function _delete_item($id, $model) |
|
578 | + { |
|
579 | + if ($model instanceof EEM_Question) { |
|
580 | + EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id)))); |
|
581 | + } |
|
582 | + return $model->delete_permanently_by_ID(absint($id)); |
|
583 | + } |
|
584 | + |
|
585 | + |
|
586 | + /****************************** QUESTION GROUPS ******************************/ |
|
587 | + |
|
588 | + |
|
589 | + /** |
|
590 | + * @param string $type |
|
591 | + * @return void |
|
592 | + * @throws DomainException |
|
593 | + * @throws EE_Error |
|
594 | + * @throws InvalidArgumentException |
|
595 | + * @throws InvalidDataTypeException |
|
596 | + * @throws InvalidInterfaceException |
|
597 | + */ |
|
598 | + protected function _edit_question_group($type = 'add') |
|
599 | + { |
|
600 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
601 | + $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) |
|
602 | + ? absint($this->_req_data['QSG_ID']) |
|
603 | + : false; |
|
604 | + |
|
605 | + switch ($this->_req_action) { |
|
606 | + case 'add_question_group': |
|
607 | + $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso'); |
|
608 | + break; |
|
609 | + case 'edit_question_group': |
|
610 | + $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso'); |
|
611 | + break; |
|
612 | + default: |
|
613 | + $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action)); |
|
614 | + } |
|
615 | + // add ID to title if editing |
|
616 | + $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title; |
|
617 | + if ($ID) { |
|
618 | + /** @var EE_Question_Group $questionGroup */ |
|
619 | + $questionGroup = $this->_question_group_model->get_one_by_ID($ID); |
|
620 | + $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID)); |
|
621 | + $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields); |
|
622 | + } else { |
|
623 | + /** @var EE_Question_Group $questionGroup */ |
|
624 | + $questionGroup = EEM_Question_Group::instance()->create_default_object(); |
|
625 | + $questionGroup->set_order_to_latest(); |
|
626 | + $this->_set_add_edit_form_tags('insert_question_group'); |
|
627 | + } |
|
628 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
629 | + $this->_template_args['all_questions'] = $questionGroup->questions_in_and_not_in_group(); |
|
630 | + $this->_template_args['QSG_ID'] = $ID ? $ID : true; |
|
631 | + $this->_template_args['question_group'] = $questionGroup; |
|
632 | + |
|
633 | + $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url); |
|
634 | + $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL); |
|
635 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
636 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php', |
|
637 | + $this->_template_args, |
|
638 | + true |
|
639 | + ); |
|
640 | + |
|
641 | + // the details template wrapper |
|
642 | + $this->display_admin_page_with_sidebar(); |
|
643 | + } |
|
644 | + |
|
645 | + |
|
646 | + /** |
|
647 | + * @return void |
|
648 | + * @throws EE_Error |
|
649 | + * @throws InvalidArgumentException |
|
650 | + * @throws InvalidDataTypeException |
|
651 | + * @throws InvalidInterfaceException |
|
652 | + */ |
|
653 | + protected function _delete_question_groups() |
|
654 | + { |
|
655 | + $success = $this->_delete_items($this->_question_group_model); |
|
656 | + $this->_redirect_after_action( |
|
657 | + $success, |
|
658 | + $this->_question_group_model->item_name($success), |
|
659 | + 'deleted permanently', |
|
660 | + array('action' => 'question_groups', 'status' => 'trash') |
|
661 | + ); |
|
662 | + } |
|
663 | + |
|
664 | + |
|
665 | + /** |
|
666 | + * @param bool $new_question_group |
|
667 | + * @throws EE_Error |
|
668 | + * @throws InvalidArgumentException |
|
669 | + * @throws InvalidDataTypeException |
|
670 | + * @throws InvalidInterfaceException |
|
671 | + */ |
|
672 | + protected function _insert_or_update_question_group($new_question_group = true) |
|
673 | + { |
|
674 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
675 | + $set_column_values = $this->_set_column_values_for($this->_question_group_model); |
|
676 | + |
|
677 | + // make sure identifier is unique |
|
678 | + $identifier_value = isset($set_column_values['QSG_identifier']) ? $set_column_values['QSG_identifier'] : ''; |
|
679 | + $where_values = ['QSG_identifier' => $set_column_values['QSG_identifier']]; |
|
680 | + if (! $new_question_group && isset($set_column_values['QSG_ID'])) { |
|
681 | + $where_values['QSG_ID'] = ['!=', $set_column_values['QSG_ID']]; |
|
682 | + } |
|
683 | + $identifier_exists = ! empty($identifier_value) |
|
684 | + ? $this->_question_group_model->count([$where_values]) > 0 |
|
685 | + : false; |
|
686 | + if ($identifier_exists) { |
|
687 | + $set_column_values['QSG_identifier'] .= uniqid('id', true); |
|
688 | + } |
|
689 | + |
|
690 | + if ($new_question_group) { |
|
691 | + $QSG_ID = $this->_question_group_model->insert($set_column_values); |
|
692 | + $success = $QSG_ID ? 1 : 0; |
|
693 | + if ($success === 0) { |
|
694 | + EE_Error::add_error( |
|
695 | + esc_html__('Something went wrong saving the question group.', 'event_espresso'), |
|
696 | + __FILE__, |
|
697 | + __FUNCTION__, |
|
698 | + __LINE__ |
|
699 | + ); |
|
700 | + $this->_redirect_after_action( |
|
701 | + false, |
|
702 | + '', |
|
703 | + '', |
|
704 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
705 | + true |
|
706 | + ); |
|
707 | + } |
|
708 | + } else { |
|
709 | + $QSG_ID = absint($this->_req_data['QSG_ID']); |
|
710 | + unset($set_column_values['QSG_ID']); |
|
711 | + $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID))); |
|
712 | + } |
|
713 | + |
|
714 | + $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string( |
|
715 | + EEM_Attendee::system_question_phone |
|
716 | + ); |
|
717 | + // update the existing related questions |
|
718 | + // BUT FIRST... delete the phone question from the Question_Group_Question |
|
719 | + // if it is being added to this question group (therefore removed from the existing group) |
|
720 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $phone_question_id ])) { |
|
721 | + // delete where QST ID = system phone question ID and Question Group ID is NOT this group |
|
722 | + EEM_Question_Group_Question::instance()->delete( |
|
723 | + array( |
|
724 | + array( |
|
725 | + 'QST_ID' => $phone_question_id, |
|
726 | + 'QSG_ID' => array('!=', $QSG_ID), |
|
727 | + ), |
|
728 | + ) |
|
729 | + ); |
|
730 | + } |
|
731 | + /** @type EE_Question_Group $question_group */ |
|
732 | + $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID); |
|
733 | + $questions = $question_group->questions(); |
|
734 | + // make sure system phone question is added to list of questions for this group |
|
735 | + if (! isset($questions[ $phone_question_id ])) { |
|
736 | + $questions[ $phone_question_id ] = EEM_Question::instance()->get_one_by_ID($phone_question_id); |
|
737 | + } |
|
738 | + |
|
739 | + foreach ($questions as $question_ID => $question) { |
|
740 | + // first we always check for order. |
|
741 | + if (! empty($this->_req_data['question_orders'][ $question_ID ])) { |
|
742 | + // update question order |
|
743 | + $question_group->update_question_order( |
|
744 | + $question_ID, |
|
745 | + $this->_req_data['question_orders'][ $question_ID ] |
|
746 | + ); |
|
747 | + } |
|
748 | + |
|
749 | + // then we always check if adding or removing. |
|
750 | + if (isset($this->_req_data['questions'], $this->_req_data['questions'][ $question_ID ])) { |
|
751 | + $question_group->add_question($question_ID); |
|
752 | + } else { |
|
753 | + // not found, remove it (but only if not a system question for the personal group |
|
754 | + // with the exception of lname system question - we allow removal of it) |
|
755 | + if ( |
|
756 | + in_array( |
|
757 | + $question->system_ID(), |
|
758 | + EEM_Question::instance()->required_system_questions_in_system_question_group( |
|
759 | + $question_group->system_group() |
|
760 | + ) |
|
761 | + ) |
|
762 | + ) { |
|
763 | + continue; |
|
764 | + } else { |
|
765 | + $question_group->remove_question($question_ID); |
|
766 | + } |
|
767 | + } |
|
768 | + } |
|
769 | + // save new related questions |
|
770 | + if (isset($this->_req_data['questions'])) { |
|
771 | + foreach ($this->_req_data['questions'] as $QST_ID) { |
|
772 | + $question_group->add_question($QST_ID); |
|
773 | + if (isset($this->_req_data['question_orders'][ $QST_ID ])) { |
|
774 | + $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][ $QST_ID ]); |
|
775 | + } |
|
776 | + } |
|
777 | + } |
|
778 | + |
|
779 | + if ($success !== false) { |
|
780 | + $msg = $new_question_group |
|
781 | + ? sprintf( |
|
782 | + esc_html__('The %s has been created', 'event_espresso'), |
|
783 | + $this->_question_group_model->item_name() |
|
784 | + ) |
|
785 | + : sprintf( |
|
786 | + esc_html__( |
|
787 | + 'The %s has been updated', |
|
788 | + 'event_espresso' |
|
789 | + ), |
|
790 | + $this->_question_group_model->item_name() |
|
791 | + ); |
|
792 | + EE_Error::add_success($msg); |
|
793 | + } |
|
794 | + $this->_redirect_after_action( |
|
795 | + false, |
|
796 | + '', |
|
797 | + '', |
|
798 | + array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID), |
|
799 | + true |
|
800 | + ); |
|
801 | + } |
|
802 | + |
|
803 | + |
|
804 | + /** |
|
805 | + * duplicates a question and all its question options and redirects to the new question. |
|
806 | + * |
|
807 | + * @return void |
|
808 | + * @throws EE_Error |
|
809 | + * @throws InvalidArgumentException |
|
810 | + * @throws ReflectionException |
|
811 | + * @throws InvalidDataTypeException |
|
812 | + * @throws InvalidInterfaceException |
|
813 | + */ |
|
814 | + public function _duplicate_question() |
|
815 | + { |
|
816 | + $question_ID = (int) $this->_req_data['QST_ID']; |
|
817 | + $question = EEM_Question::instance()->get_one_by_ID($question_ID); |
|
818 | + if ($question instanceof EE_Question) { |
|
819 | + $new_question = $question->duplicate(); |
|
820 | + if ($new_question instanceof EE_Question) { |
|
821 | + $this->_redirect_after_action( |
|
822 | + true, |
|
823 | + esc_html__('Question', 'event_espresso'), |
|
824 | + esc_html__('Duplicated', 'event_espresso'), |
|
825 | + array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), |
|
826 | + true |
|
827 | + ); |
|
828 | + } else { |
|
829 | + global $wpdb; |
|
830 | + EE_Error::add_error( |
|
831 | + sprintf( |
|
832 | + esc_html__( |
|
833 | + 'Could not duplicate question with ID %1$d because: %2$s', |
|
834 | + 'event_espresso' |
|
835 | + ), |
|
836 | + $question_ID, |
|
837 | + $wpdb->last_error |
|
838 | + ), |
|
839 | + __FILE__, |
|
840 | + __FUNCTION__, |
|
841 | + __LINE__ |
|
842 | + ); |
|
843 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
844 | + } |
|
845 | + } else { |
|
846 | + EE_Error::add_error( |
|
847 | + sprintf( |
|
848 | + esc_html__( |
|
849 | + 'Could not duplicate question with ID %d because it didn\'t exist!', |
|
850 | + 'event_espresso' |
|
851 | + ), |
|
852 | + $question_ID |
|
853 | + ), |
|
854 | + __FILE__, |
|
855 | + __FUNCTION__, |
|
856 | + __LINE__ |
|
857 | + ); |
|
858 | + $this->_redirect_after_action(false, '', '', array('action' => 'default'), false); |
|
859 | + } |
|
860 | + } |
|
861 | + |
|
862 | + |
|
863 | + /** |
|
864 | + * @param bool $trash |
|
865 | + * @throws EE_Error |
|
866 | + */ |
|
867 | + protected function _trash_or_restore_question_groups($trash = true) |
|
868 | + { |
|
869 | + $this->_trash_or_restore_items($this->_question_group_model, $trash); |
|
870 | + } |
|
871 | + |
|
872 | + |
|
873 | + /** |
|
874 | + *_trash_question |
|
875 | + * |
|
876 | + * @return void |
|
877 | + * @throws EE_Error |
|
878 | + */ |
|
879 | + protected function _trash_question() |
|
880 | + { |
|
881 | + $success = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']); |
|
882 | + $query_args = array('action' => 'default', 'status' => 'all'); |
|
883 | + $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args); |
|
884 | + } |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * @param bool $trash |
|
889 | + * @throws EE_Error |
|
890 | + */ |
|
891 | + protected function _trash_or_restore_questions($trash = true) |
|
892 | + { |
|
893 | + $this->_trash_or_restore_items($this->_question_model, $trash); |
|
894 | + } |
|
895 | + |
|
896 | + |
|
897 | + /** |
|
898 | + * Internally used to delete or restore items, using the request data. Meant to be |
|
899 | + * flexible between question or question groups |
|
900 | + * |
|
901 | + * @param EEM_Soft_Delete_Base $model |
|
902 | + * @param boolean $trash whether to trash or restore |
|
903 | + * @throws EE_Error |
|
904 | + */ |
|
905 | + private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true) |
|
906 | + { |
|
907 | + |
|
908 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
909 | + |
|
910 | + $success = 1; |
|
911 | + // Checkboxes |
|
912 | + // echo "trash $trash"; |
|
913 | + // var_dump($this->_req_data['checkbox']);die; |
|
914 | + if (isset($this->_req_data['checkbox'])) { |
|
915 | + if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
916 | + // if array has more than one element than success message should be plural |
|
917 | + $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1; |
|
918 | + // cycle thru bulk action checkboxes |
|
919 | + while (list($ID, $value) = each($this->_req_data['checkbox'])) { |
|
920 | + if (! $model->delete_or_restore_by_ID($trash, absint($ID))) { |
|
921 | + $success = 0; |
|
922 | + } |
|
923 | + } |
|
924 | + } else { |
|
925 | + // grab single id and delete |
|
926 | + $ID = absint($this->_req_data['checkbox']); |
|
927 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
928 | + $success = 0; |
|
929 | + } |
|
930 | + } |
|
931 | + } else { |
|
932 | + // delete via trash link |
|
933 | + // grab single id and delete |
|
934 | + $ID = absint($this->_req_data[ $model->primary_key_name() ]); |
|
935 | + if (! $model->delete_or_restore_by_ID($trash, $ID)) { |
|
936 | + $success = 0; |
|
937 | + } |
|
938 | + } |
|
939 | + |
|
940 | + |
|
941 | + $action = $model instanceof EEM_Question ? 'default' : 'question_groups';// strtolower( $model->item_name(2) ); |
|
942 | + // echo "action :$action"; |
|
943 | + // $action = 'questions' ? 'default' : $action; |
|
944 | + if ($trash) { |
|
945 | + $action_desc = 'trashed'; |
|
946 | + $status = 'trash'; |
|
947 | + } else { |
|
948 | + $action_desc = 'restored'; |
|
949 | + $status = 'all'; |
|
950 | + } |
|
951 | + $this->_redirect_after_action( |
|
952 | + $success, |
|
953 | + $model->item_name($success), |
|
954 | + $action_desc, |
|
955 | + array('action' => $action, 'status' => $status) |
|
956 | + ); |
|
957 | + } |
|
958 | + |
|
959 | + |
|
960 | + /** |
|
961 | + * @param $per_page |
|
962 | + * @param int $current_page |
|
963 | + * @param bool|false $count |
|
964 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
965 | + * @throws EE_Error |
|
966 | + * @throws InvalidArgumentException |
|
967 | + * @throws InvalidDataTypeException |
|
968 | + * @throws InvalidInterfaceException |
|
969 | + */ |
|
970 | + public function get_trashed_questions($per_page, $current_page = 1, $count = false) |
|
971 | + { |
|
972 | + $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page); |
|
973 | + |
|
974 | + if ($count) { |
|
975 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
976 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
977 | + $results = $this->_question_model->count_deleted($where); |
|
978 | + } else { |
|
979 | + // note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items |
|
980 | + $results = $this->_question_model->get_all_deleted($query_params); |
|
981 | + } |
|
982 | + return $results; |
|
983 | + } |
|
984 | + |
|
985 | + |
|
986 | + /** |
|
987 | + * @param $per_page |
|
988 | + * @param int $current_page |
|
989 | + * @param bool|false $count |
|
990 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
991 | + * @throws EE_Error |
|
992 | + * @throws InvalidArgumentException |
|
993 | + * @throws InvalidDataTypeException |
|
994 | + * @throws InvalidInterfaceException |
|
995 | + */ |
|
996 | + public function get_question_groups($per_page, $current_page = 1, $count = false) |
|
997 | + { |
|
998 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
999 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1000 | + if ($count) { |
|
1001 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1002 | + $results = $questionGroupModel->count($where); |
|
1003 | + } else { |
|
1004 | + $results = $questionGroupModel->get_all($query_params); |
|
1005 | + } |
|
1006 | + return $results; |
|
1007 | + } |
|
1008 | + |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * @param $per_page |
|
1012 | + * @param int $current_page |
|
1013 | + * @param bool $count |
|
1014 | + * @return EE_Soft_Delete_Base_Class[]|int |
|
1015 | + * @throws EE_Error |
|
1016 | + * @throws InvalidArgumentException |
|
1017 | + * @throws InvalidDataTypeException |
|
1018 | + * @throws InvalidInterfaceException |
|
1019 | + */ |
|
1020 | + public function get_trashed_question_groups($per_page, $current_page = 1, $count = false) |
|
1021 | + { |
|
1022 | + $questionGroupModel = EEM_Question_Group::instance(); |
|
1023 | + $query_params = $this->get_query_params($questionGroupModel, $per_page, $current_page); |
|
1024 | + if ($count) { |
|
1025 | + $where = isset($query_params[0]) ? array($query_params[0]) : array(); |
|
1026 | + $query_params['limit'] = null; |
|
1027 | + $results = $questionGroupModel->count_deleted($where); |
|
1028 | + } else { |
|
1029 | + $results = $questionGroupModel->get_all_deleted($query_params); |
|
1030 | + } |
|
1031 | + return $results; |
|
1032 | + } |
|
1033 | + |
|
1034 | + |
|
1035 | + /** |
|
1036 | + * method for performing updates to question order |
|
1037 | + * |
|
1038 | + * @return void results array |
|
1039 | + * @throws EE_Error |
|
1040 | + * @throws InvalidArgumentException |
|
1041 | + * @throws InvalidDataTypeException |
|
1042 | + * @throws InvalidInterfaceException |
|
1043 | + */ |
|
1044 | + public function update_question_group_order() |
|
1045 | + { |
|
1046 | + |
|
1047 | + $success = esc_html__('Question group order was updated successfully.', 'event_espresso'); |
|
1048 | + |
|
1049 | + // grab our row IDs |
|
1050 | + $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids']) |
|
1051 | + ? explode(',', rtrim($this->_req_data['row_ids'], ',')) |
|
1052 | + : array(); |
|
1053 | + |
|
1054 | + $perpage = ! empty($this->_req_data['perpage']) |
|
1055 | + ? (int) $this->_req_data['perpage'] |
|
1056 | + : null; |
|
1057 | + $curpage = ! empty($this->_req_data['curpage']) |
|
1058 | + ? (int) $this->_req_data['curpage'] |
|
1059 | + : null; |
|
1060 | + |
|
1061 | + if (! empty($row_ids)) { |
|
1062 | + // figure out where we start the row_id count at for the current page. |
|
1063 | + $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage; |
|
1064 | + |
|
1065 | + $row_count = count($row_ids); |
|
1066 | + for ($i = 0; $i < $row_count; $i++) { |
|
1067 | + // Update the questions when re-ordering |
|
1068 | + $updated = EEM_Question_Group::instance()->update( |
|
1069 | + array('QSG_order' => $qsgcount), |
|
1070 | + array(array('QSG_ID' => $row_ids[ $i ])) |
|
1071 | + ); |
|
1072 | + if ($updated === false) { |
|
1073 | + $success = false; |
|
1074 | + } |
|
1075 | + $qsgcount++; |
|
1076 | + } |
|
1077 | + } else { |
|
1078 | + $success = false; |
|
1079 | + } |
|
1080 | + |
|
1081 | + $errors = ! $success |
|
1082 | + ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso') |
|
1083 | + : false; |
|
1084 | + |
|
1085 | + echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors)); |
|
1086 | + die(); |
|
1087 | + } |
|
1088 | + |
|
1089 | + |
|
1090 | + |
|
1091 | + /*************************************** REGISTRATION SETTINGS ***************************************/ |
|
1092 | + |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * @throws DomainException |
|
1096 | + * @throws EE_Error |
|
1097 | + * @throws InvalidArgumentException |
|
1098 | + * @throws InvalidDataTypeException |
|
1099 | + * @throws InvalidInterfaceException |
|
1100 | + */ |
|
1101 | + protected function _reg_form_settings() |
|
1102 | + { |
|
1103 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
1104 | + add_action( |
|
1105 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1106 | + array($this, 'email_validation_settings_form'), |
|
1107 | + 2 |
|
1108 | + ); |
|
1109 | + add_action( |
|
1110 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1111 | + array($this, 'copy_attendee_info_settings_form'), |
|
1112 | + 4 |
|
1113 | + ); |
|
1114 | + add_action( |
|
1115 | + 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', |
|
1116 | + array($this, 'setSessionLifespan'), |
|
1117 | + 4.9 |
|
1118 | + ); |
|
1119 | + $this->_template_args = (array) apply_filters( |
|
1120 | + 'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args', |
|
1121 | + $this->_template_args |
|
1122 | + ); |
|
1123 | + $this->_set_add_edit_form_tags('update_reg_form_settings'); |
|
1124 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
1125 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
1126 | + REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php', |
|
1127 | + $this->_template_args, |
|
1128 | + true |
|
1129 | + ); |
|
1130 | + $this->display_admin_page_with_sidebar(); |
|
1131 | + } |
|
1132 | + |
|
1133 | + |
|
1134 | + /** |
|
1135 | + * @return void |
|
1136 | + * @throws EE_Error |
|
1137 | + * @throws InvalidArgumentException |
|
1138 | + * @throws ReflectionException |
|
1139 | + * @throws InvalidDataTypeException |
|
1140 | + * @throws InvalidInterfaceException |
|
1141 | + */ |
|
1142 | + protected function _update_reg_form_settings() |
|
1143 | + { |
|
1144 | + EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form( |
|
1145 | + EE_Registry::instance()->CFG->registration |
|
1146 | + ); |
|
1147 | + EE_Registry::instance()->CFG->registration = $this->update_copy_attendee_info_settings_form( |
|
1148 | + EE_Registry::instance()->CFG->registration |
|
1149 | + ); |
|
1150 | + $this->updateSessionLifespan(); |
|
1151 | + EE_Registry::instance()->CFG->registration = apply_filters( |
|
1152 | + 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', |
|
1153 | + EE_Registry::instance()->CFG->registration |
|
1154 | + ); |
|
1155 | + $success = $this->_update_espresso_configuration( |
|
1156 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1157 | + EE_Registry::instance()->CFG, |
|
1158 | + __FILE__, |
|
1159 | + __FUNCTION__, |
|
1160 | + __LINE__ |
|
1161 | + ); |
|
1162 | + $this->_redirect_after_action( |
|
1163 | + $success, |
|
1164 | + esc_html__('Registration Form Options', 'event_espresso'), |
|
1165 | + 'updated', |
|
1166 | + array('action' => 'view_reg_form_settings') |
|
1167 | + ); |
|
1168 | + } |
|
1169 | + |
|
1170 | + |
|
1171 | + /** |
|
1172 | + * @return void |
|
1173 | + * @throws EE_Error |
|
1174 | + * @throws InvalidArgumentException |
|
1175 | + * @throws InvalidDataTypeException |
|
1176 | + * @throws InvalidInterfaceException |
|
1177 | + */ |
|
1178 | + public function copy_attendee_info_settings_form() |
|
1179 | + { |
|
1180 | + echo wp_kses($this->_copy_attendee_info_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1181 | + } |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * _copy_attendee_info_settings_form |
|
1185 | + * |
|
1186 | + * @access protected |
|
1187 | + * @return EE_Form_Section_Proper |
|
1188 | + * @throws \EE_Error |
|
1189 | + */ |
|
1190 | + protected function _copy_attendee_info_settings_form() |
|
1191 | + { |
|
1192 | + return new EE_Form_Section_Proper( |
|
1193 | + array( |
|
1194 | + 'name' => 'copy_attendee_info_settings', |
|
1195 | + 'html_id' => 'copy_attendee_info_settings', |
|
1196 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1197 | + 'subsections' => apply_filters( |
|
1198 | + 'FHEE__Extend_Registration_Form_Admin_Page___copy_attendee_info_settings_form__form_subsections', |
|
1199 | + array( |
|
1200 | + 'copy_attendee_info_hdr' => new EE_Form_Section_HTML( |
|
1201 | + EEH_HTML::h2(esc_html__('Copy Attendee Info Settings', 'event_espresso')) |
|
1202 | + ), |
|
1203 | + 'copy_attendee_info' => new EE_Yes_No_Input( |
|
1204 | + array( |
|
1205 | + 'html_label_text' => esc_html__( |
|
1206 | + 'Allow copy #1 attendee info to extra attendees?', |
|
1207 | + 'event_espresso' |
|
1208 | + ), |
|
1209 | + 'html_help_text' => esc_html__( |
|
1210 | + 'Set to yes if you want to enable the copy of #1 attendee info to extra attendees at Registration Form.', |
|
1211 | + 'event_espresso' |
|
1212 | + ), |
|
1213 | + 'default' => EE_Registry::instance()->CFG->registration->copyAttendeeInfo(), |
|
1214 | + 'required' => false, |
|
1215 | + 'display_html_label_text' => false, |
|
1216 | + ) |
|
1217 | + ), |
|
1218 | + ) |
|
1219 | + ), |
|
1220 | + ) |
|
1221 | + ); |
|
1222 | + } |
|
1223 | + |
|
1224 | + /** |
|
1225 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1226 | + * @return EE_Registration_Config |
|
1227 | + * @throws EE_Error |
|
1228 | + * @throws InvalidArgumentException |
|
1229 | + * @throws ReflectionException |
|
1230 | + * @throws InvalidDataTypeException |
|
1231 | + * @throws InvalidInterfaceException |
|
1232 | + */ |
|
1233 | + public function update_copy_attendee_info_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1234 | + { |
|
1235 | + $prev_copy_attendee_info = $EE_Registration_Config->copyAttendeeInfo(); |
|
1236 | + try { |
|
1237 | + $copy_attendee_info_settings_form = $this->_copy_attendee_info_settings_form(); |
|
1238 | + // if not displaying a form, then check for form submission |
|
1239 | + if ($copy_attendee_info_settings_form->was_submitted()) { |
|
1240 | + // capture form data |
|
1241 | + $copy_attendee_info_settings_form->receive_form_submission(); |
|
1242 | + // validate form data |
|
1243 | + if ($copy_attendee_info_settings_form->is_valid()) { |
|
1244 | + // grab validated data from form |
|
1245 | + $valid_data = $copy_attendee_info_settings_form->valid_data(); |
|
1246 | + if (isset($valid_data['copy_attendee_info'])) { |
|
1247 | + $EE_Registration_Config->setCopyAttendeeInfo($valid_data['copy_attendee_info']); |
|
1248 | + } else { |
|
1249 | + EE_Error::add_error( |
|
1250 | + esc_html__( |
|
1251 | + 'Invalid or missing Copy Attendee Info settings. Please refresh the form and try again.', |
|
1252 | + 'event_espresso' |
|
1253 | + ), |
|
1254 | + __FILE__, |
|
1255 | + __FUNCTION__, |
|
1256 | + __LINE__ |
|
1257 | + ); |
|
1258 | + } |
|
1259 | + } elseif ($copy_attendee_info_settings_form->submission_error_message() !== '') { |
|
1260 | + EE_Error::add_error( |
|
1261 | + $copy_attendee_info_settings_form->submission_error_message(), |
|
1262 | + __FILE__, |
|
1263 | + __FUNCTION__, |
|
1264 | + __LINE__ |
|
1265 | + ); |
|
1266 | + } |
|
1267 | + } |
|
1268 | + } catch (EE_Error $e) { |
|
1269 | + $e->get_error(); |
|
1270 | + } |
|
1271 | + return $EE_Registration_Config; |
|
1272 | + } |
|
1273 | + |
|
1274 | + |
|
1275 | + /** |
|
1276 | + * @return void |
|
1277 | + * @throws EE_Error |
|
1278 | + * @throws InvalidArgumentException |
|
1279 | + * @throws InvalidDataTypeException |
|
1280 | + * @throws InvalidInterfaceException |
|
1281 | + */ |
|
1282 | + public function email_validation_settings_form() |
|
1283 | + { |
|
1284 | + echo wp_kses($this->_email_validation_settings_form()->get_html(), AllowedTags::getWithFormTags()); |
|
1285 | + } |
|
1286 | + |
|
1287 | + |
|
1288 | + /** |
|
1289 | + * _email_validation_settings_form |
|
1290 | + * |
|
1291 | + * @access protected |
|
1292 | + * @return EE_Form_Section_Proper |
|
1293 | + * @throws \EE_Error |
|
1294 | + */ |
|
1295 | + protected function _email_validation_settings_form() |
|
1296 | + { |
|
1297 | + return new EE_Form_Section_Proper( |
|
1298 | + array( |
|
1299 | + 'name' => 'email_validation_settings', |
|
1300 | + 'html_id' => 'email_validation_settings', |
|
1301 | + 'layout_strategy' => new EE_Admin_Two_Column_Layout(), |
|
1302 | + 'subsections' => apply_filters( |
|
1303 | + 'FHEE__Extend_Registration_Form_Admin_Page___email_validation_settings_form__form_subsections', |
|
1304 | + array( |
|
1305 | + 'email_validation_hdr' => new EE_Form_Section_HTML( |
|
1306 | + EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso')) |
|
1307 | + ), |
|
1308 | + 'email_validation_level' => new EE_Select_Input( |
|
1309 | + array( |
|
1310 | + 'basic' => esc_html__('Basic', 'event_espresso'), |
|
1311 | + 'wp_default' => esc_html__('WordPress Default', 'event_espresso'), |
|
1312 | + 'i18n' => esc_html__('International', 'event_espresso'), |
|
1313 | + 'i18n_dns' => esc_html__('International + DNS Check', 'event_espresso'), |
|
1314 | + ), |
|
1315 | + array( |
|
1316 | + 'html_label_text' => esc_html__('Email Validation Level', 'event_espresso') |
|
1317 | + . EEH_Template::get_help_tab_link('email_validation_info'), |
|
1318 | + 'html_help_text' => esc_html__( |
|
1319 | + 'These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.', |
|
1320 | + 'event_espresso' |
|
1321 | + ), |
|
1322 | + 'default' => isset( |
|
1323 | + EE_Registry::instance()->CFG->registration->email_validation_level |
|
1324 | + ) |
|
1325 | + ? EE_Registry::instance()->CFG->registration->email_validation_level |
|
1326 | + : 'wp_default', |
|
1327 | + 'required' => false, |
|
1328 | + ) |
|
1329 | + ), |
|
1330 | + ) |
|
1331 | + ), |
|
1332 | + ) |
|
1333 | + ); |
|
1334 | + } |
|
1335 | + |
|
1336 | + |
|
1337 | + /** |
|
1338 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1339 | + * @return EE_Registration_Config |
|
1340 | + * @throws EE_Error |
|
1341 | + * @throws InvalidArgumentException |
|
1342 | + * @throws ReflectionException |
|
1343 | + * @throws InvalidDataTypeException |
|
1344 | + * @throws InvalidInterfaceException |
|
1345 | + */ |
|
1346 | + public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config) |
|
1347 | + { |
|
1348 | + $prev_email_validation_level = $EE_Registration_Config->email_validation_level; |
|
1349 | + try { |
|
1350 | + $email_validation_settings_form = $this->_email_validation_settings_form(); |
|
1351 | + // if not displaying a form, then check for form submission |
|
1352 | + if ($email_validation_settings_form->was_submitted()) { |
|
1353 | + // capture form data |
|
1354 | + $email_validation_settings_form->receive_form_submission(); |
|
1355 | + // validate form data |
|
1356 | + if ($email_validation_settings_form->is_valid()) { |
|
1357 | + // grab validated data from form |
|
1358 | + $valid_data = $email_validation_settings_form->valid_data(); |
|
1359 | + if (isset($valid_data['email_validation_level'])) { |
|
1360 | + $email_validation_level = $valid_data['email_validation_level']; |
|
1361 | + // now if they want to use international email addresses |
|
1362 | + if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') { |
|
1363 | + // in case we need to reset their email validation level, |
|
1364 | + // make sure that the previous value wasn't already set to one of the i18n options. |
|
1365 | + if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') { |
|
1366 | + // if so, then reset it back to "basic" since that is the only other option that, |
|
1367 | + // despite offering poor validation, supports i18n email addresses |
|
1368 | + $prev_email_validation_level = 'basic'; |
|
1369 | + } |
|
1370 | + // confirm our i18n email validation will work on the server |
|
1371 | + if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) { |
|
1372 | + // or reset email validation level to previous value |
|
1373 | + $email_validation_level = $prev_email_validation_level; |
|
1374 | + } |
|
1375 | + } |
|
1376 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1377 | + } else { |
|
1378 | + EE_Error::add_error( |
|
1379 | + esc_html__( |
|
1380 | + 'Invalid or missing Email Validation settings. Please refresh the form and try again.', |
|
1381 | + 'event_espresso' |
|
1382 | + ), |
|
1383 | + __FILE__, |
|
1384 | + __FUNCTION__, |
|
1385 | + __LINE__ |
|
1386 | + ); |
|
1387 | + } |
|
1388 | + } elseif ($email_validation_settings_form->submission_error_message() !== '') { |
|
1389 | + EE_Error::add_error( |
|
1390 | + $email_validation_settings_form->submission_error_message(), |
|
1391 | + __FILE__, |
|
1392 | + __FUNCTION__, |
|
1393 | + __LINE__ |
|
1394 | + ); |
|
1395 | + } |
|
1396 | + } |
|
1397 | + } catch (EE_Error $e) { |
|
1398 | + $e->get_error(); |
|
1399 | + } |
|
1400 | + return $EE_Registration_Config; |
|
1401 | + } |
|
1402 | + |
|
1403 | + |
|
1404 | + /** |
|
1405 | + * confirms that the server's PHP version has the PCRE module enabled, |
|
1406 | + * and that the PCRE version works with our i18n email validation |
|
1407 | + * |
|
1408 | + * @param EE_Registration_Config $EE_Registration_Config |
|
1409 | + * @param string $email_validation_level |
|
1410 | + * @return bool |
|
1411 | + */ |
|
1412 | + private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level) |
|
1413 | + { |
|
1414 | + // first check that PCRE is enabled |
|
1415 | + if (! defined('PREG_BAD_UTF8_ERROR')) { |
|
1416 | + EE_Error::add_error( |
|
1417 | + sprintf( |
|
1418 | + esc_html__( |
|
1419 | + 'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.', |
|
1420 | + 'event_espresso' |
|
1421 | + ), |
|
1422 | + '<br />' |
|
1423 | + ), |
|
1424 | + __FILE__, |
|
1425 | + __FUNCTION__, |
|
1426 | + __LINE__ |
|
1427 | + ); |
|
1428 | + return false; |
|
1429 | + } else { |
|
1430 | + // PCRE support is enabled, but let's still |
|
1431 | + // perform a test to see if the server will support it. |
|
1432 | + // but first, save the updated validation level to the config, |
|
1433 | + // so that the validation strategy picks it up. |
|
1434 | + // this will get bumped back down if it doesn't work |
|
1435 | + $EE_Registration_Config->email_validation_level = $email_validation_level; |
|
1436 | + try { |
|
1437 | + $email_validator = new EE_Email_Validation_Strategy(); |
|
1438 | + $i18n_email_address = apply_filters( |
|
1439 | + 'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address', |
|
1440 | + 'jägerjü[email protected]' |
|
1441 | + ); |
|
1442 | + $email_validator->validate($i18n_email_address); |
|
1443 | + } catch (Exception $e) { |
|
1444 | + EE_Error::add_error( |
|
1445 | + sprintf( |
|
1446 | + esc_html__( |
|
1447 | + 'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s', |
|
1448 | + 'event_espresso' |
|
1449 | + ), |
|
1450 | + '<br />', |
|
1451 | + '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank" rel="noopener noreferrer">http://php.net/manual/en/pcre.installation.php</a>' |
|
1452 | + ), |
|
1453 | + __FILE__, |
|
1454 | + __FUNCTION__, |
|
1455 | + __LINE__ |
|
1456 | + ); |
|
1457 | + return false; |
|
1458 | + } |
|
1459 | + } |
|
1460 | + return true; |
|
1461 | + } |
|
1462 | + |
|
1463 | + |
|
1464 | + public function setSessionLifespan() |
|
1465 | + { |
|
1466 | + $session_lifespan_form = $this->loader->getNew(SessionLifespanForm::class); |
|
1467 | + echo wp_kses($session_lifespan_form->get_html(), AllowedTags::getWithFormTags()); |
|
1468 | + } |
|
1469 | + |
|
1470 | + |
|
1471 | + public function updateSessionLifespan() |
|
1472 | + { |
|
1473 | + $handler = $this->loader->getNew(SessionLifespanFormHandler::class); |
|
1474 | + $handler->process($this->loader->getNew(SessionLifespanForm::class)); |
|
1475 | + } |
|
1476 | 1476 | } |
@@ -20,1140 +20,1140 @@ |
||
20 | 20 | */ |
21 | 21 | class EE_Dependency_Map |
22 | 22 | { |
23 | - /** |
|
24 | - * This means that the requested class dependency is not present in the dependency map |
|
25 | - */ |
|
26 | - const not_registered = 0; |
|
27 | - |
|
28 | - /** |
|
29 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | - */ |
|
31 | - const load_new_object = 1; |
|
32 | - |
|
33 | - /** |
|
34 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | - */ |
|
37 | - const load_from_cache = 2; |
|
38 | - |
|
39 | - /** |
|
40 | - * When registering a dependency, |
|
41 | - * this indicates to keep any existing dependencies that already exist, |
|
42 | - * and simply discard any new dependencies declared in the incoming data |
|
43 | - */ |
|
44 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | - |
|
46 | - /** |
|
47 | - * When registering a dependency, |
|
48 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | - */ |
|
50 | - const OVERWRITE_DEPENDENCIES = 1; |
|
51 | - |
|
52 | - /** |
|
53 | - * @type EE_Dependency_Map $_instance |
|
54 | - */ |
|
55 | - protected static $_instance; |
|
56 | - |
|
57 | - /** |
|
58 | - * @var ClassInterfaceCache $class_cache |
|
59 | - */ |
|
60 | - private $class_cache; |
|
61 | - |
|
62 | - /** |
|
63 | - * @type RequestInterface $request |
|
64 | - */ |
|
65 | - protected $request; |
|
66 | - |
|
67 | - /** |
|
68 | - * @type LegacyRequestInterface $legacy_request |
|
69 | - */ |
|
70 | - protected $legacy_request; |
|
71 | - |
|
72 | - /** |
|
73 | - * @type ResponseInterface $response |
|
74 | - */ |
|
75 | - protected $response; |
|
76 | - |
|
77 | - /** |
|
78 | - * @type LoaderInterface $loader |
|
79 | - */ |
|
80 | - protected $loader; |
|
81 | - |
|
82 | - /** |
|
83 | - * @type array $_dependency_map |
|
84 | - */ |
|
85 | - protected $_dependency_map = []; |
|
86 | - |
|
87 | - /** |
|
88 | - * @type array $_class_loaders |
|
89 | - */ |
|
90 | - protected $_class_loaders = []; |
|
91 | - |
|
92 | - |
|
93 | - /** |
|
94 | - * EE_Dependency_Map constructor. |
|
95 | - * |
|
96 | - * @param ClassInterfaceCache $class_cache |
|
97 | - */ |
|
98 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | - { |
|
100 | - $this->class_cache = $class_cache; |
|
101 | - do_action('EE_Dependency_Map____construct', $this); |
|
102 | - } |
|
103 | - |
|
104 | - |
|
105 | - /** |
|
106 | - * @return void |
|
107 | - * @throws InvalidAliasException |
|
108 | - */ |
|
109 | - public function initialize() |
|
110 | - { |
|
111 | - $this->_register_core_dependencies(); |
|
112 | - $this->_register_core_class_loaders(); |
|
113 | - $this->_register_core_aliases(); |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - /** |
|
118 | - * @singleton method used to instantiate class object |
|
119 | - * @param ClassInterfaceCache|null $class_cache |
|
120 | - * @return EE_Dependency_Map |
|
121 | - */ |
|
122 | - public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
123 | - { |
|
124 | - // check if class object is instantiated, and instantiated properly |
|
125 | - if ( |
|
126 | - ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
127 | - && $class_cache instanceof ClassInterfaceCache |
|
128 | - ) { |
|
129 | - EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | - } |
|
131 | - return EE_Dependency_Map::$_instance; |
|
132 | - } |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * @param RequestInterface $request |
|
137 | - */ |
|
138 | - public function setRequest(RequestInterface $request) |
|
139 | - { |
|
140 | - $this->request = $request; |
|
141 | - } |
|
142 | - |
|
143 | - |
|
144 | - /** |
|
145 | - * @param LegacyRequestInterface $legacy_request |
|
146 | - */ |
|
147 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | - { |
|
149 | - $this->legacy_request = $legacy_request; |
|
150 | - } |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * @param ResponseInterface $response |
|
155 | - */ |
|
156 | - public function setResponse(ResponseInterface $response) |
|
157 | - { |
|
158 | - $this->response = $response; |
|
159 | - } |
|
160 | - |
|
161 | - |
|
162 | - /** |
|
163 | - * @param LoaderInterface $loader |
|
164 | - */ |
|
165 | - public function setLoader(LoaderInterface $loader) |
|
166 | - { |
|
167 | - $this->loader = $loader; |
|
168 | - } |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * @param string $class |
|
173 | - * @param array $dependencies |
|
174 | - * @param int $overwrite |
|
175 | - * @return bool |
|
176 | - */ |
|
177 | - public static function register_dependencies( |
|
178 | - string $class, |
|
179 | - array $dependencies, |
|
180 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | - ): bool { |
|
182 | - return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | - } |
|
184 | - |
|
185 | - |
|
186 | - /** |
|
187 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | - * to the class specified by the first parameter. |
|
189 | - * IMPORTANT !!! |
|
190 | - * The order of elements in the incoming $dependencies array MUST match |
|
191 | - * the order of the constructor parameters for the class in question. |
|
192 | - * This is especially important when overriding any existing dependencies that are registered. |
|
193 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | - * |
|
195 | - * @param string $class |
|
196 | - * @param array $dependencies |
|
197 | - * @param int $overwrite |
|
198 | - * @return bool |
|
199 | - */ |
|
200 | - public function registerDependencies( |
|
201 | - string $class, |
|
202 | - array $dependencies, |
|
203 | - int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | - ): bool { |
|
205 | - $class = trim($class, '\\'); |
|
206 | - $registered = false; |
|
207 | - if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
208 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
209 | - } |
|
210 | - // we need to make sure that any aliases used when registering a dependency |
|
211 | - // get resolved to the correct class name |
|
212 | - foreach ($dependencies as $dependency => $load_source) { |
|
213 | - $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
214 | - if ( |
|
215 | - $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | - || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | - ) { |
|
218 | - unset($dependencies[ $dependency ]); |
|
219 | - $dependencies[ $alias ] = $load_source; |
|
220 | - $registered = true; |
|
221 | - } |
|
222 | - } |
|
223 | - // now add our two lists of dependencies together. |
|
224 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | - // so $dependencies is NOT overwritten because it is listed first |
|
226 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | - // Union is way faster than array_merge() but should be used with caution... |
|
228 | - // especially with numerically indexed arrays |
|
229 | - $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
230 | - // now we need to ensure that the resulting dependencies |
|
231 | - // array only has the entries that are required for the class |
|
232 | - // so first count how many dependencies were originally registered for the class |
|
233 | - $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
234 | - // if that count is non-zero (meaning dependencies were already registered) |
|
235 | - EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | - // then truncate the final array to match that count |
|
237 | - ? array_slice($dependencies, 0, $dependency_count) |
|
238 | - // otherwise just take the incoming array because nothing previously existed |
|
239 | - : $dependencies; |
|
240 | - return $registered; |
|
241 | - } |
|
242 | - |
|
243 | - |
|
244 | - /** |
|
245 | - * @param string $class_name |
|
246 | - * @param callable|string $loader |
|
247 | - * @param bool $overwrite |
|
248 | - * @return bool |
|
249 | - * @throws DomainException |
|
250 | - */ |
|
251 | - public static function register_class_loader( |
|
252 | - string $class_name, |
|
253 | - $loader = 'load_core', |
|
254 | - bool $overwrite = false |
|
255 | - ): bool { |
|
256 | - return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * @param string $class_name |
|
262 | - * @param Closure|string $loader |
|
263 | - * @param bool $overwrite |
|
264 | - * @return bool |
|
265 | - * @throws DomainException |
|
266 | - */ |
|
267 | - public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
268 | - { |
|
269 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
270 | - throw new DomainException( |
|
271 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
272 | - ); |
|
273 | - } |
|
274 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
275 | - if ( |
|
276 | - ! is_callable($loader) |
|
277 | - && ( |
|
278 | - strpos($loader, 'load_') !== 0 |
|
279 | - || ! method_exists('EE_Registry', $loader) |
|
280 | - ) |
|
281 | - ) { |
|
282 | - throw new DomainException( |
|
283 | - sprintf( |
|
284 | - esc_html__( |
|
285 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
286 | - 'event_espresso' |
|
287 | - ), |
|
288 | - $loader |
|
289 | - ) |
|
290 | - ); |
|
291 | - } |
|
292 | - $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
293 | - if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
294 | - EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
295 | - return true; |
|
296 | - } |
|
297 | - return false; |
|
298 | - } |
|
299 | - |
|
300 | - |
|
301 | - /** |
|
302 | - * @return array |
|
303 | - */ |
|
304 | - public function dependency_map(): array |
|
305 | - { |
|
306 | - return $this->_dependency_map; |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
312 | - * |
|
313 | - * @param string $class_name |
|
314 | - * @return boolean |
|
315 | - */ |
|
316 | - public function has(string $class_name = ''): bool |
|
317 | - { |
|
318 | - // all legacy models have the same dependencies |
|
319 | - if (strpos($class_name, 'EEM_') === 0) { |
|
320 | - $class_name = 'LEGACY_MODELS'; |
|
321 | - } |
|
322 | - return isset($this->_dependency_map[ $class_name ]); |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - /** |
|
327 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
328 | - * |
|
329 | - * @param string $class_name |
|
330 | - * @param string $dependency |
|
331 | - * @return bool |
|
332 | - */ |
|
333 | - public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
334 | - { |
|
335 | - // all legacy models have the same dependencies |
|
336 | - if (strpos($class_name, 'EEM_') === 0) { |
|
337 | - $class_name = 'LEGACY_MODELS'; |
|
338 | - } |
|
339 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
340 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - /** |
|
345 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
346 | - * |
|
347 | - * @param string $class_name |
|
348 | - * @param string $dependency |
|
349 | - * @return int |
|
350 | - */ |
|
351 | - public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
352 | - { |
|
353 | - // all legacy models have the same dependencies |
|
354 | - if (strpos($class_name, 'EEM_') === 0) { |
|
355 | - $class_name = 'LEGACY_MODELS'; |
|
356 | - } |
|
357 | - $dependency = $this->getFqnForAlias($dependency); |
|
358 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
359 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
360 | - : EE_Dependency_Map::not_registered; |
|
361 | - } |
|
362 | - |
|
363 | - |
|
364 | - /** |
|
365 | - * @param string $class_name |
|
366 | - * @return string | Closure |
|
367 | - */ |
|
368 | - public function class_loader(string $class_name) |
|
369 | - { |
|
370 | - // all legacy models use load_model() |
|
371 | - if (strpos($class_name, 'EEM_') === 0) { |
|
372 | - return 'load_model'; |
|
373 | - } |
|
374 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
375 | - // perform strpos() first to avoid loading regex every time we load a class |
|
376 | - if ( |
|
377 | - strpos($class_name, 'EE_CPT_') === 0 |
|
378 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
379 | - ) { |
|
380 | - return 'load_core'; |
|
381 | - } |
|
382 | - $class_name = $this->getFqnForAlias($class_name); |
|
383 | - return $this->_class_loaders[ $class_name ] ?? ''; |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * @return array |
|
389 | - */ |
|
390 | - public function class_loaders(): array |
|
391 | - { |
|
392 | - return $this->_class_loaders; |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * adds an alias for a classname |
|
398 | - * |
|
399 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
400 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
401 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
402 | - * @throws InvalidAliasException |
|
403 | - */ |
|
404 | - public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
405 | - { |
|
406 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
407 | - } |
|
408 | - |
|
409 | - |
|
410 | - /** |
|
411 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
412 | - * WHY? |
|
413 | - * Because if a class is type hinting for a concretion, |
|
414 | - * then why would we need to find another class to supply it? |
|
415 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
416 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
417 | - * Don't go looking for some substitute. |
|
418 | - * Whereas if a class is type hinting for an interface... |
|
419 | - * then we need to find an actual class to use. |
|
420 | - * So the interface IS the alias for some other FQN, |
|
421 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
422 | - * represents some other class. |
|
423 | - * |
|
424 | - * @param string $fqn |
|
425 | - * @param string $for_class |
|
426 | - * @return bool |
|
427 | - */ |
|
428 | - public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
429 | - { |
|
430 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - /** |
|
435 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
436 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
437 | - * for example: |
|
438 | - * if the following two entries were added to the _aliases array: |
|
439 | - * array( |
|
440 | - * 'interface_alias' => 'some\namespace\interface' |
|
441 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
442 | - * ) |
|
443 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
444 | - * to load an instance of 'some\namespace\classname' |
|
445 | - * |
|
446 | - * @param string $alias |
|
447 | - * @param string $for_class |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
451 | - { |
|
452 | - return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
453 | - } |
|
454 | - |
|
455 | - |
|
456 | - /** |
|
457 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
458 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
459 | - * This is done by using the following class constants: |
|
460 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
461 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
462 | - */ |
|
463 | - protected function _register_core_dependencies() |
|
464 | - { |
|
465 | - $this->_dependency_map = [ |
|
466 | - 'EE_Admin' => [ |
|
467 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
469 | - ], |
|
470 | - 'EE_Request_Handler' => [ |
|
471 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | - 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
473 | - ], |
|
474 | - 'EE_System' => [ |
|
475 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
476 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
477 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
478 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
479 | - 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
480 | - ], |
|
481 | - 'EE_Session' => [ |
|
482 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
483 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
484 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
485 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
486 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
487 | - ], |
|
488 | - 'EE_Cart' => [ |
|
489 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
490 | - ], |
|
491 | - 'EE_Messenger_Collection_Loader' => [ |
|
492 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
493 | - ], |
|
494 | - 'EE_Message_Type_Collection_Loader' => [ |
|
495 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | - ], |
|
497 | - 'EE_Message_Resource_Manager' => [ |
|
498 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
499 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
500 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | - ], |
|
502 | - 'EE_Message_Factory' => [ |
|
503 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
504 | - ], |
|
505 | - 'EE_messages' => [ |
|
506 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
507 | - ], |
|
508 | - 'EE_Messages_Generator' => [ |
|
509 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
510 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
511 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
512 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
513 | - ], |
|
514 | - 'EE_Messages_Processor' => [ |
|
515 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
516 | - ], |
|
517 | - 'EE_Messages_Queue' => [ |
|
518 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
519 | - ], |
|
520 | - 'EE_Messages_Template_Defaults' => [ |
|
521 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
522 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
523 | - ], |
|
524 | - 'EE_Message_To_Generate_From_Request' => [ |
|
525 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
526 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
527 | - ], |
|
528 | - 'EventEspresso\core\services\commands\CommandBus' => [ |
|
529 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
530 | - ], |
|
531 | - 'EventEspresso\services\commands\CommandHandler' => [ |
|
532 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
533 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
534 | - ], |
|
535 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
536 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
537 | - ], |
|
538 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
539 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
540 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
541 | - ], |
|
542 | - 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
543 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
544 | - ], |
|
545 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
546 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
547 | - ], |
|
548 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
549 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
550 | - ], |
|
551 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
552 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
553 | - ], |
|
554 | - 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
555 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
556 | - ], |
|
557 | - 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
558 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
559 | - ], |
|
560 | - 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
561 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
562 | - ], |
|
563 | - 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
564 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
565 | - ], |
|
566 | - 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
567 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
568 | - ], |
|
569 | - 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
570 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
571 | - ], |
|
572 | - 'EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
573 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
574 | - ], |
|
575 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
576 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
577 | - ], |
|
578 | - 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
579 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
580 | - ], |
|
581 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => [ |
|
582 | - 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
583 | - ], |
|
584 | - 'EventEspresso\caffeinated\admin\extend\registration_form\forms\SessionLifespanForm' => [ |
|
585 | - 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
586 | - ], |
|
587 | - 'EventEspresso\caffeinated\admin\extend\registration_form\forms\SessionLifespanFormHandler' => [ |
|
588 | - 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
589 | - ], |
|
590 | - 'EventEspresso\core\services\database\TableManager' => [ |
|
591 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | - ], |
|
593 | - 'EE_Data_Migration_Class_Base' => [ |
|
594 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | - ], |
|
597 | - 'EE_DMS_Core_4_1_0' => [ |
|
598 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | - ], |
|
601 | - 'EE_DMS_Core_4_2_0' => [ |
|
602 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | - ], |
|
605 | - 'EE_DMS_Core_4_3_0' => [ |
|
606 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | - ], |
|
609 | - 'EE_DMS_Core_4_4_0' => [ |
|
610 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | - ], |
|
613 | - 'EE_DMS_Core_4_5_0' => [ |
|
614 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | - ], |
|
617 | - 'EE_DMS_Core_4_6_0' => [ |
|
618 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
619 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
620 | - ], |
|
621 | - 'EE_DMS_Core_4_7_0' => [ |
|
622 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
623 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
624 | - ], |
|
625 | - 'EE_DMS_Core_4_8_0' => [ |
|
626 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
627 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
628 | - ], |
|
629 | - 'EE_DMS_Core_4_9_0' => [ |
|
630 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
631 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
632 | - ], |
|
633 | - 'EE_DMS_Core_4_10_0' => [ |
|
634 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
635 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
636 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
637 | - ], |
|
638 | - 'EE_DMS_Core_4_11_0' => [ |
|
639 | - 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
640 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
641 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
642 | - ], |
|
643 | - 'EE_DMS_Core_4_12_0' => [ |
|
644 | - 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
645 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
646 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
647 | - ], |
|
648 | - 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
649 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
650 | - ], |
|
651 | - 'EventEspresso\core\services\assets\Registry' => [ |
|
652 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
653 | - 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
654 | - ], |
|
655 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
656 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
657 | - ], |
|
658 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
659 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
660 | - ], |
|
661 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
662 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
663 | - ], |
|
664 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
665 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
666 | - ], |
|
667 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
668 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
669 | - ], |
|
670 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
671 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
672 | - ], |
|
673 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
674 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
675 | - ], |
|
676 | - 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
677 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
678 | - ], |
|
679 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
680 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
681 | - ], |
|
682 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
683 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
684 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
685 | - ], |
|
686 | - 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
687 | - null, |
|
688 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
689 | - ], |
|
690 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
691 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
692 | - ], |
|
693 | - 'LEGACY_MODELS' => [ |
|
694 | - null, |
|
695 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
696 | - ], |
|
697 | - 'EE_Module_Request_Router' => [ |
|
698 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
699 | - ], |
|
700 | - 'EE_Registration_Processor' => [ |
|
701 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
702 | - ], |
|
703 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
704 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
705 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | - ], |
|
707 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
708 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
709 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
710 | - ], |
|
711 | - 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
712 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
713 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
714 | - 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | - ], |
|
716 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
717 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
718 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
719 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
720 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
721 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
722 | - ], |
|
723 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
724 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
725 | - ], |
|
726 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
727 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
728 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
729 | - ], |
|
730 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
731 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
732 | - ], |
|
733 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
734 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
735 | - ], |
|
736 | - 'EE_CPT_Strategy' => [ |
|
737 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
738 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
739 | - ], |
|
740 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
741 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
742 | - ], |
|
743 | - 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
744 | - null, |
|
745 | - null, |
|
746 | - null, |
|
747 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
748 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
749 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
750 | - ], |
|
751 | - 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
752 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
753 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
754 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
755 | - ], |
|
756 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
757 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
758 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
759 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
760 | - ], |
|
761 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
762 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
763 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | - ], |
|
765 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
766 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
767 | - 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
768 | - ], |
|
769 | - 'EE_URL_Validation_Strategy' => [ |
|
770 | - null, |
|
771 | - null, |
|
772 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
773 | - ], |
|
774 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
775 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
776 | - ], |
|
777 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
778 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
779 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
780 | - ], |
|
781 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
782 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
783 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
784 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
785 | - null, |
|
786 | - ], |
|
787 | - 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
788 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
789 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
790 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
791 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
792 | - 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
793 | - ], |
|
794 | - 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
795 | - 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
796 | - ], |
|
797 | - 'EventEspresso\core\services\routing\Router' => [ |
|
798 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
799 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
800 | - 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
801 | - ], |
|
802 | - 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
803 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
804 | - ], |
|
805 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
806 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
807 | - ], |
|
808 | - 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
809 | - 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
810 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
811 | - ], |
|
812 | - 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
813 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
814 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
815 | - ], |
|
816 | - 'EventEspresso\core\services\addon\AddonManager' => [ |
|
817 | - 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
818 | - 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
819 | - 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
820 | - 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
821 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
822 | - ], |
|
823 | - 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
824 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
825 | - ], |
|
826 | - 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
827 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
828 | - ], |
|
829 | - 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
830 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
831 | - ], |
|
832 | - 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
833 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
834 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
835 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
836 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
837 | - ], |
|
838 | - 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
839 | - 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
840 | - ], |
|
841 | - 'EventEspresso\core\services\request\CurrentPage' => [ |
|
842 | - 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
843 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
844 | - ], |
|
845 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
846 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
847 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
848 | - ], |
|
849 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
850 | - 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
851 | - 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
852 | - ], |
|
853 | - 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
854 | - 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
855 | - ], |
|
856 | - 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
857 | - 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
858 | - 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
859 | - 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
860 | - 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
861 | - 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
862 | - 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
863 | - 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
864 | - 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
865 | - ], |
|
866 | - 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
867 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
868 | - ], |
|
869 | - 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
870 | - 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
871 | - ], |
|
872 | - 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
873 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
874 | - ], |
|
875 | - ]; |
|
876 | - } |
|
877 | - |
|
878 | - |
|
879 | - /** |
|
880 | - * Registers how core classes are loaded. |
|
881 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
882 | - * 'EE_Request_Handler' => 'load_core' |
|
883 | - * 'EE_Messages_Queue' => 'load_lib' |
|
884 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
885 | - * or, if greater control is required, by providing a custom closure. For example: |
|
886 | - * 'Some_Class' => function () { |
|
887 | - * return new Some_Class(); |
|
888 | - * }, |
|
889 | - * This is required for instantiating dependencies |
|
890 | - * where an interface has been type hinted in a class constructor. For example: |
|
891 | - * 'Required_Interface' => function () { |
|
892 | - * return new A_Class_That_Implements_Required_Interface(); |
|
893 | - * }, |
|
894 | - */ |
|
895 | - protected function _register_core_class_loaders() |
|
896 | - { |
|
897 | - $this->_class_loaders = [ |
|
898 | - // load_core |
|
899 | - 'EE_Dependency_Map' => function () { |
|
900 | - return $this; |
|
901 | - }, |
|
902 | - 'EE_Capabilities' => 'load_core', |
|
903 | - 'EE_Encryption' => 'load_core', |
|
904 | - 'EE_Front_Controller' => 'load_core', |
|
905 | - 'EE_Module_Request_Router' => 'load_core', |
|
906 | - 'EE_Registry' => 'load_core', |
|
907 | - 'EE_Request' => function () { |
|
908 | - return $this->legacy_request; |
|
909 | - }, |
|
910 | - 'EventEspresso\core\services\request\Request' => function () { |
|
911 | - return $this->request; |
|
912 | - }, |
|
913 | - 'EventEspresso\core\services\request\Response' => function () { |
|
914 | - return $this->response; |
|
915 | - }, |
|
916 | - 'EE_Base' => 'load_core', |
|
917 | - 'EE_Request_Handler' => 'load_core', |
|
918 | - 'EE_Session' => 'load_core', |
|
919 | - 'EE_Cron_Tasks' => 'load_core', |
|
920 | - 'EE_System' => 'load_core', |
|
921 | - 'EE_Maintenance_Mode' => 'load_core', |
|
922 | - 'EE_Register_CPTs' => 'load_core', |
|
923 | - 'EE_Admin' => 'load_core', |
|
924 | - 'EE_CPT_Strategy' => 'load_core', |
|
925 | - // load_class |
|
926 | - 'EE_Registration_Processor' => 'load_class', |
|
927 | - // load_lib |
|
928 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
929 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
930 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
931 | - 'EE_Messenger_Collection' => 'load_lib', |
|
932 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
933 | - 'EE_Messages_Processor' => 'load_lib', |
|
934 | - 'EE_Message_Repository' => 'load_lib', |
|
935 | - 'EE_Messages_Queue' => 'load_lib', |
|
936 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
937 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
938 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
939 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
940 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
941 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
942 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
943 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
944 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
945 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
946 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
947 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
948 | - 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
949 | - 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
950 | - 'EE_Messages_Generator' => static function () { |
|
951 | - return EE_Registry::instance()->load_lib( |
|
952 | - 'Messages_Generator', |
|
953 | - [], |
|
954 | - false, |
|
955 | - false |
|
956 | - ); |
|
957 | - }, |
|
958 | - 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
959 | - return EE_Registry::instance()->load_lib( |
|
960 | - 'Messages_Template_Defaults', |
|
961 | - $arguments, |
|
962 | - false, |
|
963 | - false |
|
964 | - ); |
|
965 | - }, |
|
966 | - // load_helper |
|
967 | - 'EEH_Parse_Shortcodes' => static function () { |
|
968 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
969 | - return new EEH_Parse_Shortcodes(); |
|
970 | - } |
|
971 | - return null; |
|
972 | - }, |
|
973 | - 'EE_Template_Config' => static function () { |
|
974 | - return EE_Config::instance()->template_settings; |
|
975 | - }, |
|
976 | - 'EE_Currency_Config' => static function () { |
|
977 | - return EE_Currency_Config::getCurrencyConfig(); |
|
978 | - }, |
|
979 | - 'EE_Registration_Config' => static function () { |
|
980 | - return EE_Config::instance()->registration; |
|
981 | - }, |
|
982 | - 'EE_Core_Config' => static function () { |
|
983 | - return EE_Config::instance()->core; |
|
984 | - }, |
|
985 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
986 | - return LoaderFactory::getLoader(); |
|
987 | - }, |
|
988 | - 'EE_Network_Config' => static function () { |
|
989 | - return EE_Network_Config::instance(); |
|
990 | - }, |
|
991 | - 'EE_Config' => static function () { |
|
992 | - return EE_Config::instance(); |
|
993 | - }, |
|
994 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
995 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
996 | - }, |
|
997 | - 'EE_Admin_Config' => static function () { |
|
998 | - return EE_Config::instance()->admin; |
|
999 | - }, |
|
1000 | - 'EE_Organization_Config' => static function () { |
|
1001 | - return EE_Config::instance()->organization; |
|
1002 | - }, |
|
1003 | - 'EE_Network_Core_Config' => static function () { |
|
1004 | - return EE_Network_Config::instance()->core; |
|
1005 | - }, |
|
1006 | - 'EE_Environment_Config' => static function () { |
|
1007 | - return EE_Config::instance()->environment; |
|
1008 | - }, |
|
1009 | - 'EED_Core_Rest_Api' => static function () { |
|
1010 | - return EED_Core_Rest_Api::instance(); |
|
1011 | - }, |
|
1012 | - 'WP_REST_Server' => static function () { |
|
1013 | - return rest_get_server(); |
|
1014 | - }, |
|
1015 | - 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
1016 | - return EE_Psr4AutoloaderInit::psr4_loader(); |
|
1017 | - }, |
|
1018 | - 'EE_Ticket_Selector_Config' => function () { |
|
1019 | - return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1020 | - }, |
|
1021 | - ]; |
|
1022 | - } |
|
1023 | - |
|
1024 | - |
|
1025 | - /** |
|
1026 | - * can be used for supplying alternate names for classes, |
|
1027 | - * or for connecting interface names to instantiable classes |
|
1028 | - * |
|
1029 | - * @throws InvalidAliasException |
|
1030 | - */ |
|
1031 | - protected function _register_core_aliases() |
|
1032 | - { |
|
1033 | - $aliases = [ |
|
1034 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1035 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1036 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1037 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1038 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1039 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1040 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1041 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1042 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1043 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1044 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand', |
|
1045 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1046 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1047 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1048 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1049 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand', |
|
1050 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommandHandler', |
|
1051 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1052 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1053 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1054 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1055 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1056 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1057 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1058 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1059 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1060 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1061 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1062 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1063 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1064 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1065 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1066 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1067 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1068 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1069 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1070 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1071 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
1072 | - 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1073 | - ]; |
|
1074 | - foreach ($aliases as $alias => $fqn) { |
|
1075 | - if (is_array($fqn)) { |
|
1076 | - foreach ($fqn as $class => $for_class) { |
|
1077 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
1078 | - } |
|
1079 | - continue; |
|
1080 | - } |
|
1081 | - $this->class_cache->addAlias($fqn, $alias); |
|
1082 | - } |
|
1083 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1084 | - $this->class_cache->addAlias( |
|
1085 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1086 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1087 | - ); |
|
1088 | - } |
|
1089 | - } |
|
1090 | - |
|
1091 | - |
|
1092 | - public function debug($for_class = '') |
|
1093 | - { |
|
1094 | - if (method_exists($this->class_cache, 'debug')) { |
|
1095 | - $this->class_cache->debug($for_class); |
|
1096 | - } |
|
1097 | - } |
|
1098 | - |
|
1099 | - |
|
1100 | - /** |
|
1101 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1102 | - * request Primarily used by unit tests. |
|
1103 | - */ |
|
1104 | - public function reset() |
|
1105 | - { |
|
1106 | - $this->_register_core_class_loaders(); |
|
1107 | - $this->_register_core_dependencies(); |
|
1108 | - } |
|
1109 | - |
|
1110 | - |
|
1111 | - /** |
|
1112 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
1113 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
1114 | - * WHY? |
|
1115 | - * Because if a class is type hinting for a concretion, |
|
1116 | - * then why would we need to find another class to supply it? |
|
1117 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1118 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1119 | - * Don't go looking for some substitute. |
|
1120 | - * Whereas if a class is type hinting for an interface... |
|
1121 | - * then we need to find an actual class to use. |
|
1122 | - * So the interface IS the alias for some other FQN, |
|
1123 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1124 | - * represents some other class. |
|
1125 | - * |
|
1126 | - * @param string $fqn |
|
1127 | - * @param string $for_class |
|
1128 | - * @return bool |
|
1129 | - * @deprecated 4.9.62.p |
|
1130 | - */ |
|
1131 | - public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
1132 | - { |
|
1133 | - return $this->isAlias($fqn, $for_class); |
|
1134 | - } |
|
1135 | - |
|
1136 | - |
|
1137 | - /** |
|
1138 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1139 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1140 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1141 | - * for example: |
|
1142 | - * if the following two entries were added to the _aliases array: |
|
1143 | - * array( |
|
1144 | - * 'interface_alias' => 'some\namespace\interface' |
|
1145 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
1146 | - * ) |
|
1147 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1148 | - * to load an instance of 'some\namespace\classname' |
|
1149 | - * |
|
1150 | - * @param string $alias |
|
1151 | - * @param string $for_class |
|
1152 | - * @return string |
|
1153 | - * @deprecated 4.9.62.p |
|
1154 | - */ |
|
1155 | - public function get_alias(string $alias = '', string $for_class = ''): string |
|
1156 | - { |
|
1157 | - return $this->getFqnForAlias($alias, $for_class); |
|
1158 | - } |
|
23 | + /** |
|
24 | + * This means that the requested class dependency is not present in the dependency map |
|
25 | + */ |
|
26 | + const not_registered = 0; |
|
27 | + |
|
28 | + /** |
|
29 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
30 | + */ |
|
31 | + const load_new_object = 1; |
|
32 | + |
|
33 | + /** |
|
34 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
35 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
36 | + */ |
|
37 | + const load_from_cache = 2; |
|
38 | + |
|
39 | + /** |
|
40 | + * When registering a dependency, |
|
41 | + * this indicates to keep any existing dependencies that already exist, |
|
42 | + * and simply discard any new dependencies declared in the incoming data |
|
43 | + */ |
|
44 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
45 | + |
|
46 | + /** |
|
47 | + * When registering a dependency, |
|
48 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
49 | + */ |
|
50 | + const OVERWRITE_DEPENDENCIES = 1; |
|
51 | + |
|
52 | + /** |
|
53 | + * @type EE_Dependency_Map $_instance |
|
54 | + */ |
|
55 | + protected static $_instance; |
|
56 | + |
|
57 | + /** |
|
58 | + * @var ClassInterfaceCache $class_cache |
|
59 | + */ |
|
60 | + private $class_cache; |
|
61 | + |
|
62 | + /** |
|
63 | + * @type RequestInterface $request |
|
64 | + */ |
|
65 | + protected $request; |
|
66 | + |
|
67 | + /** |
|
68 | + * @type LegacyRequestInterface $legacy_request |
|
69 | + */ |
|
70 | + protected $legacy_request; |
|
71 | + |
|
72 | + /** |
|
73 | + * @type ResponseInterface $response |
|
74 | + */ |
|
75 | + protected $response; |
|
76 | + |
|
77 | + /** |
|
78 | + * @type LoaderInterface $loader |
|
79 | + */ |
|
80 | + protected $loader; |
|
81 | + |
|
82 | + /** |
|
83 | + * @type array $_dependency_map |
|
84 | + */ |
|
85 | + protected $_dependency_map = []; |
|
86 | + |
|
87 | + /** |
|
88 | + * @type array $_class_loaders |
|
89 | + */ |
|
90 | + protected $_class_loaders = []; |
|
91 | + |
|
92 | + |
|
93 | + /** |
|
94 | + * EE_Dependency_Map constructor. |
|
95 | + * |
|
96 | + * @param ClassInterfaceCache $class_cache |
|
97 | + */ |
|
98 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
99 | + { |
|
100 | + $this->class_cache = $class_cache; |
|
101 | + do_action('EE_Dependency_Map____construct', $this); |
|
102 | + } |
|
103 | + |
|
104 | + |
|
105 | + /** |
|
106 | + * @return void |
|
107 | + * @throws InvalidAliasException |
|
108 | + */ |
|
109 | + public function initialize() |
|
110 | + { |
|
111 | + $this->_register_core_dependencies(); |
|
112 | + $this->_register_core_class_loaders(); |
|
113 | + $this->_register_core_aliases(); |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + /** |
|
118 | + * @singleton method used to instantiate class object |
|
119 | + * @param ClassInterfaceCache|null $class_cache |
|
120 | + * @return EE_Dependency_Map |
|
121 | + */ |
|
122 | + public static function instance(ClassInterfaceCache $class_cache = null): EE_Dependency_Map |
|
123 | + { |
|
124 | + // check if class object is instantiated, and instantiated properly |
|
125 | + if ( |
|
126 | + ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map |
|
127 | + && $class_cache instanceof ClassInterfaceCache |
|
128 | + ) { |
|
129 | + EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache); |
|
130 | + } |
|
131 | + return EE_Dependency_Map::$_instance; |
|
132 | + } |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * @param RequestInterface $request |
|
137 | + */ |
|
138 | + public function setRequest(RequestInterface $request) |
|
139 | + { |
|
140 | + $this->request = $request; |
|
141 | + } |
|
142 | + |
|
143 | + |
|
144 | + /** |
|
145 | + * @param LegacyRequestInterface $legacy_request |
|
146 | + */ |
|
147 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
148 | + { |
|
149 | + $this->legacy_request = $legacy_request; |
|
150 | + } |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * @param ResponseInterface $response |
|
155 | + */ |
|
156 | + public function setResponse(ResponseInterface $response) |
|
157 | + { |
|
158 | + $this->response = $response; |
|
159 | + } |
|
160 | + |
|
161 | + |
|
162 | + /** |
|
163 | + * @param LoaderInterface $loader |
|
164 | + */ |
|
165 | + public function setLoader(LoaderInterface $loader) |
|
166 | + { |
|
167 | + $this->loader = $loader; |
|
168 | + } |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * @param string $class |
|
173 | + * @param array $dependencies |
|
174 | + * @param int $overwrite |
|
175 | + * @return bool |
|
176 | + */ |
|
177 | + public static function register_dependencies( |
|
178 | + string $class, |
|
179 | + array $dependencies, |
|
180 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
181 | + ): bool { |
|
182 | + return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
183 | + } |
|
184 | + |
|
185 | + |
|
186 | + /** |
|
187 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
188 | + * to the class specified by the first parameter. |
|
189 | + * IMPORTANT !!! |
|
190 | + * The order of elements in the incoming $dependencies array MUST match |
|
191 | + * the order of the constructor parameters for the class in question. |
|
192 | + * This is especially important when overriding any existing dependencies that are registered. |
|
193 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
194 | + * |
|
195 | + * @param string $class |
|
196 | + * @param array $dependencies |
|
197 | + * @param int $overwrite |
|
198 | + * @return bool |
|
199 | + */ |
|
200 | + public function registerDependencies( |
|
201 | + string $class, |
|
202 | + array $dependencies, |
|
203 | + int $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
204 | + ): bool { |
|
205 | + $class = trim($class, '\\'); |
|
206 | + $registered = false; |
|
207 | + if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) { |
|
208 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = []; |
|
209 | + } |
|
210 | + // we need to make sure that any aliases used when registering a dependency |
|
211 | + // get resolved to the correct class name |
|
212 | + foreach ($dependencies as $dependency => $load_source) { |
|
213 | + $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency); |
|
214 | + if ( |
|
215 | + $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
216 | + || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ]) |
|
217 | + ) { |
|
218 | + unset($dependencies[ $dependency ]); |
|
219 | + $dependencies[ $alias ] = $load_source; |
|
220 | + $registered = true; |
|
221 | + } |
|
222 | + } |
|
223 | + // now add our two lists of dependencies together. |
|
224 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
225 | + // so $dependencies is NOT overwritten because it is listed first |
|
226 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
227 | + // Union is way faster than array_merge() but should be used with caution... |
|
228 | + // especially with numerically indexed arrays |
|
229 | + $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ]; |
|
230 | + // now we need to ensure that the resulting dependencies |
|
231 | + // array only has the entries that are required for the class |
|
232 | + // so first count how many dependencies were originally registered for the class |
|
233 | + $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]); |
|
234 | + // if that count is non-zero (meaning dependencies were already registered) |
|
235 | + EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count |
|
236 | + // then truncate the final array to match that count |
|
237 | + ? array_slice($dependencies, 0, $dependency_count) |
|
238 | + // otherwise just take the incoming array because nothing previously existed |
|
239 | + : $dependencies; |
|
240 | + return $registered; |
|
241 | + } |
|
242 | + |
|
243 | + |
|
244 | + /** |
|
245 | + * @param string $class_name |
|
246 | + * @param callable|string $loader |
|
247 | + * @param bool $overwrite |
|
248 | + * @return bool |
|
249 | + * @throws DomainException |
|
250 | + */ |
|
251 | + public static function register_class_loader( |
|
252 | + string $class_name, |
|
253 | + $loader = 'load_core', |
|
254 | + bool $overwrite = false |
|
255 | + ): bool { |
|
256 | + return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader, $overwrite); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * @param string $class_name |
|
262 | + * @param Closure|string $loader |
|
263 | + * @param bool $overwrite |
|
264 | + * @return bool |
|
265 | + * @throws DomainException |
|
266 | + */ |
|
267 | + public function registerClassLoader(string $class_name, $loader = 'load_core', bool $overwrite = false): bool |
|
268 | + { |
|
269 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
270 | + throw new DomainException( |
|
271 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
272 | + ); |
|
273 | + } |
|
274 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
275 | + if ( |
|
276 | + ! is_callable($loader) |
|
277 | + && ( |
|
278 | + strpos($loader, 'load_') !== 0 |
|
279 | + || ! method_exists('EE_Registry', $loader) |
|
280 | + ) |
|
281 | + ) { |
|
282 | + throw new DomainException( |
|
283 | + sprintf( |
|
284 | + esc_html__( |
|
285 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
286 | + 'event_espresso' |
|
287 | + ), |
|
288 | + $loader |
|
289 | + ) |
|
290 | + ); |
|
291 | + } |
|
292 | + $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name); |
|
293 | + if ($overwrite || ! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) { |
|
294 | + EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader; |
|
295 | + return true; |
|
296 | + } |
|
297 | + return false; |
|
298 | + } |
|
299 | + |
|
300 | + |
|
301 | + /** |
|
302 | + * @return array |
|
303 | + */ |
|
304 | + public function dependency_map(): array |
|
305 | + { |
|
306 | + return $this->_dependency_map; |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
312 | + * |
|
313 | + * @param string $class_name |
|
314 | + * @return boolean |
|
315 | + */ |
|
316 | + public function has(string $class_name = ''): bool |
|
317 | + { |
|
318 | + // all legacy models have the same dependencies |
|
319 | + if (strpos($class_name, 'EEM_') === 0) { |
|
320 | + $class_name = 'LEGACY_MODELS'; |
|
321 | + } |
|
322 | + return isset($this->_dependency_map[ $class_name ]); |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + /** |
|
327 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
328 | + * |
|
329 | + * @param string $class_name |
|
330 | + * @param string $dependency |
|
331 | + * @return bool |
|
332 | + */ |
|
333 | + public function has_dependency_for_class(string $class_name = '', string $dependency = ''): bool |
|
334 | + { |
|
335 | + // all legacy models have the same dependencies |
|
336 | + if (strpos($class_name, 'EEM_') === 0) { |
|
337 | + $class_name = 'LEGACY_MODELS'; |
|
338 | + } |
|
339 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
340 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + /** |
|
345 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
346 | + * |
|
347 | + * @param string $class_name |
|
348 | + * @param string $dependency |
|
349 | + * @return int |
|
350 | + */ |
|
351 | + public function loading_strategy_for_class_dependency(string $class_name = '', string $dependency = ''): int |
|
352 | + { |
|
353 | + // all legacy models have the same dependencies |
|
354 | + if (strpos($class_name, 'EEM_') === 0) { |
|
355 | + $class_name = 'LEGACY_MODELS'; |
|
356 | + } |
|
357 | + $dependency = $this->getFqnForAlias($dependency); |
|
358 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
359 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
360 | + : EE_Dependency_Map::not_registered; |
|
361 | + } |
|
362 | + |
|
363 | + |
|
364 | + /** |
|
365 | + * @param string $class_name |
|
366 | + * @return string | Closure |
|
367 | + */ |
|
368 | + public function class_loader(string $class_name) |
|
369 | + { |
|
370 | + // all legacy models use load_model() |
|
371 | + if (strpos($class_name, 'EEM_') === 0) { |
|
372 | + return 'load_model'; |
|
373 | + } |
|
374 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
375 | + // perform strpos() first to avoid loading regex every time we load a class |
|
376 | + if ( |
|
377 | + strpos($class_name, 'EE_CPT_') === 0 |
|
378 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
379 | + ) { |
|
380 | + return 'load_core'; |
|
381 | + } |
|
382 | + $class_name = $this->getFqnForAlias($class_name); |
|
383 | + return $this->_class_loaders[ $class_name ] ?? ''; |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * @return array |
|
389 | + */ |
|
390 | + public function class_loaders(): array |
|
391 | + { |
|
392 | + return $this->_class_loaders; |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * adds an alias for a classname |
|
398 | + * |
|
399 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
400 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
401 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
402 | + * @throws InvalidAliasException |
|
403 | + */ |
|
404 | + public function add_alias(string $fqcn, string $alias, string $for_class = '') |
|
405 | + { |
|
406 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
407 | + } |
|
408 | + |
|
409 | + |
|
410 | + /** |
|
411 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
412 | + * WHY? |
|
413 | + * Because if a class is type hinting for a concretion, |
|
414 | + * then why would we need to find another class to supply it? |
|
415 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
416 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
417 | + * Don't go looking for some substitute. |
|
418 | + * Whereas if a class is type hinting for an interface... |
|
419 | + * then we need to find an actual class to use. |
|
420 | + * So the interface IS the alias for some other FQN, |
|
421 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
422 | + * represents some other class. |
|
423 | + * |
|
424 | + * @param string $fqn |
|
425 | + * @param string $for_class |
|
426 | + * @return bool |
|
427 | + */ |
|
428 | + public function isAlias(string $fqn = '', string $for_class = ''): bool |
|
429 | + { |
|
430 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + /** |
|
435 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
436 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
437 | + * for example: |
|
438 | + * if the following two entries were added to the _aliases array: |
|
439 | + * array( |
|
440 | + * 'interface_alias' => 'some\namespace\interface' |
|
441 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
442 | + * ) |
|
443 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
444 | + * to load an instance of 'some\namespace\classname' |
|
445 | + * |
|
446 | + * @param string $alias |
|
447 | + * @param string $for_class |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function getFqnForAlias(string $alias = '', string $for_class = ''): string |
|
451 | + { |
|
452 | + return $this->class_cache->getFqnForAlias($alias, $for_class); |
|
453 | + } |
|
454 | + |
|
455 | + |
|
456 | + /** |
|
457 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
458 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
459 | + * This is done by using the following class constants: |
|
460 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
461 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
462 | + */ |
|
463 | + protected function _register_core_dependencies() |
|
464 | + { |
|
465 | + $this->_dependency_map = [ |
|
466 | + 'EE_Admin' => [ |
|
467 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
468 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
469 | + ], |
|
470 | + 'EE_Request_Handler' => [ |
|
471 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
472 | + 'EventEspresso\core\services\request\Response' => EE_Dependency_Map::load_from_cache, |
|
473 | + ], |
|
474 | + 'EE_System' => [ |
|
475 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
476 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
477 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
478 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
479 | + 'EventEspresso\core\services\routing\Router' => EE_Dependency_Map::load_from_cache, |
|
480 | + ], |
|
481 | + 'EE_Session' => [ |
|
482 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
483 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
484 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
485 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
486 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
487 | + ], |
|
488 | + 'EE_Cart' => [ |
|
489 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
490 | + ], |
|
491 | + 'EE_Messenger_Collection_Loader' => [ |
|
492 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
493 | + ], |
|
494 | + 'EE_Message_Type_Collection_Loader' => [ |
|
495 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
496 | + ], |
|
497 | + 'EE_Message_Resource_Manager' => [ |
|
498 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
499 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
500 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
501 | + ], |
|
502 | + 'EE_Message_Factory' => [ |
|
503 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
504 | + ], |
|
505 | + 'EE_messages' => [ |
|
506 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
507 | + ], |
|
508 | + 'EE_Messages_Generator' => [ |
|
509 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
510 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
511 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
512 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
513 | + ], |
|
514 | + 'EE_Messages_Processor' => [ |
|
515 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
516 | + ], |
|
517 | + 'EE_Messages_Queue' => [ |
|
518 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
519 | + ], |
|
520 | + 'EE_Messages_Template_Defaults' => [ |
|
521 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
522 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
523 | + ], |
|
524 | + 'EE_Message_To_Generate_From_Request' => [ |
|
525 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
526 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
527 | + ], |
|
528 | + 'EventEspresso\core\services\commands\CommandBus' => [ |
|
529 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
530 | + ], |
|
531 | + 'EventEspresso\services\commands\CommandHandler' => [ |
|
532 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
533 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
534 | + ], |
|
535 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => [ |
|
536 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
537 | + ], |
|
538 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => [ |
|
539 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
540 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
541 | + ], |
|
542 | + 'EventEspresso\core\services\commands\CommandFactory' => [ |
|
543 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
544 | + ], |
|
545 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => [ |
|
546 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
547 | + ], |
|
548 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => [ |
|
549 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
550 | + ], |
|
551 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => [ |
|
552 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
553 | + ], |
|
554 | + 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommandHandler' => [ |
|
555 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
556 | + ], |
|
557 | + 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommandHandler' => [ |
|
558 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
559 | + ], |
|
560 | + 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => [ |
|
561 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
562 | + ], |
|
563 | + 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => [ |
|
564 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
565 | + ], |
|
566 | + 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [ |
|
567 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
568 | + ], |
|
569 | + 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommandHandler' => [ |
|
570 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
571 | + ], |
|
572 | + 'EventEspresso\core\domain\services\commands\ticket\CancelTicketLineItemCommandHandler' => [ |
|
573 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
574 | + ], |
|
575 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => [ |
|
576 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
577 | + ], |
|
578 | + 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler' => [ |
|
579 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
580 | + ], |
|
581 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => [ |
|
582 | + 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
583 | + ], |
|
584 | + 'EventEspresso\caffeinated\admin\extend\registration_form\forms\SessionLifespanForm' => [ |
|
585 | + 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
586 | + ], |
|
587 | + 'EventEspresso\caffeinated\admin\extend\registration_form\forms\SessionLifespanFormHandler' => [ |
|
588 | + 'EventEspresso\core\domain\values\session\SessionLifespanOption' => EE_Dependency_Map::load_from_cache, |
|
589 | + ], |
|
590 | + 'EventEspresso\core\services\database\TableManager' => [ |
|
591 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
592 | + ], |
|
593 | + 'EE_Data_Migration_Class_Base' => [ |
|
594 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
595 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
596 | + ], |
|
597 | + 'EE_DMS_Core_4_1_0' => [ |
|
598 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
599 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
600 | + ], |
|
601 | + 'EE_DMS_Core_4_2_0' => [ |
|
602 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
603 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
604 | + ], |
|
605 | + 'EE_DMS_Core_4_3_0' => [ |
|
606 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
607 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
608 | + ], |
|
609 | + 'EE_DMS_Core_4_4_0' => [ |
|
610 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
611 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
612 | + ], |
|
613 | + 'EE_DMS_Core_4_5_0' => [ |
|
614 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
615 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
616 | + ], |
|
617 | + 'EE_DMS_Core_4_6_0' => [ |
|
618 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
619 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
620 | + ], |
|
621 | + 'EE_DMS_Core_4_7_0' => [ |
|
622 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
623 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
624 | + ], |
|
625 | + 'EE_DMS_Core_4_8_0' => [ |
|
626 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
627 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
628 | + ], |
|
629 | + 'EE_DMS_Core_4_9_0' => [ |
|
630 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
631 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
632 | + ], |
|
633 | + 'EE_DMS_Core_4_10_0' => [ |
|
634 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
635 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
636 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
637 | + ], |
|
638 | + 'EE_DMS_Core_4_11_0' => [ |
|
639 | + 'EE_DMS_Core_4_10_0' => EE_Dependency_Map::load_from_cache, |
|
640 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
641 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
642 | + ], |
|
643 | + 'EE_DMS_Core_4_12_0' => [ |
|
644 | + 'EE_DMS_Core_4_11_0' => EE_Dependency_Map::load_from_cache, |
|
645 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
646 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
647 | + ], |
|
648 | + 'EventEspresso\core\services\assets\I18nRegistry' => [ |
|
649 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
650 | + ], |
|
651 | + 'EventEspresso\core\services\assets\Registry' => [ |
|
652 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
653 | + 'EventEspresso\core\services\assets\AssetManifest' => EE_Dependency_Map::load_from_cache, |
|
654 | + ], |
|
655 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => [ |
|
656 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
657 | + ], |
|
658 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => [ |
|
659 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
660 | + ], |
|
661 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => [ |
|
662 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
663 | + ], |
|
664 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => [ |
|
665 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
666 | + ], |
|
667 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => [ |
|
668 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
669 | + ], |
|
670 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => [ |
|
671 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
672 | + ], |
|
673 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => [ |
|
674 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
675 | + ], |
|
676 | + 'EventEspresso\core\services\cache\BasicCacheManager' => [ |
|
677 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
678 | + ], |
|
679 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => [ |
|
680 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
681 | + ], |
|
682 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => [ |
|
683 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
684 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
685 | + ], |
|
686 | + 'EventEspresso\core\domain\values\EmailAddress' => [ |
|
687 | + null, |
|
688 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
689 | + ], |
|
690 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => [ |
|
691 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
692 | + ], |
|
693 | + 'LEGACY_MODELS' => [ |
|
694 | + null, |
|
695 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
696 | + ], |
|
697 | + 'EE_Module_Request_Router' => [ |
|
698 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
699 | + ], |
|
700 | + 'EE_Registration_Processor' => [ |
|
701 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
702 | + ], |
|
703 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => [ |
|
704 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
705 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
706 | + ], |
|
707 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => [ |
|
708 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
709 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
710 | + ], |
|
711 | + 'EventEspresso\modules\ticket_selector\DisplayTicketSelector' => [ |
|
712 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => EE_Dependency_Map::load_from_cache, |
|
713 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
714 | + 'EE_Ticket_Selector_Config' => EE_Dependency_Map::load_from_cache, |
|
715 | + ], |
|
716 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => [ |
|
717 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
718 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
719 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
720 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
721 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
722 | + ], |
|
723 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => [ |
|
724 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
725 | + ], |
|
726 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => [ |
|
727 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
728 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
729 | + ], |
|
730 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => [ |
|
731 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
732 | + ], |
|
733 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => [ |
|
734 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
735 | + ], |
|
736 | + 'EE_CPT_Strategy' => [ |
|
737 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
738 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
739 | + ], |
|
740 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => [ |
|
741 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
742 | + ], |
|
743 | + 'EventEspresso\core\CPTs\CptQueryModifier' => [ |
|
744 | + null, |
|
745 | + null, |
|
746 | + null, |
|
747 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
748 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
749 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
750 | + ], |
|
751 | + 'EventEspresso\core\services\dependencies\DependencyResolver' => [ |
|
752 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
753 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
754 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
755 | + ], |
|
756 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => [ |
|
757 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
758 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
759 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
760 | + ], |
|
761 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => [ |
|
762 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
763 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
764 | + ], |
|
765 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationManager' => [ |
|
766 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
767 | + 'EventEspresso\core\services\routing\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
768 | + ], |
|
769 | + 'EE_URL_Validation_Strategy' => [ |
|
770 | + null, |
|
771 | + null, |
|
772 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache, |
|
773 | + ], |
|
774 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => [ |
|
775 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
776 | + ], |
|
777 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
778 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
779 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
780 | + ], |
|
781 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
782 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
783 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
784 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
785 | + null, |
|
786 | + ], |
|
787 | + 'EventEspresso\core\services\routing\RouteHandler' => [ |
|
788 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
789 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => EE_Dependency_Map::load_from_cache, |
|
790 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
791 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
792 | + 'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache, |
|
793 | + ], |
|
794 | + 'EventEspresso\core\services\json\JsonDataNodeHandler' => [ |
|
795 | + 'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache, |
|
796 | + ], |
|
797 | + 'EventEspresso\core\services\routing\Router' => [ |
|
798 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
799 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
800 | + 'EventEspresso\core\services\routing\RouteHandler' => EE_Dependency_Map::load_from_cache, |
|
801 | + ], |
|
802 | + 'EventEspresso\core\services\assets\AssetManifest' => [ |
|
803 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
804 | + ], |
|
805 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => [ |
|
806 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
807 | + ], |
|
808 | + 'EventEspresso\core\services\assets\BaristaFactory' => [ |
|
809 | + 'EventEspresso\core\services\assets\AssetManifestFactory' => EE_Dependency_Map::load_from_cache, |
|
810 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
811 | + ], |
|
812 | + 'EventEspresso\core\domain\services\capabilities\FeatureFlags' => [ |
|
813 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
814 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
815 | + ], |
|
816 | + 'EventEspresso\core\services\addon\AddonManager' => [ |
|
817 | + 'EventEspresso\core\services\addon\AddonCollection' => EE_Dependency_Map::load_from_cache, |
|
818 | + 'EventEspresso\core\Psr4Autoloader' => EE_Dependency_Map::load_from_cache, |
|
819 | + 'EventEspresso\core\services\addon\api\v1\RegisterAddon' => EE_Dependency_Map::load_from_cache, |
|
820 | + 'EventEspresso\core\services\addon\api\IncompatibleAddonHandler' => EE_Dependency_Map::load_from_cache, |
|
821 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => EE_Dependency_Map::load_from_cache, |
|
822 | + ], |
|
823 | + 'EventEspresso\core\services\addon\api\ThirdPartyPluginHandler' => [ |
|
824 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
825 | + ], |
|
826 | + 'EventEspressoBatchRequest\JobHandlers\ExecuteBatchDeletion' => [ |
|
827 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
828 | + ], |
|
829 | + 'EventEspressoBatchRequest\JobHandlers\PreviewEventDeletion' => [ |
|
830 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
831 | + ], |
|
832 | + 'EventEspresso\core\domain\services\admin\events\data\PreviewDeletion' => [ |
|
833 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
834 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
835 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
836 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
837 | + ], |
|
838 | + 'EventEspresso\core\domain\services\admin\events\data\ConfirmDeletion' => [ |
|
839 | + 'EventEspresso\core\services\orm\tree_traversal\NodeGroupDao' => EE_Dependency_Map::load_from_cache, |
|
840 | + ], |
|
841 | + 'EventEspresso\core\services\request\CurrentPage' => [ |
|
842 | + 'EE_CPT_Strategy' => EE_Dependency_Map::load_from_cache, |
|
843 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
844 | + ], |
|
845 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => [ |
|
846 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
847 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
848 | + ], |
|
849 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager' => [ |
|
850 | + 'EventEspresso\core\services\shortcodes\LegacyShortcodesManager' => EE_Dependency_Map::load_from_cache, |
|
851 | + 'EventEspresso\core\services\request\CurrentPage' => EE_Dependency_Map::load_from_cache, |
|
852 | + ], |
|
853 | + 'EventEspresso\core\domain\entities\users\CurrentUser' => [ |
|
854 | + 'EventEspresso\core\domain\entities\users\EventManagers' => EE_Dependency_Map::load_from_cache, |
|
855 | + ], |
|
856 | + 'EventEspresso\core\services\form\meta\InputTypes' => [ |
|
857 | + 'EventEspresso\core\services\form\meta\inputs\Block' => EE_Dependency_Map::load_from_cache, |
|
858 | + 'EventEspresso\core\services\form\meta\inputs\Button' => EE_Dependency_Map::load_from_cache, |
|
859 | + 'EventEspresso\core\services\form\meta\inputs\DateTime' => EE_Dependency_Map::load_from_cache, |
|
860 | + 'EventEspresso\core\services\form\meta\inputs\Input' => EE_Dependency_Map::load_from_cache, |
|
861 | + 'EventEspresso\core\services\form\meta\inputs\Number' => EE_Dependency_Map::load_from_cache, |
|
862 | + 'EventEspresso\core\services\form\meta\inputs\Phone' => EE_Dependency_Map::load_from_cache, |
|
863 | + 'EventEspresso\core\services\form\meta\inputs\Select' => EE_Dependency_Map::load_from_cache, |
|
864 | + 'EventEspresso\core\services\form\meta\inputs\Text' => EE_Dependency_Map::load_from_cache, |
|
865 | + ], |
|
866 | + 'EventEspresso\core\domain\services\registration\form\v1\RegFormDependencyHandler' => [ |
|
867 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
868 | + ], |
|
869 | + 'EventEspresso\core\services\calculators\LineItemCalculator' => [ |
|
870 | + 'EventEspresso\core\services\helpers\DecimalValues' => EE_Dependency_Map::load_from_cache, |
|
871 | + ], |
|
872 | + 'EventEspresso\core\services\helpers\DecimalValues' => [ |
|
873 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
874 | + ], |
|
875 | + ]; |
|
876 | + } |
|
877 | + |
|
878 | + |
|
879 | + /** |
|
880 | + * Registers how core classes are loaded. |
|
881 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
882 | + * 'EE_Request_Handler' => 'load_core' |
|
883 | + * 'EE_Messages_Queue' => 'load_lib' |
|
884 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
885 | + * or, if greater control is required, by providing a custom closure. For example: |
|
886 | + * 'Some_Class' => function () { |
|
887 | + * return new Some_Class(); |
|
888 | + * }, |
|
889 | + * This is required for instantiating dependencies |
|
890 | + * where an interface has been type hinted in a class constructor. For example: |
|
891 | + * 'Required_Interface' => function () { |
|
892 | + * return new A_Class_That_Implements_Required_Interface(); |
|
893 | + * }, |
|
894 | + */ |
|
895 | + protected function _register_core_class_loaders() |
|
896 | + { |
|
897 | + $this->_class_loaders = [ |
|
898 | + // load_core |
|
899 | + 'EE_Dependency_Map' => function () { |
|
900 | + return $this; |
|
901 | + }, |
|
902 | + 'EE_Capabilities' => 'load_core', |
|
903 | + 'EE_Encryption' => 'load_core', |
|
904 | + 'EE_Front_Controller' => 'load_core', |
|
905 | + 'EE_Module_Request_Router' => 'load_core', |
|
906 | + 'EE_Registry' => 'load_core', |
|
907 | + 'EE_Request' => function () { |
|
908 | + return $this->legacy_request; |
|
909 | + }, |
|
910 | + 'EventEspresso\core\services\request\Request' => function () { |
|
911 | + return $this->request; |
|
912 | + }, |
|
913 | + 'EventEspresso\core\services\request\Response' => function () { |
|
914 | + return $this->response; |
|
915 | + }, |
|
916 | + 'EE_Base' => 'load_core', |
|
917 | + 'EE_Request_Handler' => 'load_core', |
|
918 | + 'EE_Session' => 'load_core', |
|
919 | + 'EE_Cron_Tasks' => 'load_core', |
|
920 | + 'EE_System' => 'load_core', |
|
921 | + 'EE_Maintenance_Mode' => 'load_core', |
|
922 | + 'EE_Register_CPTs' => 'load_core', |
|
923 | + 'EE_Admin' => 'load_core', |
|
924 | + 'EE_CPT_Strategy' => 'load_core', |
|
925 | + // load_class |
|
926 | + 'EE_Registration_Processor' => 'load_class', |
|
927 | + // load_lib |
|
928 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
929 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
930 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
931 | + 'EE_Messenger_Collection' => 'load_lib', |
|
932 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
933 | + 'EE_Messages_Processor' => 'load_lib', |
|
934 | + 'EE_Message_Repository' => 'load_lib', |
|
935 | + 'EE_Messages_Queue' => 'load_lib', |
|
936 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
937 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
938 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
939 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
940 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
941 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
942 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
943 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
944 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
945 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
946 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
947 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
948 | + 'EE_DMS_Core_4_11_0' => 'load_dms', |
|
949 | + 'EE_DMS_Core_4_12_0' => 'load_dms', |
|
950 | + 'EE_Messages_Generator' => static function () { |
|
951 | + return EE_Registry::instance()->load_lib( |
|
952 | + 'Messages_Generator', |
|
953 | + [], |
|
954 | + false, |
|
955 | + false |
|
956 | + ); |
|
957 | + }, |
|
958 | + 'EE_Messages_Template_Defaults' => static function ($arguments = []) { |
|
959 | + return EE_Registry::instance()->load_lib( |
|
960 | + 'Messages_Template_Defaults', |
|
961 | + $arguments, |
|
962 | + false, |
|
963 | + false |
|
964 | + ); |
|
965 | + }, |
|
966 | + // load_helper |
|
967 | + 'EEH_Parse_Shortcodes' => static function () { |
|
968 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
969 | + return new EEH_Parse_Shortcodes(); |
|
970 | + } |
|
971 | + return null; |
|
972 | + }, |
|
973 | + 'EE_Template_Config' => static function () { |
|
974 | + return EE_Config::instance()->template_settings; |
|
975 | + }, |
|
976 | + 'EE_Currency_Config' => static function () { |
|
977 | + return EE_Currency_Config::getCurrencyConfig(); |
|
978 | + }, |
|
979 | + 'EE_Registration_Config' => static function () { |
|
980 | + return EE_Config::instance()->registration; |
|
981 | + }, |
|
982 | + 'EE_Core_Config' => static function () { |
|
983 | + return EE_Config::instance()->core; |
|
984 | + }, |
|
985 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
986 | + return LoaderFactory::getLoader(); |
|
987 | + }, |
|
988 | + 'EE_Network_Config' => static function () { |
|
989 | + return EE_Network_Config::instance(); |
|
990 | + }, |
|
991 | + 'EE_Config' => static function () { |
|
992 | + return EE_Config::instance(); |
|
993 | + }, |
|
994 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
995 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
996 | + }, |
|
997 | + 'EE_Admin_Config' => static function () { |
|
998 | + return EE_Config::instance()->admin; |
|
999 | + }, |
|
1000 | + 'EE_Organization_Config' => static function () { |
|
1001 | + return EE_Config::instance()->organization; |
|
1002 | + }, |
|
1003 | + 'EE_Network_Core_Config' => static function () { |
|
1004 | + return EE_Network_Config::instance()->core; |
|
1005 | + }, |
|
1006 | + 'EE_Environment_Config' => static function () { |
|
1007 | + return EE_Config::instance()->environment; |
|
1008 | + }, |
|
1009 | + 'EED_Core_Rest_Api' => static function () { |
|
1010 | + return EED_Core_Rest_Api::instance(); |
|
1011 | + }, |
|
1012 | + 'WP_REST_Server' => static function () { |
|
1013 | + return rest_get_server(); |
|
1014 | + }, |
|
1015 | + 'EventEspresso\core\Psr4Autoloader' => static function () { |
|
1016 | + return EE_Psr4AutoloaderInit::psr4_loader(); |
|
1017 | + }, |
|
1018 | + 'EE_Ticket_Selector_Config' => function () { |
|
1019 | + return EE_Config::instance()->template_settings->EED_Ticket_Selector; |
|
1020 | + }, |
|
1021 | + ]; |
|
1022 | + } |
|
1023 | + |
|
1024 | + |
|
1025 | + /** |
|
1026 | + * can be used for supplying alternate names for classes, |
|
1027 | + * or for connecting interface names to instantiable classes |
|
1028 | + * |
|
1029 | + * @throws InvalidAliasException |
|
1030 | + */ |
|
1031 | + protected function _register_core_aliases() |
|
1032 | + { |
|
1033 | + $aliases = [ |
|
1034 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
1035 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
1036 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
1037 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
1038 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
1039 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
1040 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1041 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
1042 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
1043 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
1044 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CreateRegistrationCommand', |
|
1045 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationDetailsCommand', |
|
1046 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
1047 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
1048 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\domain\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
1049 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\domain\services\commands\ticket\CreateTicketLineItemCommand', |
|
1050 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\domain\services\commands\transaction\CreateTransactionCommandHandler', |
|
1051 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\domain\services\commands\attendee\CreateAttendeeCommandHandler', |
|
1052 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
1053 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
1054 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1055 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
1056 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
1057 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
1058 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
1059 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
1060 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
1061 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
1062 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
1063 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
1064 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
1065 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
1066 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
1067 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
1068 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
1069 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
1070 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
1071 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
1072 | + 'EventEspresso\core\services\assets\AssetManifestInterface' => 'EventEspresso\core\services\assets\AssetManifest', |
|
1073 | + ]; |
|
1074 | + foreach ($aliases as $alias => $fqn) { |
|
1075 | + if (is_array($fqn)) { |
|
1076 | + foreach ($fqn as $class => $for_class) { |
|
1077 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
1078 | + } |
|
1079 | + continue; |
|
1080 | + } |
|
1081 | + $this->class_cache->addAlias($fqn, $alias); |
|
1082 | + } |
|
1083 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
1084 | + $this->class_cache->addAlias( |
|
1085 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
1086 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
1087 | + ); |
|
1088 | + } |
|
1089 | + } |
|
1090 | + |
|
1091 | + |
|
1092 | + public function debug($for_class = '') |
|
1093 | + { |
|
1094 | + if (method_exists($this->class_cache, 'debug')) { |
|
1095 | + $this->class_cache->debug($for_class); |
|
1096 | + } |
|
1097 | + } |
|
1098 | + |
|
1099 | + |
|
1100 | + /** |
|
1101 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
1102 | + * request Primarily used by unit tests. |
|
1103 | + */ |
|
1104 | + public function reset() |
|
1105 | + { |
|
1106 | + $this->_register_core_class_loaders(); |
|
1107 | + $this->_register_core_dependencies(); |
|
1108 | + } |
|
1109 | + |
|
1110 | + |
|
1111 | + /** |
|
1112 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
1113 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
1114 | + * WHY? |
|
1115 | + * Because if a class is type hinting for a concretion, |
|
1116 | + * then why would we need to find another class to supply it? |
|
1117 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
1118 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
1119 | + * Don't go looking for some substitute. |
|
1120 | + * Whereas if a class is type hinting for an interface... |
|
1121 | + * then we need to find an actual class to use. |
|
1122 | + * So the interface IS the alias for some other FQN, |
|
1123 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
1124 | + * represents some other class. |
|
1125 | + * |
|
1126 | + * @param string $fqn |
|
1127 | + * @param string $for_class |
|
1128 | + * @return bool |
|
1129 | + * @deprecated 4.9.62.p |
|
1130 | + */ |
|
1131 | + public function has_alias(string $fqn = '', string $for_class = ''): bool |
|
1132 | + { |
|
1133 | + return $this->isAlias($fqn, $for_class); |
|
1134 | + } |
|
1135 | + |
|
1136 | + |
|
1137 | + /** |
|
1138 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
1139 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
1140 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
1141 | + * for example: |
|
1142 | + * if the following two entries were added to the _aliases array: |
|
1143 | + * array( |
|
1144 | + * 'interface_alias' => 'some\namespace\interface' |
|
1145 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
1146 | + * ) |
|
1147 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
1148 | + * to load an instance of 'some\namespace\classname' |
|
1149 | + * |
|
1150 | + * @param string $alias |
|
1151 | + * @param string $for_class |
|
1152 | + * @return string |
|
1153 | + * @deprecated 4.9.62.p |
|
1154 | + */ |
|
1155 | + public function get_alias(string $alias = '', string $for_class = ''): string |
|
1156 | + { |
|
1157 | + return $this->getFqnForAlias($alias, $for_class); |
|
1158 | + } |
|
1159 | 1159 | } |