@@ -5,49 +5,49 @@ |
||
| 5 | 5 | class Number |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the HTML input type is 'number' whose value is a decimal (float) |
|
| 10 | - */ |
|
| 11 | - public const TYPE_FLOAT = 'decimal'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that the HTML input type is 'number' whose value is an integer (whole number) |
|
| 15 | - */ |
|
| 16 | - public const TYPE_INT = 'integer'; |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * indicates that the HTML input type is 'range' |
|
| 20 | - */ |
|
| 21 | - public const TYPE_RANGE = 'range'; |
|
| 22 | - |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * @var array |
|
| 26 | - */ |
|
| 27 | - private $valid_type_options; |
|
| 28 | - |
|
| 29 | - |
|
| 30 | - public function __construct() |
|
| 31 | - { |
|
| 32 | - $this->valid_type_options = apply_filters( |
|
| 33 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options', |
|
| 34 | - [ |
|
| 35 | - Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'), |
|
| 36 | - Number::TYPE_INT => esc_html__('Integer (Whole) Number', 'event_espresso'), |
|
| 37 | - Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'), |
|
| 38 | - ] |
|
| 39 | - ); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @param bool $constants_only |
|
| 45 | - * @return array |
|
| 46 | - */ |
|
| 47 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 48 | - { |
|
| 49 | - return $constants_only |
|
| 50 | - ? array_keys($this->valid_type_options) |
|
| 51 | - : $this->valid_type_options; |
|
| 52 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that the HTML input type is 'number' whose value is a decimal (float) |
|
| 10 | + */ |
|
| 11 | + public const TYPE_FLOAT = 'decimal'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that the HTML input type is 'number' whose value is an integer (whole number) |
|
| 15 | + */ |
|
| 16 | + public const TYPE_INT = 'integer'; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * indicates that the HTML input type is 'range' |
|
| 20 | + */ |
|
| 21 | + public const TYPE_RANGE = 'range'; |
|
| 22 | + |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * @var array |
|
| 26 | + */ |
|
| 27 | + private $valid_type_options; |
|
| 28 | + |
|
| 29 | + |
|
| 30 | + public function __construct() |
|
| 31 | + { |
|
| 32 | + $this->valid_type_options = apply_filters( |
|
| 33 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Number__valid_type_options', |
|
| 34 | + [ |
|
| 35 | + Number::TYPE_FLOAT => esc_html__('Decimal Number', 'event_espresso'), |
|
| 36 | + Number::TYPE_INT => esc_html__('Integer (Whole) Number', 'event_espresso'), |
|
| 37 | + Number::TYPE_RANGE => esc_html__('Number Range', 'event_espresso'), |
|
| 38 | + ] |
|
| 39 | + ); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @param bool $constants_only |
|
| 45 | + * @return array |
|
| 46 | + */ |
|
| 47 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 48 | + { |
|
| 49 | + return $constants_only |
|
| 50 | + ? array_keys($this->valid_type_options) |
|
| 51 | + : $this->valid_type_options; |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -5,59 +5,59 @@ |
||
| 5 | 5 | class Select |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
| 10 | - */ |
|
| 11 | - public const TYPE_SELECT = 'select'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
| 15 | - */ |
|
| 16 | - public const TYPE_SELECT_MULTI = 'select-multi'; |
|
| 17 | - |
|
| 18 | - // CUSTOM EE SELECT TYPES |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * indicates that input is an HTML dropdown (select input) |
|
| 22 | - * populated with names of countries that are enabled for the site |
|
| 23 | - */ |
|
| 24 | - public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * indicates that the input is an HTML dropdown (select input) |
|
| 28 | - * populated with names of states for the countries that are enabled for the site |
|
| 29 | - */ |
|
| 30 | - public const TYPE_SELECT_STATE = 'select-state'; |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var array |
|
| 35 | - */ |
|
| 36 | - private $valid_type_options; |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - public function __construct() |
|
| 40 | - { |
|
| 41 | - $this->valid_type_options = apply_filters( |
|
| 42 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
| 43 | - [ |
|
| 44 | - Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
| 45 | - Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
| 46 | - Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
| 47 | - Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
| 48 | - ] |
|
| 49 | - ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @param bool $constants_only |
|
| 55 | - * @return array |
|
| 56 | - */ |
|
| 57 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 58 | - { |
|
| 59 | - return $constants_only |
|
| 60 | - ? array_keys($this->valid_type_options) |
|
| 61 | - : $this->valid_type_options; |
|
| 62 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that the input is an HTML dropdown (select input) that accepts only one value |
|
| 10 | + */ |
|
| 11 | + public const TYPE_SELECT = 'select'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that the input is an HTML dropdown (select input) that accepts multiple values |
|
| 15 | + */ |
|
| 16 | + public const TYPE_SELECT_MULTI = 'select-multi'; |
|
| 17 | + |
|
| 18 | + // CUSTOM EE SELECT TYPES |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * indicates that input is an HTML dropdown (select input) |
|
| 22 | + * populated with names of countries that are enabled for the site |
|
| 23 | + */ |
|
| 24 | + public const TYPE_SELECT_COUNTRY = 'select-country'; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * indicates that the input is an HTML dropdown (select input) |
|
| 28 | + * populated with names of states for the countries that are enabled for the site |
|
| 29 | + */ |
|
| 30 | + public const TYPE_SELECT_STATE = 'select-state'; |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var array |
|
| 35 | + */ |
|
| 36 | + private $valid_type_options; |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + public function __construct() |
|
| 40 | + { |
|
| 41 | + $this->valid_type_options = apply_filters( |
|
| 42 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Select__valid_type_options', |
|
| 43 | + [ |
|
| 44 | + Select::TYPE_SELECT => esc_html__('Dropdown', 'event_espresso'), |
|
| 45 | + Select::TYPE_SELECT_MULTI => esc_html__('Multi-Select Dropdown', 'event_espresso'), |
|
| 46 | + Select::TYPE_SELECT_COUNTRY => esc_html__('Country Selector', 'event_espresso'), |
|
| 47 | + Select::TYPE_SELECT_STATE => esc_html__('State Selector', 'event_espresso'), |
|
| 48 | + ] |
|
| 49 | + ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @param bool $constants_only |
|
| 55 | + * @return array |
|
| 56 | + */ |
|
| 57 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 58 | + { |
|
| 59 | + return $constants_only |
|
| 60 | + ? array_keys($this->valid_type_options) |
|
| 61 | + : $this->valid_type_options; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -5,109 +5,109 @@ |
||
| 5 | 5 | class Phone |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that the HTML input type is 'tel' |
|
| 10 | - */ |
|
| 11 | - public const INPUT_TYPE = 'tel'; |
|
| 8 | + /** |
|
| 9 | + * indicates that the HTML input type is 'tel' |
|
| 10 | + */ |
|
| 11 | + public const INPUT_TYPE = 'tel'; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
| 15 | - * ########## |
|
| 16 | - * ###-###-#### |
|
| 17 | - * ### ### #### |
|
| 18 | - * (###)-###-#### |
|
| 19 | - * (###) ###-#### |
|
| 20 | - * |
|
| 21 | - * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
| 22 | - * +1 (###) ###-#### |
|
| 23 | - */ |
|
| 24 | - public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
| 13 | + /** |
|
| 14 | + * indicates that the 'tel' input regex pattern is for a US formatted phone number, examples: |
|
| 15 | + * ########## |
|
| 16 | + * ###-###-#### |
|
| 17 | + * ### ### #### |
|
| 18 | + * (###)-###-#### |
|
| 19 | + * (###) ###-#### |
|
| 20 | + * |
|
| 21 | + * captures the intl code to the first group (+1) and the rest of the number to group 2 |
|
| 22 | + * +1 (###) ###-#### |
|
| 23 | + */ |
|
| 24 | + public const PATTERN_US = '(\+?\d{1,3})?[\ \-]?(\(?\d{3}\)?[\ \-]?\d{3}[\ \-]?\d{4})'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
| 28 | - * (###) #### #### |
|
| 29 | - * (####) ### #### |
|
| 30 | - * (#####) ## #### |
|
| 31 | - * |
|
| 32 | - * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
| 33 | - * +44 (###) #### #### |
|
| 34 | - */ |
|
| 35 | - public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
| 26 | + /** |
|
| 27 | + * indicates that the 'tel' input regex pattern is for a UK formatted phone number, examples: |
|
| 28 | + * (###) #### #### |
|
| 29 | + * (####) ### #### |
|
| 30 | + * (#####) ## #### |
|
| 31 | + * |
|
| 32 | + * captures the intl code to the first group (+44) and the rest of the number to group 2 |
|
| 33 | + * +44 (###) #### #### |
|
| 34 | + */ |
|
| 35 | + public const PATTERN_UK = '(\+?44)?[\ ]?(\(?(?:(?:\d{3,5})|(?:\d{4} \d{2}))\)?[\-\ ]?\d{2,4}[\-\ ]?\d{2,4})'; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
| 39 | - * 0# ## ## ## ## |
|
| 40 | - * 0### ## ## ## |
|
| 41 | - * |
|
| 42 | - * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
| 43 | - * +33 # ## ## ## ## |
|
| 44 | - * 0033 # ## ## ## ## |
|
| 45 | - */ |
|
| 46 | - public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
| 37 | + /** |
|
| 38 | + * indicates that the 'tel' input regex pattern is for a France formatted phone number, examples: |
|
| 39 | + * 0# ## ## ## ## |
|
| 40 | + * 0### ## ## ## |
|
| 41 | + * |
|
| 42 | + * captures the intl code to the first group (+33) and the rest of the number to group 2 |
|
| 43 | + * +33 # ## ## ## ## |
|
| 44 | + * 0033 # ## ## ## ## |
|
| 45 | + */ |
|
| 46 | + public const PATTERN_FR = '((?:\+|00)33)?[\ \.\-]*((?:(?:\(0\)[\ \.\-]{0,3})?|0)[1-9](?:(?:[\ \.\-]?\d{2}){4}|\d{2}(?:[\ \.\-]?\d{3}){2}))'; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
| 50 | - * (0##) ####-#### |
|
| 51 | - * (0###) ####-#### |
|
| 52 | - * (0####) ###-#### |
|
| 53 | - * (03####) ##-#### |
|
| 54 | - * |
|
| 55 | - * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
| 56 | - * +49 (0##) ####-#### |
|
| 57 | - */ |
|
| 58 | - public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
| 48 | + /** |
|
| 49 | + * indicates that the 'tel' input regex pattern is for a German formatted phone number, examples: |
|
| 50 | + * (0##) ####-#### |
|
| 51 | + * (0###) ####-#### |
|
| 52 | + * (0####) ###-#### |
|
| 53 | + * (03####) ##-#### |
|
| 54 | + * |
|
| 55 | + * captures the intl code to the first group (+49) and the rest of the number to group 2 |
|
| 56 | + * +49 (0##) ####-#### |
|
| 57 | + */ |
|
| 58 | + public const PATTERN_DE = '(\+?49)?[\ \.\-]?(\(?(?:[\d \-\)\–\/\(]+){6,}\)?(?:[\ \.\-–\/]?)(?:[\d]+))'; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * @var array |
|
| 62 | - */ |
|
| 63 | - private $regex_patterns; |
|
| 60 | + /** |
|
| 61 | + * @var array |
|
| 62 | + */ |
|
| 63 | + private $regex_patterns; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * @var array |
|
| 67 | - */ |
|
| 68 | - private $valid_type_options; |
|
| 65 | + /** |
|
| 66 | + * @var array |
|
| 67 | + */ |
|
| 68 | + private $valid_type_options; |
|
| 69 | 69 | |
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Phone constructor. |
|
| 73 | - */ |
|
| 74 | - public function __construct() |
|
| 75 | - { |
|
| 76 | - $this->regex_patterns = (array) apply_filters( |
|
| 77 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
| 78 | - [ |
|
| 79 | - 'de_DE' => Phone::PATTERN_DE, |
|
| 80 | - 'fr_FR' => Phone::PATTERN_FR, |
|
| 81 | - 'en_UK' => Phone::PATTERN_UK, |
|
| 82 | - 'en_US' => Phone::PATTERN_US, |
|
| 83 | - ] |
|
| 84 | - ); |
|
| 85 | - $this->valid_type_options = apply_filters( |
|
| 86 | - 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
| 87 | - [ |
|
| 88 | - Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
| 89 | - ] |
|
| 90 | - ); |
|
| 91 | - } |
|
| 71 | + /** |
|
| 72 | + * Phone constructor. |
|
| 73 | + */ |
|
| 74 | + public function __construct() |
|
| 75 | + { |
|
| 76 | + $this->regex_patterns = (array) apply_filters( |
|
| 77 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
|
| 78 | + [ |
|
| 79 | + 'de_DE' => Phone::PATTERN_DE, |
|
| 80 | + 'fr_FR' => Phone::PATTERN_FR, |
|
| 81 | + 'en_UK' => Phone::PATTERN_UK, |
|
| 82 | + 'en_US' => Phone::PATTERN_US, |
|
| 83 | + ] |
|
| 84 | + ); |
|
| 85 | + $this->valid_type_options = apply_filters( |
|
| 86 | + 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__valid_type_options', |
|
| 87 | + [ |
|
| 88 | + Phone::INPUT_TYPE => esc_html__('Phone Number', 'event_espresso'), |
|
| 89 | + ] |
|
| 90 | + ); |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | |
| 94 | - /** |
|
| 95 | - * @return array |
|
| 96 | - */ |
|
| 97 | - public function regexPatterns(): array |
|
| 98 | - { |
|
| 99 | - return $this->regex_patterns; |
|
| 100 | - } |
|
| 94 | + /** |
|
| 95 | + * @return array |
|
| 96 | + */ |
|
| 97 | + public function regexPatterns(): array |
|
| 98 | + { |
|
| 99 | + return $this->regex_patterns; |
|
| 100 | + } |
|
| 101 | 101 | |
| 102 | 102 | |
| 103 | - /** |
|
| 104 | - * @param bool $constants_only |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | - { |
|
| 109 | - return $constants_only |
|
| 110 | - ? array_keys($this->valid_type_options) |
|
| 111 | - : $this->valid_type_options; |
|
| 112 | - } |
|
| 103 | + /** |
|
| 104 | + * @param bool $constants_only |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | + { |
|
| 109 | + return $constants_only |
|
| 110 | + ? array_keys($this->valid_type_options) |
|
| 111 | + : $this->valid_type_options; |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | */ |
| 74 | 74 | public function __construct() |
| 75 | 75 | { |
| 76 | - $this->regex_patterns = (array) apply_filters( |
|
| 76 | + $this->regex_patterns = (array) apply_filters( |
|
| 77 | 77 | 'FHEE__EventEspresso_core_services_form_meta_inputs_Phone__regex_patterns', |
| 78 | 78 | [ |
| 79 | 79 | 'de_DE' => Phone::PATTERN_DE, |
@@ -5,55 +5,55 @@ |
||
| 5 | 5 | class Element |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * indicates that element is not archived or trashed |
|
| 10 | - */ |
|
| 11 | - public const STATUS_ACTIVE = 'active'; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * indicates that element is archived and should no longer be displayed on public forms |
|
| 15 | - * but may still be required due to existing answers when form was completed prior to input being archived |
|
| 16 | - */ |
|
| 17 | - public const STATUS_ARCHIVED = 'archived'; |
|
| 18 | - |
|
| 19 | - /** |
|
| 20 | - * indicates that element should be automatically added to newly created forms |
|
| 21 | - */ |
|
| 22 | - public const STATUS_DEFAULT = 'default'; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
| 26 | - */ |
|
| 27 | - public const STATUS_TRASHED = 'trashed'; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var array |
|
| 31 | - */ |
|
| 32 | - private $valid_status_options; |
|
| 33 | - |
|
| 34 | - |
|
| 35 | - public function __construct() |
|
| 36 | - { |
|
| 37 | - $this->valid_status_options = apply_filters( |
|
| 38 | - 'FHEE__EventEspresso_core_services_form_meta_Element__valid_status_options', |
|
| 39 | - [ |
|
| 40 | - Element::STATUS_ACTIVE => esc_html__('Active', 'event_espresso'), |
|
| 41 | - Element::STATUS_ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
| 42 | - Element::STATUS_DEFAULT => esc_html__('Default', 'event_espresso'), |
|
| 43 | - Element::STATUS_TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
| 44 | - ] |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @param bool $constants_only |
|
| 51 | - * @return array |
|
| 52 | - */ |
|
| 53 | - public function validStatusOptions(bool $constants_only = false): array |
|
| 54 | - { |
|
| 55 | - return $constants_only |
|
| 56 | - ? array_keys($this->valid_status_options) |
|
| 57 | - : $this->valid_status_options; |
|
| 58 | - } |
|
| 8 | + /** |
|
| 9 | + * indicates that element is not archived or trashed |
|
| 10 | + */ |
|
| 11 | + public const STATUS_ACTIVE = 'active'; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * indicates that element is archived and should no longer be displayed on public forms |
|
| 15 | + * but may still be required due to existing answers when form was completed prior to input being archived |
|
| 16 | + */ |
|
| 17 | + public const STATUS_ARCHIVED = 'archived'; |
|
| 18 | + |
|
| 19 | + /** |
|
| 20 | + * indicates that element should be automatically added to newly created forms |
|
| 21 | + */ |
|
| 22 | + public const STATUS_DEFAULT = 'default'; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * indicates that element is no longer needed, has no existing answers, and can be moved to the trash |
|
| 26 | + */ |
|
| 27 | + public const STATUS_TRASHED = 'trashed'; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var array |
|
| 31 | + */ |
|
| 32 | + private $valid_status_options; |
|
| 33 | + |
|
| 34 | + |
|
| 35 | + public function __construct() |
|
| 36 | + { |
|
| 37 | + $this->valid_status_options = apply_filters( |
|
| 38 | + 'FHEE__EventEspresso_core_services_form_meta_Element__valid_status_options', |
|
| 39 | + [ |
|
| 40 | + Element::STATUS_ACTIVE => esc_html__('Active', 'event_espresso'), |
|
| 41 | + Element::STATUS_ARCHIVED => esc_html__('Archived', 'event_espresso'), |
|
| 42 | + Element::STATUS_DEFAULT => esc_html__('Default', 'event_espresso'), |
|
| 43 | + Element::STATUS_TRASHED => esc_html__('Trashed', 'event_espresso'), |
|
| 44 | + ] |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @param bool $constants_only |
|
| 51 | + * @return array |
|
| 52 | + */ |
|
| 53 | + public function validStatusOptions(bool $constants_only = false): array |
|
| 54 | + { |
|
| 55 | + return $constants_only |
|
| 56 | + ? array_keys($this->valid_status_options) |
|
| 57 | + : $this->valid_status_options; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -12,102 +12,102 @@ |
||
| 12 | 12 | |
| 13 | 13 | class InputTypes |
| 14 | 14 | { |
| 15 | - /** |
|
| 16 | - * @var Button |
|
| 17 | - */ |
|
| 18 | - private $button; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * @var DateTime |
|
| 22 | - */ |
|
| 23 | - private $datetime; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @var Input |
|
| 27 | - */ |
|
| 28 | - private $input; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var Number |
|
| 32 | - */ |
|
| 33 | - private $number; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * @var Phone |
|
| 37 | - */ |
|
| 38 | - private $phone; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @var Select |
|
| 42 | - */ |
|
| 43 | - private $select; |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @var Text |
|
| 47 | - */ |
|
| 48 | - private $text; |
|
| 49 | - |
|
| 50 | - /** |
|
| 51 | - * @var array |
|
| 52 | - */ |
|
| 53 | - private $valid_type_options; |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * InputTypes constructor. |
|
| 58 | - * |
|
| 59 | - * @param Button $button |
|
| 60 | - * @param DateTime $datetime |
|
| 61 | - * @param Input $input |
|
| 62 | - * @param Number $number |
|
| 63 | - * @param Phone $phone |
|
| 64 | - * @param Select $select |
|
| 65 | - * @param Text $text |
|
| 66 | - */ |
|
| 67 | - public function __construct( |
|
| 68 | - Button $button, |
|
| 69 | - DateTime $datetime, |
|
| 70 | - Input $input, |
|
| 71 | - Number $number, |
|
| 72 | - Phone $phone, |
|
| 73 | - Select $select, |
|
| 74 | - Text $text |
|
| 75 | - ) { |
|
| 76 | - $this->button = $button; |
|
| 77 | - $this->datetime = $datetime; |
|
| 78 | - $this->input = $input; |
|
| 79 | - $this->number = $number; |
|
| 80 | - $this->phone = $phone; |
|
| 81 | - $this->select = $select; |
|
| 82 | - $this->text = $text; |
|
| 83 | - $this->assembleValidTypeOptions(); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - private function assembleValidTypeOptions() |
|
| 88 | - { |
|
| 89 | - $button = $this->button->validTypeOptions(); |
|
| 90 | - $datetime = $this->datetime->validTypeOptions(); |
|
| 91 | - $input = $this->input->validTypeOptions(); |
|
| 92 | - $number = $this->number->validTypeOptions(); |
|
| 93 | - $phone = $this->phone->validTypeOptions(); |
|
| 94 | - $select = $this->select->validTypeOptions(); |
|
| 95 | - $text = $this->text->validTypeOptions(); |
|
| 96 | - $this->valid_type_options = apply_filters( |
|
| 97 | - 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
| 98 | - array_merge($button, $datetime, $input, $number, $phone, $select, $text) |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @param bool $constants_only |
|
| 105 | - * @return array |
|
| 106 | - */ |
|
| 107 | - public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | - { |
|
| 109 | - return $constants_only |
|
| 110 | - ? array_keys($this->valid_type_options) |
|
| 111 | - : $this->valid_type_options; |
|
| 112 | - } |
|
| 15 | + /** |
|
| 16 | + * @var Button |
|
| 17 | + */ |
|
| 18 | + private $button; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * @var DateTime |
|
| 22 | + */ |
|
| 23 | + private $datetime; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @var Input |
|
| 27 | + */ |
|
| 28 | + private $input; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var Number |
|
| 32 | + */ |
|
| 33 | + private $number; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * @var Phone |
|
| 37 | + */ |
|
| 38 | + private $phone; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @var Select |
|
| 42 | + */ |
|
| 43 | + private $select; |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @var Text |
|
| 47 | + */ |
|
| 48 | + private $text; |
|
| 49 | + |
|
| 50 | + /** |
|
| 51 | + * @var array |
|
| 52 | + */ |
|
| 53 | + private $valid_type_options; |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * InputTypes constructor. |
|
| 58 | + * |
|
| 59 | + * @param Button $button |
|
| 60 | + * @param DateTime $datetime |
|
| 61 | + * @param Input $input |
|
| 62 | + * @param Number $number |
|
| 63 | + * @param Phone $phone |
|
| 64 | + * @param Select $select |
|
| 65 | + * @param Text $text |
|
| 66 | + */ |
|
| 67 | + public function __construct( |
|
| 68 | + Button $button, |
|
| 69 | + DateTime $datetime, |
|
| 70 | + Input $input, |
|
| 71 | + Number $number, |
|
| 72 | + Phone $phone, |
|
| 73 | + Select $select, |
|
| 74 | + Text $text |
|
| 75 | + ) { |
|
| 76 | + $this->button = $button; |
|
| 77 | + $this->datetime = $datetime; |
|
| 78 | + $this->input = $input; |
|
| 79 | + $this->number = $number; |
|
| 80 | + $this->phone = $phone; |
|
| 81 | + $this->select = $select; |
|
| 82 | + $this->text = $text; |
|
| 83 | + $this->assembleValidTypeOptions(); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + private function assembleValidTypeOptions() |
|
| 88 | + { |
|
| 89 | + $button = $this->button->validTypeOptions(); |
|
| 90 | + $datetime = $this->datetime->validTypeOptions(); |
|
| 91 | + $input = $this->input->validTypeOptions(); |
|
| 92 | + $number = $this->number->validTypeOptions(); |
|
| 93 | + $phone = $this->phone->validTypeOptions(); |
|
| 94 | + $select = $this->select->validTypeOptions(); |
|
| 95 | + $text = $this->text->validTypeOptions(); |
|
| 96 | + $this->valid_type_options = apply_filters( |
|
| 97 | + 'FHEE__EventEspresso_core_services_form_meta_InputTypes__valid_type_options', |
|
| 98 | + array_merge($button, $datetime, $input, $number, $phone, $select, $text) |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @param bool $constants_only |
|
| 105 | + * @return array |
|
| 106 | + */ |
|
| 107 | + public function validTypeOptions(bool $constants_only = false): array |
|
| 108 | + { |
|
| 109 | + return $constants_only |
|
| 110 | + ? array_keys($this->valid_type_options) |
|
| 111 | + : $this->valid_type_options; |
|
| 112 | + } |
|
| 113 | 113 | } |
@@ -21,290 +21,290 @@ |
||
| 21 | 21 | class Mirror |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var ReflectionClass[] |
|
| 26 | - */ |
|
| 27 | - private $classes = []; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var ReflectionMethod[] |
|
| 31 | - */ |
|
| 32 | - private $constructors = []; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var ReflectionParameter[][] |
|
| 36 | - */ |
|
| 37 | - private $parameters = []; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var ReflectionParameter[][] |
|
| 41 | - */ |
|
| 42 | - private $parameter_classes = []; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var ReflectionProperty[][] |
|
| 46 | - */ |
|
| 47 | - private $properties = []; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @var ReflectionMethod[][] |
|
| 51 | - */ |
|
| 52 | - private $methods = []; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @var array |
|
| 56 | - */ |
|
| 57 | - private $default_properties = []; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var array |
|
| 61 | - */ |
|
| 62 | - private $static_properties = []; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @param string $class_name |
|
| 67 | - * @return ReflectionClass |
|
| 68 | - * @throws ReflectionException |
|
| 69 | - * @throws InvalidDataTypeException |
|
| 70 | - */ |
|
| 71 | - public function getReflectionClass(string $class_name): ReflectionClass |
|
| 72 | - { |
|
| 73 | - if (! is_string($class_name)) { |
|
| 74 | - throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
| 75 | - } |
|
| 76 | - if (! isset($this->classes[ $class_name ])) { |
|
| 77 | - $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
| 78 | - } |
|
| 79 | - return $this->classes[ $class_name ]; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @param string $class_name |
|
| 85 | - * @return ReflectionMethod|null |
|
| 86 | - * @throws InvalidDataTypeException |
|
| 87 | - * @throws ReflectionException |
|
| 88 | - */ |
|
| 89 | - public function getConstructor(string $class_name): ?ReflectionMethod |
|
| 90 | - { |
|
| 91 | - if (! is_string($class_name)) { |
|
| 92 | - throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
| 93 | - } |
|
| 94 | - if (! isset($this->constructors[ $class_name ])) { |
|
| 95 | - $reflection_class = $this->getReflectionClass($class_name); |
|
| 96 | - $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
| 97 | - } |
|
| 98 | - return $this->constructors[ $class_name ]; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @param ReflectionClass $reflection_class |
|
| 104 | - * @return ReflectionMethod|null |
|
| 105 | - * @throws InvalidDataTypeException |
|
| 106 | - * @throws ReflectionException |
|
| 107 | - */ |
|
| 108 | - public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod |
|
| 109 | - { |
|
| 110 | - return $this->getConstructor($reflection_class->getName()); |
|
| 111 | - } |
|
| 112 | - |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * @param string $class_name |
|
| 116 | - * @return ReflectionParameter[] |
|
| 117 | - * @throws InvalidDataTypeException |
|
| 118 | - * @throws ReflectionException |
|
| 119 | - */ |
|
| 120 | - public function getParameters(string $class_name): array |
|
| 121 | - { |
|
| 122 | - if (! isset($this->parameters[ $class_name ])) { |
|
| 123 | - $constructor = $this->getConstructor($class_name); |
|
| 124 | - $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
| 125 | - } |
|
| 126 | - return $this->parameters[ $class_name ]; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * @param ReflectionClass $reflection_class |
|
| 132 | - * @return ReflectionParameter[] |
|
| 133 | - * @throws InvalidDataTypeException |
|
| 134 | - * @throws ReflectionException |
|
| 135 | - */ |
|
| 136 | - public function getParametersFromReflection(ReflectionClass $reflection_class): array |
|
| 137 | - { |
|
| 138 | - return $this->getParameters($reflection_class->getName()); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param ReflectionMethod $constructor |
|
| 144 | - * @return ReflectionParameter[] |
|
| 145 | - * @throws InvalidDataTypeException |
|
| 146 | - * @throws ReflectionException |
|
| 147 | - */ |
|
| 148 | - public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array |
|
| 149 | - { |
|
| 150 | - return $this->getParameters($constructor->getDeclaringClass()); |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * returns array of ReflectionParameter objects for parameters that are NOT optional |
|
| 156 | - * |
|
| 157 | - * @param string $class_name |
|
| 158 | - * @return ReflectionParameter[] |
|
| 159 | - * @throws InvalidDataTypeException |
|
| 160 | - * @throws ReflectionException |
|
| 161 | - */ |
|
| 162 | - public function getRequiredParameters(string $class_name): array |
|
| 163 | - { |
|
| 164 | - $required_parameters = []; |
|
| 165 | - $parameters = $this->getParameters($class_name); |
|
| 166 | - foreach ($parameters as $parameter) { |
|
| 167 | - if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) { |
|
| 168 | - $required_parameters[] = $parameter; |
|
| 169 | - } |
|
| 170 | - } |
|
| 171 | - return $required_parameters; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @param ReflectionParameter $param |
|
| 177 | - * @param string $class_name |
|
| 178 | - * @param string $index |
|
| 179 | - * @return string|null |
|
| 180 | - */ |
|
| 181 | - public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string |
|
| 182 | - { |
|
| 183 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
| 184 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 185 | - } |
|
| 186 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 187 | - $this->parameter_classes[ $class_name ] = []; |
|
| 188 | - } |
|
| 189 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 190 | - $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 191 | - } |
|
| 192 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
| 193 | - ? $param->getClass()->name |
|
| 194 | - : null; |
|
| 195 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 196 | - } |
|
| 197 | - |
|
| 198 | - |
|
| 199 | - /** |
|
| 200 | - * @param ReflectionParameter $param |
|
| 201 | - * @param string $class_name |
|
| 202 | - * @param string $index |
|
| 203 | - * @return array|string|null |
|
| 204 | - * @throws ReflectionException |
|
| 205 | - */ |
|
| 206 | - public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index) |
|
| 207 | - { |
|
| 208 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
| 209 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 210 | - } |
|
| 211 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 212 | - $this->parameter_classes[ $class_name ] = []; |
|
| 213 | - } |
|
| 214 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 215 | - $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 216 | - } |
|
| 217 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
| 218 | - ? $param->getDefaultValue() |
|
| 219 | - : null; |
|
| 220 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - |
|
| 224 | - /** |
|
| 225 | - * @param string $class_name |
|
| 226 | - * @return ReflectionProperty[] |
|
| 227 | - * @throws InvalidDataTypeException |
|
| 228 | - * @throws ReflectionException |
|
| 229 | - */ |
|
| 230 | - public function getProperties(string $class_name): array |
|
| 231 | - { |
|
| 232 | - if (! isset($this->properties[ $class_name ])) { |
|
| 233 | - $reflection_class = $this->getReflectionClass($class_name); |
|
| 234 | - $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
| 235 | - } |
|
| 236 | - return $this->properties[ $class_name ]; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - /** |
|
| 241 | - * @param ReflectionClass $reflection_class |
|
| 242 | - * @return ReflectionProperty[] |
|
| 243 | - * @throws InvalidDataTypeException |
|
| 244 | - * @throws ReflectionException |
|
| 245 | - */ |
|
| 246 | - public function getPropertiesFromReflection(ReflectionClass $reflection_class): array |
|
| 247 | - { |
|
| 248 | - return $this->getProperties($reflection_class->getName()); |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - |
|
| 252 | - /** |
|
| 253 | - * @param string $class_name |
|
| 254 | - * @return ReflectionMethod[] |
|
| 255 | - * @throws InvalidDataTypeException |
|
| 256 | - * @throws ReflectionException |
|
| 257 | - */ |
|
| 258 | - public function getMethods(string $class_name): array |
|
| 259 | - { |
|
| 260 | - if (! isset($this->methods[ $class_name ])) { |
|
| 261 | - $reflection_class = $this->getReflectionClass($class_name); |
|
| 262 | - $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
| 263 | - } |
|
| 264 | - return $this->methods[ $class_name ]; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * @param ReflectionClass $reflection_class ) |
|
| 270 | - * @return ReflectionMethod[] |
|
| 271 | - * @throws InvalidDataTypeException |
|
| 272 | - * @throws ReflectionException |
|
| 273 | - */ |
|
| 274 | - public function getMethodsFromReflection(ReflectionClass $reflection_class): array |
|
| 275 | - { |
|
| 276 | - return $this->getMethods($reflection_class->getName()); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * @param string $class_name |
|
| 282 | - * @return array |
|
| 283 | - * @throws InvalidDataTypeException |
|
| 284 | - * @throws ReflectionException |
|
| 285 | - */ |
|
| 286 | - public function getDefaultProperties(string $class_name): array |
|
| 287 | - { |
|
| 288 | - if (! isset($this->default_properties[ $class_name ])) { |
|
| 289 | - $reflection_class = $this->getReflectionClass($class_name); |
|
| 290 | - $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties(); |
|
| 291 | - } |
|
| 292 | - return $this->default_properties[ $class_name ]; |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - /** |
|
| 297 | - * @param string $class_name |
|
| 298 | - * @return array |
|
| 299 | - * @throws InvalidDataTypeException |
|
| 300 | - * @throws ReflectionException |
|
| 301 | - */ |
|
| 302 | - public function getStaticProperties(string $class_name): array |
|
| 303 | - { |
|
| 304 | - if (! isset($this->static_properties[ $class_name ])) { |
|
| 305 | - $reflection_class = $this->getReflectionClass($class_name); |
|
| 306 | - $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties(); |
|
| 307 | - } |
|
| 308 | - return $this->static_properties[ $class_name ]; |
|
| 309 | - } |
|
| 24 | + /** |
|
| 25 | + * @var ReflectionClass[] |
|
| 26 | + */ |
|
| 27 | + private $classes = []; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var ReflectionMethod[] |
|
| 31 | + */ |
|
| 32 | + private $constructors = []; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var ReflectionParameter[][] |
|
| 36 | + */ |
|
| 37 | + private $parameters = []; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var ReflectionParameter[][] |
|
| 41 | + */ |
|
| 42 | + private $parameter_classes = []; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var ReflectionProperty[][] |
|
| 46 | + */ |
|
| 47 | + private $properties = []; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @var ReflectionMethod[][] |
|
| 51 | + */ |
|
| 52 | + private $methods = []; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @var array |
|
| 56 | + */ |
|
| 57 | + private $default_properties = []; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var array |
|
| 61 | + */ |
|
| 62 | + private $static_properties = []; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @param string $class_name |
|
| 67 | + * @return ReflectionClass |
|
| 68 | + * @throws ReflectionException |
|
| 69 | + * @throws InvalidDataTypeException |
|
| 70 | + */ |
|
| 71 | + public function getReflectionClass(string $class_name): ReflectionClass |
|
| 72 | + { |
|
| 73 | + if (! is_string($class_name)) { |
|
| 74 | + throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
| 75 | + } |
|
| 76 | + if (! isset($this->classes[ $class_name ])) { |
|
| 77 | + $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
| 78 | + } |
|
| 79 | + return $this->classes[ $class_name ]; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @param string $class_name |
|
| 85 | + * @return ReflectionMethod|null |
|
| 86 | + * @throws InvalidDataTypeException |
|
| 87 | + * @throws ReflectionException |
|
| 88 | + */ |
|
| 89 | + public function getConstructor(string $class_name): ?ReflectionMethod |
|
| 90 | + { |
|
| 91 | + if (! is_string($class_name)) { |
|
| 92 | + throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
|
| 93 | + } |
|
| 94 | + if (! isset($this->constructors[ $class_name ])) { |
|
| 95 | + $reflection_class = $this->getReflectionClass($class_name); |
|
| 96 | + $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
| 97 | + } |
|
| 98 | + return $this->constructors[ $class_name ]; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @param ReflectionClass $reflection_class |
|
| 104 | + * @return ReflectionMethod|null |
|
| 105 | + * @throws InvalidDataTypeException |
|
| 106 | + * @throws ReflectionException |
|
| 107 | + */ |
|
| 108 | + public function getConstructorFromReflection(ReflectionClass $reflection_class): ?ReflectionMethod |
|
| 109 | + { |
|
| 110 | + return $this->getConstructor($reflection_class->getName()); |
|
| 111 | + } |
|
| 112 | + |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * @param string $class_name |
|
| 116 | + * @return ReflectionParameter[] |
|
| 117 | + * @throws InvalidDataTypeException |
|
| 118 | + * @throws ReflectionException |
|
| 119 | + */ |
|
| 120 | + public function getParameters(string $class_name): array |
|
| 121 | + { |
|
| 122 | + if (! isset($this->parameters[ $class_name ])) { |
|
| 123 | + $constructor = $this->getConstructor($class_name); |
|
| 124 | + $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
| 125 | + } |
|
| 126 | + return $this->parameters[ $class_name ]; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * @param ReflectionClass $reflection_class |
|
| 132 | + * @return ReflectionParameter[] |
|
| 133 | + * @throws InvalidDataTypeException |
|
| 134 | + * @throws ReflectionException |
|
| 135 | + */ |
|
| 136 | + public function getParametersFromReflection(ReflectionClass $reflection_class): array |
|
| 137 | + { |
|
| 138 | + return $this->getParameters($reflection_class->getName()); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param ReflectionMethod $constructor |
|
| 144 | + * @return ReflectionParameter[] |
|
| 145 | + * @throws InvalidDataTypeException |
|
| 146 | + * @throws ReflectionException |
|
| 147 | + */ |
|
| 148 | + public function getParametersFromReflectionConstructor(ReflectionMethod $constructor): array |
|
| 149 | + { |
|
| 150 | + return $this->getParameters($constructor->getDeclaringClass()); |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * returns array of ReflectionParameter objects for parameters that are NOT optional |
|
| 156 | + * |
|
| 157 | + * @param string $class_name |
|
| 158 | + * @return ReflectionParameter[] |
|
| 159 | + * @throws InvalidDataTypeException |
|
| 160 | + * @throws ReflectionException |
|
| 161 | + */ |
|
| 162 | + public function getRequiredParameters(string $class_name): array |
|
| 163 | + { |
|
| 164 | + $required_parameters = []; |
|
| 165 | + $parameters = $this->getParameters($class_name); |
|
| 166 | + foreach ($parameters as $parameter) { |
|
| 167 | + if ($parameter instanceof ReflectionParameter && ! $parameter->isOptional()) { |
|
| 168 | + $required_parameters[] = $parameter; |
|
| 169 | + } |
|
| 170 | + } |
|
| 171 | + return $required_parameters; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param ReflectionParameter $param |
|
| 177 | + * @param string $class_name |
|
| 178 | + * @param string $index |
|
| 179 | + * @return string|null |
|
| 180 | + */ |
|
| 181 | + public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string |
|
| 182 | + { |
|
| 183 | + if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
| 184 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 185 | + } |
|
| 186 | + if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 187 | + $this->parameter_classes[ $class_name ] = []; |
|
| 188 | + } |
|
| 189 | + if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 190 | + $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 191 | + } |
|
| 192 | + $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
| 193 | + ? $param->getClass()->name |
|
| 194 | + : null; |
|
| 195 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 196 | + } |
|
| 197 | + |
|
| 198 | + |
|
| 199 | + /** |
|
| 200 | + * @param ReflectionParameter $param |
|
| 201 | + * @param string $class_name |
|
| 202 | + * @param string $index |
|
| 203 | + * @return array|string|null |
|
| 204 | + * @throws ReflectionException |
|
| 205 | + */ |
|
| 206 | + public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index) |
|
| 207 | + { |
|
| 208 | + if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
| 209 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 210 | + } |
|
| 211 | + if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 212 | + $this->parameter_classes[ $class_name ] = []; |
|
| 213 | + } |
|
| 214 | + if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 215 | + $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 216 | + } |
|
| 217 | + $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
| 218 | + ? $param->getDefaultValue() |
|
| 219 | + : null; |
|
| 220 | + return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + |
|
| 224 | + /** |
|
| 225 | + * @param string $class_name |
|
| 226 | + * @return ReflectionProperty[] |
|
| 227 | + * @throws InvalidDataTypeException |
|
| 228 | + * @throws ReflectionException |
|
| 229 | + */ |
|
| 230 | + public function getProperties(string $class_name): array |
|
| 231 | + { |
|
| 232 | + if (! isset($this->properties[ $class_name ])) { |
|
| 233 | + $reflection_class = $this->getReflectionClass($class_name); |
|
| 234 | + $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
| 235 | + } |
|
| 236 | + return $this->properties[ $class_name ]; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + /** |
|
| 241 | + * @param ReflectionClass $reflection_class |
|
| 242 | + * @return ReflectionProperty[] |
|
| 243 | + * @throws InvalidDataTypeException |
|
| 244 | + * @throws ReflectionException |
|
| 245 | + */ |
|
| 246 | + public function getPropertiesFromReflection(ReflectionClass $reflection_class): array |
|
| 247 | + { |
|
| 248 | + return $this->getProperties($reflection_class->getName()); |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + |
|
| 252 | + /** |
|
| 253 | + * @param string $class_name |
|
| 254 | + * @return ReflectionMethod[] |
|
| 255 | + * @throws InvalidDataTypeException |
|
| 256 | + * @throws ReflectionException |
|
| 257 | + */ |
|
| 258 | + public function getMethods(string $class_name): array |
|
| 259 | + { |
|
| 260 | + if (! isset($this->methods[ $class_name ])) { |
|
| 261 | + $reflection_class = $this->getReflectionClass($class_name); |
|
| 262 | + $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
| 263 | + } |
|
| 264 | + return $this->methods[ $class_name ]; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * @param ReflectionClass $reflection_class ) |
|
| 270 | + * @return ReflectionMethod[] |
|
| 271 | + * @throws InvalidDataTypeException |
|
| 272 | + * @throws ReflectionException |
|
| 273 | + */ |
|
| 274 | + public function getMethodsFromReflection(ReflectionClass $reflection_class): array |
|
| 275 | + { |
|
| 276 | + return $this->getMethods($reflection_class->getName()); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * @param string $class_name |
|
| 282 | + * @return array |
|
| 283 | + * @throws InvalidDataTypeException |
|
| 284 | + * @throws ReflectionException |
|
| 285 | + */ |
|
| 286 | + public function getDefaultProperties(string $class_name): array |
|
| 287 | + { |
|
| 288 | + if (! isset($this->default_properties[ $class_name ])) { |
|
| 289 | + $reflection_class = $this->getReflectionClass($class_name); |
|
| 290 | + $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties(); |
|
| 291 | + } |
|
| 292 | + return $this->default_properties[ $class_name ]; |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + /** |
|
| 297 | + * @param string $class_name |
|
| 298 | + * @return array |
|
| 299 | + * @throws InvalidDataTypeException |
|
| 300 | + * @throws ReflectionException |
|
| 301 | + */ |
|
| 302 | + public function getStaticProperties(string $class_name): array |
|
| 303 | + { |
|
| 304 | + if (! isset($this->static_properties[ $class_name ])) { |
|
| 305 | + $reflection_class = $this->getReflectionClass($class_name); |
|
| 306 | + $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties(); |
|
| 307 | + } |
|
| 308 | + return $this->static_properties[ $class_name ]; |
|
| 309 | + } |
|
| 310 | 310 | } |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | public function getReflectionClass(string $class_name): ReflectionClass |
| 72 | 72 | { |
| 73 | - if (! is_string($class_name)) { |
|
| 73 | + if ( ! is_string($class_name)) { |
|
| 74 | 74 | throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
| 75 | 75 | } |
| 76 | - if (! isset($this->classes[ $class_name ])) { |
|
| 77 | - $this->classes[ $class_name ] = new ReflectionClass($class_name); |
|
| 76 | + if ( ! isset($this->classes[$class_name])) { |
|
| 77 | + $this->classes[$class_name] = new ReflectionClass($class_name); |
|
| 78 | 78 | } |
| 79 | - return $this->classes[ $class_name ]; |
|
| 79 | + return $this->classes[$class_name]; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | |
@@ -88,14 +88,14 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public function getConstructor(string $class_name): ?ReflectionMethod |
| 90 | 90 | { |
| 91 | - if (! is_string($class_name)) { |
|
| 91 | + if ( ! is_string($class_name)) { |
|
| 92 | 92 | throw new InvalidDataTypeException($class_name, '$class_name', 'string (fully qualified class name)'); |
| 93 | 93 | } |
| 94 | - if (! isset($this->constructors[ $class_name ])) { |
|
| 94 | + if ( ! isset($this->constructors[$class_name])) { |
|
| 95 | 95 | $reflection_class = $this->getReflectionClass($class_name); |
| 96 | - $this->constructors[ $class_name ] = $reflection_class->getConstructor(); |
|
| 96 | + $this->constructors[$class_name] = $reflection_class->getConstructor(); |
|
| 97 | 97 | } |
| 98 | - return $this->constructors[ $class_name ]; |
|
| 98 | + return $this->constructors[$class_name]; |
|
| 99 | 99 | } |
| 100 | 100 | |
| 101 | 101 | |
@@ -119,11 +119,11 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function getParameters(string $class_name): array |
| 121 | 121 | { |
| 122 | - if (! isset($this->parameters[ $class_name ])) { |
|
| 122 | + if ( ! isset($this->parameters[$class_name])) { |
|
| 123 | 123 | $constructor = $this->getConstructor($class_name); |
| 124 | - $this->parameters[ $class_name ] = $constructor->getParameters(); |
|
| 124 | + $this->parameters[$class_name] = $constructor->getParameters(); |
|
| 125 | 125 | } |
| 126 | - return $this->parameters[ $class_name ]; |
|
| 126 | + return $this->parameters[$class_name]; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
@@ -180,19 +180,19 @@ discard block |
||
| 180 | 180 | */ |
| 181 | 181 | public function getParameterClassName(ReflectionParameter $param, string $class_name, string $index): ?string |
| 182 | 182 | { |
| 183 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_name'])) { |
|
| 184 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 183 | + if (isset($this->parameter_classes[$class_name][$index]['param_class_name'])) { |
|
| 184 | + return $this->parameter_classes[$class_name][$index]['param_class_name']; |
|
| 185 | 185 | } |
| 186 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 187 | - $this->parameter_classes[ $class_name ] = []; |
|
| 186 | + if ( ! isset($this->parameter_classes[$class_name])) { |
|
| 187 | + $this->parameter_classes[$class_name] = []; |
|
| 188 | 188 | } |
| 189 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 190 | - $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 189 | + if ( ! isset($this->parameter_classes[$class_name][$index])) { |
|
| 190 | + $this->parameter_classes[$class_name][$index] = []; |
|
| 191 | 191 | } |
| 192 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_name'] = $param->getClass() |
|
| 192 | + $this->parameter_classes[$class_name][$index]['param_class_name'] = $param->getClass() |
|
| 193 | 193 | ? $param->getClass()->name |
| 194 | 194 | : null; |
| 195 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_name']; |
|
| 195 | + return $this->parameter_classes[$class_name][$index]['param_class_name']; |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | */ |
| 206 | 206 | public function getParameterDefaultValue(ReflectionParameter $param, string $class_name, string $index) |
| 207 | 207 | { |
| 208 | - if (isset($this->parameter_classes[ $class_name ][ $index ]['param_class_default'])) { |
|
| 209 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 208 | + if (isset($this->parameter_classes[$class_name][$index]['param_class_default'])) { |
|
| 209 | + return $this->parameter_classes[$class_name][$index]['param_class_default']; |
|
| 210 | 210 | } |
| 211 | - if (! isset($this->parameter_classes[ $class_name ])) { |
|
| 212 | - $this->parameter_classes[ $class_name ] = []; |
|
| 211 | + if ( ! isset($this->parameter_classes[$class_name])) { |
|
| 212 | + $this->parameter_classes[$class_name] = []; |
|
| 213 | 213 | } |
| 214 | - if (! isset($this->parameter_classes[ $class_name ][ $index ])) { |
|
| 215 | - $this->parameter_classes[ $class_name ][ $index ] = []; |
|
| 214 | + if ( ! isset($this->parameter_classes[$class_name][$index])) { |
|
| 215 | + $this->parameter_classes[$class_name][$index] = []; |
|
| 216 | 216 | } |
| 217 | - $this->parameter_classes[ $class_name ][ $index ]['param_class_default'] = $param->isDefaultValueAvailable() |
|
| 217 | + $this->parameter_classes[$class_name][$index]['param_class_default'] = $param->isDefaultValueAvailable() |
|
| 218 | 218 | ? $param->getDefaultValue() |
| 219 | 219 | : null; |
| 220 | - return $this->parameter_classes[ $class_name ][ $index ]['param_class_default']; |
|
| 220 | + return $this->parameter_classes[$class_name][$index]['param_class_default']; |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -229,11 +229,11 @@ discard block |
||
| 229 | 229 | */ |
| 230 | 230 | public function getProperties(string $class_name): array |
| 231 | 231 | { |
| 232 | - if (! isset($this->properties[ $class_name ])) { |
|
| 232 | + if ( ! isset($this->properties[$class_name])) { |
|
| 233 | 233 | $reflection_class = $this->getReflectionClass($class_name); |
| 234 | - $this->properties[ $class_name ] = $reflection_class->getProperties(); |
|
| 234 | + $this->properties[$class_name] = $reflection_class->getProperties(); |
|
| 235 | 235 | } |
| 236 | - return $this->properties[ $class_name ]; |
|
| 236 | + return $this->properties[$class_name]; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
@@ -257,11 +257,11 @@ discard block |
||
| 257 | 257 | */ |
| 258 | 258 | public function getMethods(string $class_name): array |
| 259 | 259 | { |
| 260 | - if (! isset($this->methods[ $class_name ])) { |
|
| 260 | + if ( ! isset($this->methods[$class_name])) { |
|
| 261 | 261 | $reflection_class = $this->getReflectionClass($class_name); |
| 262 | - $this->methods[ $class_name ] = $reflection_class->getMethods(); |
|
| 262 | + $this->methods[$class_name] = $reflection_class->getMethods(); |
|
| 263 | 263 | } |
| 264 | - return $this->methods[ $class_name ]; |
|
| 264 | + return $this->methods[$class_name]; |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | |
@@ -285,11 +285,11 @@ discard block |
||
| 285 | 285 | */ |
| 286 | 286 | public function getDefaultProperties(string $class_name): array |
| 287 | 287 | { |
| 288 | - if (! isset($this->default_properties[ $class_name ])) { |
|
| 288 | + if ( ! isset($this->default_properties[$class_name])) { |
|
| 289 | 289 | $reflection_class = $this->getReflectionClass($class_name); |
| 290 | - $this->default_properties[ $class_name ] = $reflection_class->getDefaultProperties(); |
|
| 290 | + $this->default_properties[$class_name] = $reflection_class->getDefaultProperties(); |
|
| 291 | 291 | } |
| 292 | - return $this->default_properties[ $class_name ]; |
|
| 292 | + return $this->default_properties[$class_name]; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
@@ -301,10 +301,10 @@ discard block |
||
| 301 | 301 | */ |
| 302 | 302 | public function getStaticProperties(string $class_name): array |
| 303 | 303 | { |
| 304 | - if (! isset($this->static_properties[ $class_name ])) { |
|
| 304 | + if ( ! isset($this->static_properties[$class_name])) { |
|
| 305 | 305 | $reflection_class = $this->getReflectionClass($class_name); |
| 306 | - $this->static_properties[ $class_name ] = $reflection_class->getStaticProperties(); |
|
| 306 | + $this->static_properties[$class_name] = $reflection_class->getStaticProperties(); |
|
| 307 | 307 | } |
| 308 | - return $this->static_properties[ $class_name ]; |
|
| 308 | + return $this->static_properties[$class_name]; |
|
| 309 | 309 | } |
| 310 | 310 | } |
@@ -47,618 +47,618 @@ |
||
| 47 | 47 | class ModelFieldFactory |
| 48 | 48 | { |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @var LoaderInterface $loader |
|
| 52 | - */ |
|
| 53 | - private $loader; |
|
| 54 | - |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * ModelFieldFactory constructor. |
|
| 58 | - * |
|
| 59 | - * @param LoaderInterface $loader |
|
| 60 | - */ |
|
| 61 | - public function __construct(LoaderInterface $loader) |
|
| 62 | - { |
|
| 63 | - $this->loader = $loader; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * @param string $table_column |
|
| 69 | - * @param string $nice_name |
|
| 70 | - * @param bool $nullable |
|
| 71 | - * @param null $default_value |
|
| 72 | - * @return EE_All_Caps_Text_Field |
|
| 73 | - */ |
|
| 74 | - public function createAllCapsTextField( |
|
| 75 | - string $table_column, |
|
| 76 | - string $nice_name, |
|
| 77 | - bool $nullable, |
|
| 78 | - $default_value = null |
|
| 79 | - ): EE_All_Caps_Text_Field { |
|
| 80 | - return $this->loader->getNew( |
|
| 81 | - 'EE_All_Caps_Text_Field', |
|
| 82 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 83 | - ); |
|
| 84 | - } |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param string $table_column |
|
| 89 | - * @param string $nice_name |
|
| 90 | - * @param bool $nullable |
|
| 91 | - * @param null $default_value |
|
| 92 | - * @param string $model_name |
|
| 93 | - * @return EE_Any_Foreign_Model_Name_Field |
|
| 94 | - */ |
|
| 95 | - public function createAnyForeignModelNameField( |
|
| 96 | - string $table_column, |
|
| 97 | - string $nice_name, |
|
| 98 | - bool $nullable, |
|
| 99 | - $default_value = null, |
|
| 100 | - string $model_name = '' |
|
| 101 | - ): EE_Any_Foreign_Model_Name_Field { |
|
| 102 | - return $this->loader->getNew( |
|
| 103 | - 'EE_Any_Foreign_Model_Name_Field', |
|
| 104 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 105 | - ); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @param string $table_column |
|
| 111 | - * @param string $nice_name |
|
| 112 | - * @param bool $nullable |
|
| 113 | - * @param null $default_value |
|
| 114 | - * @return EE_Boolean_Field |
|
| 115 | - */ |
|
| 116 | - public function createBooleanField( |
|
| 117 | - string $table_column, |
|
| 118 | - string $nice_name, |
|
| 119 | - bool $nullable, |
|
| 120 | - $default_value = null |
|
| 121 | - ): EE_Boolean_Field { |
|
| 122 | - return $this->loader->getNew( |
|
| 123 | - 'EE_Boolean_Field', |
|
| 124 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @param string $table_column |
|
| 131 | - * @param string $nice_name |
|
| 132 | - * @param bool $nullable |
|
| 133 | - * @param string $default_value |
|
| 134 | - * @return EE_Datetime_Field |
|
| 135 | - */ |
|
| 136 | - public function createDatetimeField( |
|
| 137 | - string $table_column, |
|
| 138 | - string $nice_name, |
|
| 139 | - bool $nullable = false, |
|
| 140 | - string $default_value = EE_Datetime_Field::now |
|
| 141 | - ): EE_Datetime_Field { |
|
| 142 | - return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @param string $table_column |
|
| 148 | - * @param string $nice_name |
|
| 149 | - * @param bool $nullable |
|
| 150 | - * @param null $default_value |
|
| 151 | - * @return EE_DB_Only_Float_Field |
|
| 152 | - */ |
|
| 153 | - public function createDbOnlyFloatField( |
|
| 154 | - string $table_column, |
|
| 155 | - string $nice_name, |
|
| 156 | - bool $nullable, |
|
| 157 | - $default_value = null |
|
| 158 | - ): EE_DB_Only_Float_Field { |
|
| 159 | - return $this->loader->getNew( |
|
| 160 | - 'EE_DB_Only_Float_Field', |
|
| 161 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 162 | - ); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - /** |
|
| 167 | - * @param string $table_column |
|
| 168 | - * @param string $nice_name |
|
| 169 | - * @param bool $nullable |
|
| 170 | - * @param null $default_value |
|
| 171 | - * @return EE_DB_Only_Int_Field |
|
| 172 | - */ |
|
| 173 | - public function createDbOnlyIntField( |
|
| 174 | - string $table_column, |
|
| 175 | - string $nice_name, |
|
| 176 | - bool $nullable, |
|
| 177 | - $default_value = null |
|
| 178 | - ): EE_DB_Only_Int_Field { |
|
| 179 | - return $this->loader->getNew( |
|
| 180 | - 'EE_DB_Only_Int_Field', |
|
| 181 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 182 | - ); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - /** |
|
| 187 | - * @param string $table_column |
|
| 188 | - * @param string $nice_name |
|
| 189 | - * @param bool $nullable |
|
| 190 | - * @param null $default_value |
|
| 191 | - * @return EE_DB_Only_Text_Field |
|
| 192 | - */ |
|
| 193 | - public function createDbOnlyTextField( |
|
| 194 | - string $table_column, |
|
| 195 | - string $nice_name, |
|
| 196 | - bool $nullable, |
|
| 197 | - $default_value = null |
|
| 198 | - ): EE_DB_Only_Text_Field { |
|
| 199 | - return $this->loader->getNew( |
|
| 200 | - 'EE_DB_Only_Text_Field', |
|
| 201 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 202 | - ); |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - |
|
| 206 | - /** |
|
| 207 | - * @param string $table_column |
|
| 208 | - * @param string $nice_name |
|
| 209 | - * @param bool $nullable |
|
| 210 | - * @param string|null $default_value |
|
| 211 | - * @return EE_Email_Field |
|
| 212 | - */ |
|
| 213 | - public function createEmailField( |
|
| 214 | - string $table_column, |
|
| 215 | - string $nice_name, |
|
| 216 | - bool $nullable = true, |
|
| 217 | - string $default_value = '' |
|
| 218 | - ): EE_Email_Field { |
|
| 219 | - return $this->loader->getNew( |
|
| 220 | - 'EE_Email_Field', |
|
| 221 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 222 | - ); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * @param string $table_column |
|
| 228 | - * @param string $nice_name |
|
| 229 | - * @param bool $nullable |
|
| 230 | - * @param null $default_value |
|
| 231 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 232 | - * values are how they should be displayed |
|
| 233 | - * @return EE_Enum_Integer_Field |
|
| 234 | - */ |
|
| 235 | - public function createEnumIntegerField( |
|
| 236 | - string $table_column, |
|
| 237 | - string $nice_name, |
|
| 238 | - bool $nullable, |
|
| 239 | - $default_value = null, |
|
| 240 | - array $allowed_enum_values = [] |
|
| 241 | - ): EE_Enum_Integer_Field { |
|
| 242 | - return $this->loader->getNew( |
|
| 243 | - 'EE_Enum_Integer_Field', |
|
| 244 | - [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
| 245 | - ); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * @param string $table_column |
|
| 251 | - * @param string $nice_name |
|
| 252 | - * @param bool $nullable |
|
| 253 | - * @param null $default_value |
|
| 254 | - * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 255 | - * values are how they should be displayed |
|
| 256 | - * @return EE_Enum_Text_Field |
|
| 257 | - */ |
|
| 258 | - public function createEnumTextField( |
|
| 259 | - string $table_column, |
|
| 260 | - string $nice_name, |
|
| 261 | - bool $nullable, |
|
| 262 | - $default_value, |
|
| 263 | - array $allowed_enum_values |
|
| 264 | - ): EE_Enum_Text_Field { |
|
| 265 | - return $this->loader->getNew( |
|
| 266 | - 'EE_Enum_Text_Field', |
|
| 267 | - [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
| 268 | - ); |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * @param string $table_column |
|
| 274 | - * @param string $nice_name |
|
| 275 | - * @param bool $nullable |
|
| 276 | - * @param null $default_value |
|
| 277 | - * @return EE_Float_Field |
|
| 278 | - */ |
|
| 279 | - public function createFloatField( |
|
| 280 | - string $table_column, |
|
| 281 | - string $nice_name, |
|
| 282 | - bool $nullable, |
|
| 283 | - $default_value = null |
|
| 284 | - ): EE_Float_Field { |
|
| 285 | - return $this->loader->getNew( |
|
| 286 | - 'EE_Float_Field', |
|
| 287 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 288 | - ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - /** |
|
| 293 | - * @param string $table_column |
|
| 294 | - * @param string $nice_name |
|
| 295 | - * @param bool $nullable |
|
| 296 | - * @param null $default_value |
|
| 297 | - * @param string $model_name |
|
| 298 | - * @return EE_Foreign_Key_Int_Field |
|
| 299 | - */ |
|
| 300 | - public function createForeignKeyIntField( |
|
| 301 | - string $table_column, |
|
| 302 | - string $nice_name, |
|
| 303 | - bool $nullable, |
|
| 304 | - $default_value, |
|
| 305 | - string $model_name |
|
| 306 | - ): EE_Foreign_Key_Int_Field { |
|
| 307 | - return $this->loader->getNew( |
|
| 308 | - 'EE_Foreign_Key_Int_Field', |
|
| 309 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 310 | - ); |
|
| 311 | - } |
|
| 312 | - |
|
| 313 | - |
|
| 314 | - /** |
|
| 315 | - * @param string $table_column |
|
| 316 | - * @param string $nice_name |
|
| 317 | - * @param bool $nullable |
|
| 318 | - * @param null $default_value |
|
| 319 | - * @param string $model_name |
|
| 320 | - * @return EE_Foreign_Key_String_Field |
|
| 321 | - */ |
|
| 322 | - public function createForeignKeyStringField( |
|
| 323 | - string $table_column, |
|
| 324 | - string $nice_name, |
|
| 325 | - bool $nullable, |
|
| 326 | - $default_value, |
|
| 327 | - string $model_name |
|
| 328 | - ): EE_Foreign_Key_String_Field { |
|
| 329 | - return $this->loader->getNew( |
|
| 330 | - 'EE_Foreign_Key_String_Field', |
|
| 331 | - [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 332 | - ); |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - |
|
| 336 | - /** |
|
| 337 | - * @param string $table_column |
|
| 338 | - * @param string $nice_name |
|
| 339 | - * @param bool $nullable |
|
| 340 | - * @param null $default_value |
|
| 341 | - * @return EE_Full_HTML_Field |
|
| 342 | - */ |
|
| 343 | - public function createFullHtmlField( |
|
| 344 | - string $table_column, |
|
| 345 | - string $nice_name, |
|
| 346 | - bool $nullable, |
|
| 347 | - $default_value = null |
|
| 348 | - ): EE_Full_HTML_Field { |
|
| 349 | - return $this->loader->getNew( |
|
| 350 | - 'EE_Full_HTML_Field', |
|
| 351 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 352 | - ); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * @param string $table_column |
|
| 358 | - * @param string $nice_name |
|
| 359 | - * @param bool $nullable |
|
| 360 | - * @param null $default_value |
|
| 361 | - * @return EE_Infinite_Integer_Field |
|
| 362 | - */ |
|
| 363 | - public function createInfiniteIntegerField( |
|
| 364 | - string $table_column, |
|
| 365 | - string $nice_name, |
|
| 366 | - bool $nullable, |
|
| 367 | - $default_value = null |
|
| 368 | - ): EE_Infinite_Integer_Field { |
|
| 369 | - return $this->loader->getNew( |
|
| 370 | - 'EE_Infinite_Integer_Field', |
|
| 371 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 372 | - ); |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - |
|
| 376 | - /** |
|
| 377 | - * @param string $table_column |
|
| 378 | - * @param string $nice_name |
|
| 379 | - * @param bool $nullable |
|
| 380 | - * @param integer $default_value |
|
| 381 | - * @return EE_Integer_Field |
|
| 382 | - */ |
|
| 383 | - public function createIntegerField( |
|
| 384 | - string $table_column, |
|
| 385 | - string $nice_name, |
|
| 386 | - bool $nullable = false, |
|
| 387 | - int $default_value = 0 |
|
| 388 | - ): EE_Integer_Field { |
|
| 389 | - return $this->loader->getNew( |
|
| 390 | - 'EE_Integer_Field', |
|
| 391 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 392 | - ); |
|
| 393 | - } |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * @param string $table_column |
|
| 398 | - * @param string $nice_name |
|
| 399 | - * @param bool $nullable |
|
| 400 | - * @param null $default_value |
|
| 401 | - * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
| 402 | - */ |
|
| 403 | - public function createMaybeSerializedSimpleHtmlField( |
|
| 404 | - string $table_column, |
|
| 405 | - string $nice_name, |
|
| 406 | - bool $nullable, |
|
| 407 | - $default_value = null |
|
| 408 | - ): EE_Maybe_Serialized_Simple_HTML_Field { |
|
| 409 | - return $this->loader->getNew( |
|
| 410 | - 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
| 411 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 412 | - ); |
|
| 413 | - } |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * @param string $table_column |
|
| 418 | - * @param string $nice_name |
|
| 419 | - * @param bool $nullable |
|
| 420 | - * @param null $default_value |
|
| 421 | - * @return EE_Maybe_Serialized_Text_Field |
|
| 422 | - */ |
|
| 423 | - public function createMaybeSerializedTextField( |
|
| 424 | - string $table_column, |
|
| 425 | - string $nice_name, |
|
| 426 | - bool $nullable, |
|
| 427 | - $default_value = null |
|
| 428 | - ): EE_Maybe_Serialized_Text_Field { |
|
| 429 | - return $this->loader->getNew( |
|
| 430 | - 'EE_Maybe_Serialized_Text_Field', |
|
| 431 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 432 | - ); |
|
| 433 | - } |
|
| 434 | - |
|
| 435 | - |
|
| 436 | - /** |
|
| 437 | - * @param string $table_column |
|
| 438 | - * @param string $nice_name |
|
| 439 | - * @param bool $nullable |
|
| 440 | - * @param null $default_value |
|
| 441 | - * @return EE_Money_Field |
|
| 442 | - */ |
|
| 443 | - public function createMoneyField( |
|
| 444 | - string $table_column, |
|
| 445 | - string $nice_name, |
|
| 446 | - bool $nullable, |
|
| 447 | - $default_value = null |
|
| 448 | - ): EE_Money_Field { |
|
| 449 | - return $this->loader->getNew( |
|
| 450 | - 'EE_Money_Field', |
|
| 451 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 452 | - ); |
|
| 453 | - } |
|
| 454 | - |
|
| 455 | - |
|
| 456 | - /** |
|
| 457 | - * @param string $table_column |
|
| 458 | - * @param string $nice_name |
|
| 459 | - * @param bool $nullable |
|
| 460 | - * @param string $default_value |
|
| 461 | - * @return EE_Plain_Text_Field |
|
| 462 | - */ |
|
| 463 | - public function createPlainTextField( |
|
| 464 | - string $table_column, |
|
| 465 | - string $nice_name, |
|
| 466 | - bool $nullable = true, |
|
| 467 | - string $default_value = '' |
|
| 468 | - ): EE_Plain_Text_Field { |
|
| 469 | - return $this->loader->getNew( |
|
| 470 | - 'EE_Plain_Text_Field', |
|
| 471 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 472 | - ); |
|
| 473 | - } |
|
| 474 | - |
|
| 475 | - |
|
| 476 | - /** |
|
| 477 | - * @param string $table_column |
|
| 478 | - * @param string $nice_name |
|
| 479 | - * @param bool $nullable |
|
| 480 | - * @param null $default_value |
|
| 481 | - * @return EE_Post_Content_Field |
|
| 482 | - */ |
|
| 483 | - public function createPostContentField( |
|
| 484 | - string $table_column, |
|
| 485 | - string $nice_name, |
|
| 486 | - bool $nullable, |
|
| 487 | - $default_value = null |
|
| 488 | - ): EE_Post_Content_Field { |
|
| 489 | - return $this->loader->getNew( |
|
| 490 | - 'EE_Post_Content_Field', |
|
| 491 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 492 | - ); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - |
|
| 496 | - /** |
|
| 497 | - * @param string $table_column |
|
| 498 | - * @param string $nice_name |
|
| 499 | - * @return EE_Primary_Key_Int_Field |
|
| 500 | - */ |
|
| 501 | - public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field |
|
| 502 | - { |
|
| 503 | - return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]); |
|
| 504 | - } |
|
| 505 | - |
|
| 506 | - |
|
| 507 | - /** |
|
| 508 | - * @param string $table_column |
|
| 509 | - * @param string $nice_name |
|
| 510 | - * @return EE_Primary_Key_String_Field |
|
| 511 | - */ |
|
| 512 | - public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field |
|
| 513 | - { |
|
| 514 | - return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]); |
|
| 515 | - } |
|
| 516 | - |
|
| 517 | - |
|
| 518 | - /** |
|
| 519 | - * @param string $table_column |
|
| 520 | - * @param string $nice_name |
|
| 521 | - * @param bool $nullable |
|
| 522 | - * @param null $default_value |
|
| 523 | - * @return EE_Serialized_Text_Field |
|
| 524 | - */ |
|
| 525 | - public function createSerializedTextField( |
|
| 526 | - string $table_column, |
|
| 527 | - string $nice_name, |
|
| 528 | - bool $nullable, |
|
| 529 | - $default_value = null |
|
| 530 | - ): EE_Serialized_Text_Field { |
|
| 531 | - return $this->loader->getNew( |
|
| 532 | - 'EE_Serialized_Text_Field', |
|
| 533 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 534 | - ); |
|
| 535 | - } |
|
| 536 | - |
|
| 537 | - |
|
| 538 | - /** |
|
| 539 | - * @param string $table_column |
|
| 540 | - * @param string $nice_name |
|
| 541 | - * @param bool $nullable |
|
| 542 | - * @param null $default_value |
|
| 543 | - * @return EE_Simple_HTML_Field |
|
| 544 | - */ |
|
| 545 | - public function createSimpleHtmlField( |
|
| 546 | - string $table_column, |
|
| 547 | - string $nice_name, |
|
| 548 | - bool $nullable, |
|
| 549 | - $default_value = null |
|
| 550 | - ): EE_Simple_HTML_Field { |
|
| 551 | - return $this->loader->getNew( |
|
| 552 | - 'EE_Simple_HTML_Field', |
|
| 553 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 554 | - ); |
|
| 555 | - } |
|
| 556 | - |
|
| 557 | - |
|
| 558 | - /** |
|
| 559 | - * @param string $table_column |
|
| 560 | - * @param string $nice_name |
|
| 561 | - * @param bool $nullable |
|
| 562 | - * @param null $default_value |
|
| 563 | - * @return EE_Slug_Field |
|
| 564 | - */ |
|
| 565 | - public function createSlugField( |
|
| 566 | - string $table_column, |
|
| 567 | - string $nice_name, |
|
| 568 | - bool $nullable = false, |
|
| 569 | - $default_value = null |
|
| 570 | - ): EE_Slug_Field { |
|
| 571 | - return $this->loader->getNew( |
|
| 572 | - 'EE_Slug_Field', |
|
| 573 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 574 | - ); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * @param string $table_column |
|
| 580 | - * @param string $nice_name |
|
| 581 | - * @param bool $nullable |
|
| 582 | - * @param null $default_value |
|
| 583 | - * @return EE_Trashed_Flag_Field |
|
| 584 | - */ |
|
| 585 | - public function createTrashedFlagField( |
|
| 586 | - string $table_column, |
|
| 587 | - string $nice_name, |
|
| 588 | - bool $nullable, |
|
| 589 | - $default_value = null |
|
| 590 | - ): EE_Trashed_Flag_Field { |
|
| 591 | - return $this->loader->getNew( |
|
| 592 | - 'EE_Trashed_Flag_Field', |
|
| 593 | - [$table_column, $nice_name, $nullable, $default_value] |
|
| 594 | - ); |
|
| 595 | - } |
|
| 596 | - |
|
| 597 | - |
|
| 598 | - /** |
|
| 599 | - * @param string $table_column |
|
| 600 | - * @param string $nice_name |
|
| 601 | - * @param bool $nullable |
|
| 602 | - * @param mixed $default_value |
|
| 603 | - * @param array $values If additional statuses are to be used other than the default WP statuses, |
|
| 604 | - * then they can be registered via this property. |
|
| 605 | - * The format of the array should be as follows: |
|
| 606 | - * [ |
|
| 607 | - * 'status_reference' => [ |
|
| 608 | - * 'label' => __('Status Reference Label', 'event_espresso'), |
|
| 609 | - * // whether status is shown on the frontend of the site |
|
| 610 | - * 'public' => true, |
|
| 611 | - * // whether status is excluded from wp searches |
|
| 612 | - * 'exclude_from_search' => false, |
|
| 613 | - * // whether status is included in queries |
|
| 614 | - * for the admin 'all' view in list table views. |
|
| 615 | - * 'show_in_admin_all_list' => true, |
|
| 616 | - * // show in the list of statuses with post counts |
|
| 617 | - * // at the top of the admin list tables (i.e. Status Reference(2) ) |
|
| 618 | - * 'show_in_admin_status_list' => true, |
|
| 619 | - * // the text to display on the admin screen |
|
| 620 | - * // ( or you won't see your status count ) |
|
| 621 | - * 'label_count' => _n_noop( |
|
| 622 | - * 'Status Reference <span class="count">(%s)</span>', |
|
| 623 | - * 'Status References <span class="count">(%s)</span>' |
|
| 624 | - * ), |
|
| 625 | - * ] |
|
| 626 | - * ] |
|
| 627 | - * @return EE_WP_Post_Status_Field |
|
| 628 | - * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
| 629 | - */ |
|
| 630 | - public function createWpPostStatusField( |
|
| 631 | - string $table_column, |
|
| 632 | - string $nice_name, |
|
| 633 | - bool $nullable, |
|
| 634 | - $default_value = null, |
|
| 635 | - array $values = [] |
|
| 636 | - ): EE_WP_Post_Status_Field { |
|
| 637 | - return $this->loader->getNew( |
|
| 638 | - 'EE_WP_Post_Status_Field', |
|
| 639 | - [$table_column, $nice_name, $nullable, $default_value, $values] |
|
| 640 | - ); |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - |
|
| 644 | - /** |
|
| 645 | - * @param string $post_type |
|
| 646 | - * @return EE_WP_Post_Type_Field |
|
| 647 | - */ |
|
| 648 | - public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field |
|
| 649 | - { |
|
| 650 | - return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]); |
|
| 651 | - } |
|
| 652 | - |
|
| 653 | - |
|
| 654 | - /** |
|
| 655 | - * @param string $table_column |
|
| 656 | - * @param string $nice_name |
|
| 657 | - * @param bool $nullable |
|
| 658 | - * @return EE_WP_User_Field |
|
| 659 | - */ |
|
| 660 | - public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field |
|
| 661 | - { |
|
| 662 | - return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]); |
|
| 663 | - } |
|
| 50 | + /** |
|
| 51 | + * @var LoaderInterface $loader |
|
| 52 | + */ |
|
| 53 | + private $loader; |
|
| 54 | + |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * ModelFieldFactory constructor. |
|
| 58 | + * |
|
| 59 | + * @param LoaderInterface $loader |
|
| 60 | + */ |
|
| 61 | + public function __construct(LoaderInterface $loader) |
|
| 62 | + { |
|
| 63 | + $this->loader = $loader; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * @param string $table_column |
|
| 69 | + * @param string $nice_name |
|
| 70 | + * @param bool $nullable |
|
| 71 | + * @param null $default_value |
|
| 72 | + * @return EE_All_Caps_Text_Field |
|
| 73 | + */ |
|
| 74 | + public function createAllCapsTextField( |
|
| 75 | + string $table_column, |
|
| 76 | + string $nice_name, |
|
| 77 | + bool $nullable, |
|
| 78 | + $default_value = null |
|
| 79 | + ): EE_All_Caps_Text_Field { |
|
| 80 | + return $this->loader->getNew( |
|
| 81 | + 'EE_All_Caps_Text_Field', |
|
| 82 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 83 | + ); |
|
| 84 | + } |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param string $table_column |
|
| 89 | + * @param string $nice_name |
|
| 90 | + * @param bool $nullable |
|
| 91 | + * @param null $default_value |
|
| 92 | + * @param string $model_name |
|
| 93 | + * @return EE_Any_Foreign_Model_Name_Field |
|
| 94 | + */ |
|
| 95 | + public function createAnyForeignModelNameField( |
|
| 96 | + string $table_column, |
|
| 97 | + string $nice_name, |
|
| 98 | + bool $nullable, |
|
| 99 | + $default_value = null, |
|
| 100 | + string $model_name = '' |
|
| 101 | + ): EE_Any_Foreign_Model_Name_Field { |
|
| 102 | + return $this->loader->getNew( |
|
| 103 | + 'EE_Any_Foreign_Model_Name_Field', |
|
| 104 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 105 | + ); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @param string $table_column |
|
| 111 | + * @param string $nice_name |
|
| 112 | + * @param bool $nullable |
|
| 113 | + * @param null $default_value |
|
| 114 | + * @return EE_Boolean_Field |
|
| 115 | + */ |
|
| 116 | + public function createBooleanField( |
|
| 117 | + string $table_column, |
|
| 118 | + string $nice_name, |
|
| 119 | + bool $nullable, |
|
| 120 | + $default_value = null |
|
| 121 | + ): EE_Boolean_Field { |
|
| 122 | + return $this->loader->getNew( |
|
| 123 | + 'EE_Boolean_Field', |
|
| 124 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @param string $table_column |
|
| 131 | + * @param string $nice_name |
|
| 132 | + * @param bool $nullable |
|
| 133 | + * @param string $default_value |
|
| 134 | + * @return EE_Datetime_Field |
|
| 135 | + */ |
|
| 136 | + public function createDatetimeField( |
|
| 137 | + string $table_column, |
|
| 138 | + string $nice_name, |
|
| 139 | + bool $nullable = false, |
|
| 140 | + string $default_value = EE_Datetime_Field::now |
|
| 141 | + ): EE_Datetime_Field { |
|
| 142 | + return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @param string $table_column |
|
| 148 | + * @param string $nice_name |
|
| 149 | + * @param bool $nullable |
|
| 150 | + * @param null $default_value |
|
| 151 | + * @return EE_DB_Only_Float_Field |
|
| 152 | + */ |
|
| 153 | + public function createDbOnlyFloatField( |
|
| 154 | + string $table_column, |
|
| 155 | + string $nice_name, |
|
| 156 | + bool $nullable, |
|
| 157 | + $default_value = null |
|
| 158 | + ): EE_DB_Only_Float_Field { |
|
| 159 | + return $this->loader->getNew( |
|
| 160 | + 'EE_DB_Only_Float_Field', |
|
| 161 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 162 | + ); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + /** |
|
| 167 | + * @param string $table_column |
|
| 168 | + * @param string $nice_name |
|
| 169 | + * @param bool $nullable |
|
| 170 | + * @param null $default_value |
|
| 171 | + * @return EE_DB_Only_Int_Field |
|
| 172 | + */ |
|
| 173 | + public function createDbOnlyIntField( |
|
| 174 | + string $table_column, |
|
| 175 | + string $nice_name, |
|
| 176 | + bool $nullable, |
|
| 177 | + $default_value = null |
|
| 178 | + ): EE_DB_Only_Int_Field { |
|
| 179 | + return $this->loader->getNew( |
|
| 180 | + 'EE_DB_Only_Int_Field', |
|
| 181 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 182 | + ); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + /** |
|
| 187 | + * @param string $table_column |
|
| 188 | + * @param string $nice_name |
|
| 189 | + * @param bool $nullable |
|
| 190 | + * @param null $default_value |
|
| 191 | + * @return EE_DB_Only_Text_Field |
|
| 192 | + */ |
|
| 193 | + public function createDbOnlyTextField( |
|
| 194 | + string $table_column, |
|
| 195 | + string $nice_name, |
|
| 196 | + bool $nullable, |
|
| 197 | + $default_value = null |
|
| 198 | + ): EE_DB_Only_Text_Field { |
|
| 199 | + return $this->loader->getNew( |
|
| 200 | + 'EE_DB_Only_Text_Field', |
|
| 201 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 202 | + ); |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + |
|
| 206 | + /** |
|
| 207 | + * @param string $table_column |
|
| 208 | + * @param string $nice_name |
|
| 209 | + * @param bool $nullable |
|
| 210 | + * @param string|null $default_value |
|
| 211 | + * @return EE_Email_Field |
|
| 212 | + */ |
|
| 213 | + public function createEmailField( |
|
| 214 | + string $table_column, |
|
| 215 | + string $nice_name, |
|
| 216 | + bool $nullable = true, |
|
| 217 | + string $default_value = '' |
|
| 218 | + ): EE_Email_Field { |
|
| 219 | + return $this->loader->getNew( |
|
| 220 | + 'EE_Email_Field', |
|
| 221 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 222 | + ); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * @param string $table_column |
|
| 228 | + * @param string $nice_name |
|
| 229 | + * @param bool $nullable |
|
| 230 | + * @param null $default_value |
|
| 231 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 232 | + * values are how they should be displayed |
|
| 233 | + * @return EE_Enum_Integer_Field |
|
| 234 | + */ |
|
| 235 | + public function createEnumIntegerField( |
|
| 236 | + string $table_column, |
|
| 237 | + string $nice_name, |
|
| 238 | + bool $nullable, |
|
| 239 | + $default_value = null, |
|
| 240 | + array $allowed_enum_values = [] |
|
| 241 | + ): EE_Enum_Integer_Field { |
|
| 242 | + return $this->loader->getNew( |
|
| 243 | + 'EE_Enum_Integer_Field', |
|
| 244 | + [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
| 245 | + ); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * @param string $table_column |
|
| 251 | + * @param string $nice_name |
|
| 252 | + * @param bool $nullable |
|
| 253 | + * @param null $default_value |
|
| 254 | + * @param array $allowed_enum_values keys are values to be used in the DB, |
|
| 255 | + * values are how they should be displayed |
|
| 256 | + * @return EE_Enum_Text_Field |
|
| 257 | + */ |
|
| 258 | + public function createEnumTextField( |
|
| 259 | + string $table_column, |
|
| 260 | + string $nice_name, |
|
| 261 | + bool $nullable, |
|
| 262 | + $default_value, |
|
| 263 | + array $allowed_enum_values |
|
| 264 | + ): EE_Enum_Text_Field { |
|
| 265 | + return $this->loader->getNew( |
|
| 266 | + 'EE_Enum_Text_Field', |
|
| 267 | + [$table_column, $nice_name, $nullable, $default_value, $allowed_enum_values] |
|
| 268 | + ); |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * @param string $table_column |
|
| 274 | + * @param string $nice_name |
|
| 275 | + * @param bool $nullable |
|
| 276 | + * @param null $default_value |
|
| 277 | + * @return EE_Float_Field |
|
| 278 | + */ |
|
| 279 | + public function createFloatField( |
|
| 280 | + string $table_column, |
|
| 281 | + string $nice_name, |
|
| 282 | + bool $nullable, |
|
| 283 | + $default_value = null |
|
| 284 | + ): EE_Float_Field { |
|
| 285 | + return $this->loader->getNew( |
|
| 286 | + 'EE_Float_Field', |
|
| 287 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 288 | + ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + /** |
|
| 293 | + * @param string $table_column |
|
| 294 | + * @param string $nice_name |
|
| 295 | + * @param bool $nullable |
|
| 296 | + * @param null $default_value |
|
| 297 | + * @param string $model_name |
|
| 298 | + * @return EE_Foreign_Key_Int_Field |
|
| 299 | + */ |
|
| 300 | + public function createForeignKeyIntField( |
|
| 301 | + string $table_column, |
|
| 302 | + string $nice_name, |
|
| 303 | + bool $nullable, |
|
| 304 | + $default_value, |
|
| 305 | + string $model_name |
|
| 306 | + ): EE_Foreign_Key_Int_Field { |
|
| 307 | + return $this->loader->getNew( |
|
| 308 | + 'EE_Foreign_Key_Int_Field', |
|
| 309 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 310 | + ); |
|
| 311 | + } |
|
| 312 | + |
|
| 313 | + |
|
| 314 | + /** |
|
| 315 | + * @param string $table_column |
|
| 316 | + * @param string $nice_name |
|
| 317 | + * @param bool $nullable |
|
| 318 | + * @param null $default_value |
|
| 319 | + * @param string $model_name |
|
| 320 | + * @return EE_Foreign_Key_String_Field |
|
| 321 | + */ |
|
| 322 | + public function createForeignKeyStringField( |
|
| 323 | + string $table_column, |
|
| 324 | + string $nice_name, |
|
| 325 | + bool $nullable, |
|
| 326 | + $default_value, |
|
| 327 | + string $model_name |
|
| 328 | + ): EE_Foreign_Key_String_Field { |
|
| 329 | + return $this->loader->getNew( |
|
| 330 | + 'EE_Foreign_Key_String_Field', |
|
| 331 | + [$table_column, $nice_name, $nullable, $default_value, $model_name] |
|
| 332 | + ); |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + |
|
| 336 | + /** |
|
| 337 | + * @param string $table_column |
|
| 338 | + * @param string $nice_name |
|
| 339 | + * @param bool $nullable |
|
| 340 | + * @param null $default_value |
|
| 341 | + * @return EE_Full_HTML_Field |
|
| 342 | + */ |
|
| 343 | + public function createFullHtmlField( |
|
| 344 | + string $table_column, |
|
| 345 | + string $nice_name, |
|
| 346 | + bool $nullable, |
|
| 347 | + $default_value = null |
|
| 348 | + ): EE_Full_HTML_Field { |
|
| 349 | + return $this->loader->getNew( |
|
| 350 | + 'EE_Full_HTML_Field', |
|
| 351 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 352 | + ); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * @param string $table_column |
|
| 358 | + * @param string $nice_name |
|
| 359 | + * @param bool $nullable |
|
| 360 | + * @param null $default_value |
|
| 361 | + * @return EE_Infinite_Integer_Field |
|
| 362 | + */ |
|
| 363 | + public function createInfiniteIntegerField( |
|
| 364 | + string $table_column, |
|
| 365 | + string $nice_name, |
|
| 366 | + bool $nullable, |
|
| 367 | + $default_value = null |
|
| 368 | + ): EE_Infinite_Integer_Field { |
|
| 369 | + return $this->loader->getNew( |
|
| 370 | + 'EE_Infinite_Integer_Field', |
|
| 371 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 372 | + ); |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + |
|
| 376 | + /** |
|
| 377 | + * @param string $table_column |
|
| 378 | + * @param string $nice_name |
|
| 379 | + * @param bool $nullable |
|
| 380 | + * @param integer $default_value |
|
| 381 | + * @return EE_Integer_Field |
|
| 382 | + */ |
|
| 383 | + public function createIntegerField( |
|
| 384 | + string $table_column, |
|
| 385 | + string $nice_name, |
|
| 386 | + bool $nullable = false, |
|
| 387 | + int $default_value = 0 |
|
| 388 | + ): EE_Integer_Field { |
|
| 389 | + return $this->loader->getNew( |
|
| 390 | + 'EE_Integer_Field', |
|
| 391 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 392 | + ); |
|
| 393 | + } |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * @param string $table_column |
|
| 398 | + * @param string $nice_name |
|
| 399 | + * @param bool $nullable |
|
| 400 | + * @param null $default_value |
|
| 401 | + * @return EE_Maybe_Serialized_Simple_HTML_Field |
|
| 402 | + */ |
|
| 403 | + public function createMaybeSerializedSimpleHtmlField( |
|
| 404 | + string $table_column, |
|
| 405 | + string $nice_name, |
|
| 406 | + bool $nullable, |
|
| 407 | + $default_value = null |
|
| 408 | + ): EE_Maybe_Serialized_Simple_HTML_Field { |
|
| 409 | + return $this->loader->getNew( |
|
| 410 | + 'EE_Maybe_Serialized_Simple_HTML_Field', |
|
| 411 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 412 | + ); |
|
| 413 | + } |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * @param string $table_column |
|
| 418 | + * @param string $nice_name |
|
| 419 | + * @param bool $nullable |
|
| 420 | + * @param null $default_value |
|
| 421 | + * @return EE_Maybe_Serialized_Text_Field |
|
| 422 | + */ |
|
| 423 | + public function createMaybeSerializedTextField( |
|
| 424 | + string $table_column, |
|
| 425 | + string $nice_name, |
|
| 426 | + bool $nullable, |
|
| 427 | + $default_value = null |
|
| 428 | + ): EE_Maybe_Serialized_Text_Field { |
|
| 429 | + return $this->loader->getNew( |
|
| 430 | + 'EE_Maybe_Serialized_Text_Field', |
|
| 431 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 432 | + ); |
|
| 433 | + } |
|
| 434 | + |
|
| 435 | + |
|
| 436 | + /** |
|
| 437 | + * @param string $table_column |
|
| 438 | + * @param string $nice_name |
|
| 439 | + * @param bool $nullable |
|
| 440 | + * @param null $default_value |
|
| 441 | + * @return EE_Money_Field |
|
| 442 | + */ |
|
| 443 | + public function createMoneyField( |
|
| 444 | + string $table_column, |
|
| 445 | + string $nice_name, |
|
| 446 | + bool $nullable, |
|
| 447 | + $default_value = null |
|
| 448 | + ): EE_Money_Field { |
|
| 449 | + return $this->loader->getNew( |
|
| 450 | + 'EE_Money_Field', |
|
| 451 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 452 | + ); |
|
| 453 | + } |
|
| 454 | + |
|
| 455 | + |
|
| 456 | + /** |
|
| 457 | + * @param string $table_column |
|
| 458 | + * @param string $nice_name |
|
| 459 | + * @param bool $nullable |
|
| 460 | + * @param string $default_value |
|
| 461 | + * @return EE_Plain_Text_Field |
|
| 462 | + */ |
|
| 463 | + public function createPlainTextField( |
|
| 464 | + string $table_column, |
|
| 465 | + string $nice_name, |
|
| 466 | + bool $nullable = true, |
|
| 467 | + string $default_value = '' |
|
| 468 | + ): EE_Plain_Text_Field { |
|
| 469 | + return $this->loader->getNew( |
|
| 470 | + 'EE_Plain_Text_Field', |
|
| 471 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 472 | + ); |
|
| 473 | + } |
|
| 474 | + |
|
| 475 | + |
|
| 476 | + /** |
|
| 477 | + * @param string $table_column |
|
| 478 | + * @param string $nice_name |
|
| 479 | + * @param bool $nullable |
|
| 480 | + * @param null $default_value |
|
| 481 | + * @return EE_Post_Content_Field |
|
| 482 | + */ |
|
| 483 | + public function createPostContentField( |
|
| 484 | + string $table_column, |
|
| 485 | + string $nice_name, |
|
| 486 | + bool $nullable, |
|
| 487 | + $default_value = null |
|
| 488 | + ): EE_Post_Content_Field { |
|
| 489 | + return $this->loader->getNew( |
|
| 490 | + 'EE_Post_Content_Field', |
|
| 491 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 492 | + ); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + |
|
| 496 | + /** |
|
| 497 | + * @param string $table_column |
|
| 498 | + * @param string $nice_name |
|
| 499 | + * @return EE_Primary_Key_Int_Field |
|
| 500 | + */ |
|
| 501 | + public function createPrimaryKeyIntField(string $table_column, string $nice_name): EE_Primary_Key_Int_Field |
|
| 502 | + { |
|
| 503 | + return $this->loader->getNew('EE_Primary_Key_Int_Field', [$table_column, $nice_name]); |
|
| 504 | + } |
|
| 505 | + |
|
| 506 | + |
|
| 507 | + /** |
|
| 508 | + * @param string $table_column |
|
| 509 | + * @param string $nice_name |
|
| 510 | + * @return EE_Primary_Key_String_Field |
|
| 511 | + */ |
|
| 512 | + public function createPrimaryKeyStringField(string $table_column, string $nice_name): EE_Primary_Key_String_Field |
|
| 513 | + { |
|
| 514 | + return $this->loader->getNew('EE_Primary_Key_String_Field', [$table_column, $nice_name]); |
|
| 515 | + } |
|
| 516 | + |
|
| 517 | + |
|
| 518 | + /** |
|
| 519 | + * @param string $table_column |
|
| 520 | + * @param string $nice_name |
|
| 521 | + * @param bool $nullable |
|
| 522 | + * @param null $default_value |
|
| 523 | + * @return EE_Serialized_Text_Field |
|
| 524 | + */ |
|
| 525 | + public function createSerializedTextField( |
|
| 526 | + string $table_column, |
|
| 527 | + string $nice_name, |
|
| 528 | + bool $nullable, |
|
| 529 | + $default_value = null |
|
| 530 | + ): EE_Serialized_Text_Field { |
|
| 531 | + return $this->loader->getNew( |
|
| 532 | + 'EE_Serialized_Text_Field', |
|
| 533 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 534 | + ); |
|
| 535 | + } |
|
| 536 | + |
|
| 537 | + |
|
| 538 | + /** |
|
| 539 | + * @param string $table_column |
|
| 540 | + * @param string $nice_name |
|
| 541 | + * @param bool $nullable |
|
| 542 | + * @param null $default_value |
|
| 543 | + * @return EE_Simple_HTML_Field |
|
| 544 | + */ |
|
| 545 | + public function createSimpleHtmlField( |
|
| 546 | + string $table_column, |
|
| 547 | + string $nice_name, |
|
| 548 | + bool $nullable, |
|
| 549 | + $default_value = null |
|
| 550 | + ): EE_Simple_HTML_Field { |
|
| 551 | + return $this->loader->getNew( |
|
| 552 | + 'EE_Simple_HTML_Field', |
|
| 553 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 554 | + ); |
|
| 555 | + } |
|
| 556 | + |
|
| 557 | + |
|
| 558 | + /** |
|
| 559 | + * @param string $table_column |
|
| 560 | + * @param string $nice_name |
|
| 561 | + * @param bool $nullable |
|
| 562 | + * @param null $default_value |
|
| 563 | + * @return EE_Slug_Field |
|
| 564 | + */ |
|
| 565 | + public function createSlugField( |
|
| 566 | + string $table_column, |
|
| 567 | + string $nice_name, |
|
| 568 | + bool $nullable = false, |
|
| 569 | + $default_value = null |
|
| 570 | + ): EE_Slug_Field { |
|
| 571 | + return $this->loader->getNew( |
|
| 572 | + 'EE_Slug_Field', |
|
| 573 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 574 | + ); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * @param string $table_column |
|
| 580 | + * @param string $nice_name |
|
| 581 | + * @param bool $nullable |
|
| 582 | + * @param null $default_value |
|
| 583 | + * @return EE_Trashed_Flag_Field |
|
| 584 | + */ |
|
| 585 | + public function createTrashedFlagField( |
|
| 586 | + string $table_column, |
|
| 587 | + string $nice_name, |
|
| 588 | + bool $nullable, |
|
| 589 | + $default_value = null |
|
| 590 | + ): EE_Trashed_Flag_Field { |
|
| 591 | + return $this->loader->getNew( |
|
| 592 | + 'EE_Trashed_Flag_Field', |
|
| 593 | + [$table_column, $nice_name, $nullable, $default_value] |
|
| 594 | + ); |
|
| 595 | + } |
|
| 596 | + |
|
| 597 | + |
|
| 598 | + /** |
|
| 599 | + * @param string $table_column |
|
| 600 | + * @param string $nice_name |
|
| 601 | + * @param bool $nullable |
|
| 602 | + * @param mixed $default_value |
|
| 603 | + * @param array $values If additional statuses are to be used other than the default WP statuses, |
|
| 604 | + * then they can be registered via this property. |
|
| 605 | + * The format of the array should be as follows: |
|
| 606 | + * [ |
|
| 607 | + * 'status_reference' => [ |
|
| 608 | + * 'label' => __('Status Reference Label', 'event_espresso'), |
|
| 609 | + * // whether status is shown on the frontend of the site |
|
| 610 | + * 'public' => true, |
|
| 611 | + * // whether status is excluded from wp searches |
|
| 612 | + * 'exclude_from_search' => false, |
|
| 613 | + * // whether status is included in queries |
|
| 614 | + * for the admin 'all' view in list table views. |
|
| 615 | + * 'show_in_admin_all_list' => true, |
|
| 616 | + * // show in the list of statuses with post counts |
|
| 617 | + * // at the top of the admin list tables (i.e. Status Reference(2) ) |
|
| 618 | + * 'show_in_admin_status_list' => true, |
|
| 619 | + * // the text to display on the admin screen |
|
| 620 | + * // ( or you won't see your status count ) |
|
| 621 | + * 'label_count' => _n_noop( |
|
| 622 | + * 'Status Reference <span class="count">(%s)</span>', |
|
| 623 | + * 'Status References <span class="count">(%s)</span>' |
|
| 624 | + * ), |
|
| 625 | + * ] |
|
| 626 | + * ] |
|
| 627 | + * @return EE_WP_Post_Status_Field |
|
| 628 | + * @link http://codex.wordpress.org/Function_Reference/register_post_status for more info |
|
| 629 | + */ |
|
| 630 | + public function createWpPostStatusField( |
|
| 631 | + string $table_column, |
|
| 632 | + string $nice_name, |
|
| 633 | + bool $nullable, |
|
| 634 | + $default_value = null, |
|
| 635 | + array $values = [] |
|
| 636 | + ): EE_WP_Post_Status_Field { |
|
| 637 | + return $this->loader->getNew( |
|
| 638 | + 'EE_WP_Post_Status_Field', |
|
| 639 | + [$table_column, $nice_name, $nullable, $default_value, $values] |
|
| 640 | + ); |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + |
|
| 644 | + /** |
|
| 645 | + * @param string $post_type |
|
| 646 | + * @return EE_WP_Post_Type_Field |
|
| 647 | + */ |
|
| 648 | + public function createWpPostTypeField(string $post_type): EE_WP_Post_Type_Field |
|
| 649 | + { |
|
| 650 | + return $this->loader->getNew('EE_WP_Post_Type_Field', [$post_type]); |
|
| 651 | + } |
|
| 652 | + |
|
| 653 | + |
|
| 654 | + /** |
|
| 655 | + * @param string $table_column |
|
| 656 | + * @param string $nice_name |
|
| 657 | + * @param bool $nullable |
|
| 658 | + * @return EE_WP_User_Field |
|
| 659 | + */ |
|
| 660 | + public function createWpUserField(string $table_column, string $nice_name, bool $nullable): EE_WP_User_Field |
|
| 661 | + { |
|
| 662 | + return $this->loader->getNew('EE_WP_User_Field', [$table_column, $nice_name, $nullable]); |
|
| 663 | + } |
|
| 664 | 664 | } |
@@ -139,7 +139,7 @@ |
||
| 139 | 139 | bool $nullable = false, |
| 140 | 140 | string $default_value = EE_Datetime_Field::now |
| 141 | 141 | ): EE_Datetime_Field { |
| 142 | - return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value,]); |
|
| 142 | + return $this->loader->getNew('EE_Datetime_Field', [$table_column, $nice_name, $nullable, $default_value, ]); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | |
@@ -5,30 +5,30 @@ |
||
| 5 | 5 | abstract class EEM_Form_Element extends EEM_Base |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - /** |
|
| 9 | - * @var Element |
|
| 10 | - */ |
|
| 11 | - protected $element; |
|
| 12 | - |
|
| 13 | - /** |
|
| 14 | - * @var array |
|
| 15 | - */ |
|
| 16 | - protected $valid_status_options; |
|
| 17 | - |
|
| 18 | - |
|
| 19 | - protected function __construct(Element $element, $timezone) |
|
| 20 | - { |
|
| 21 | - $this->element = $element; |
|
| 22 | - parent::__construct($timezone); |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @param bool $constants_only |
|
| 28 | - * @return array |
|
| 29 | - */ |
|
| 30 | - public function validStatusOptions(bool $constants_only = false): array |
|
| 31 | - { |
|
| 32 | - return $this->element->validStatusOptions($constants_only); |
|
| 33 | - } |
|
| 8 | + /** |
|
| 9 | + * @var Element |
|
| 10 | + */ |
|
| 11 | + protected $element; |
|
| 12 | + |
|
| 13 | + /** |
|
| 14 | + * @var array |
|
| 15 | + */ |
|
| 16 | + protected $valid_status_options; |
|
| 17 | + |
|
| 18 | + |
|
| 19 | + protected function __construct(Element $element, $timezone) |
|
| 20 | + { |
|
| 21 | + $this->element = $element; |
|
| 22 | + parent::__construct($timezone); |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @param bool $constants_only |
|
| 28 | + * @return array |
|
| 29 | + */ |
|
| 30 | + public function validStatusOptions(bool $constants_only = false): array |
|
| 31 | + { |
|
| 32 | + return $this->element->validStatusOptions($constants_only); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -21,262 +21,262 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class EEM_Form_Section extends EEM_Form_Element |
| 23 | 23 | { |
| 24 | - public const APPLIES_TO_ALL = 'all'; |
|
| 24 | + public const APPLIES_TO_ALL = 'all'; |
|
| 25 | 25 | |
| 26 | - public const APPLIES_TO_PRIMARY = 'primary'; |
|
| 26 | + public const APPLIES_TO_PRIMARY = 'primary'; |
|
| 27 | 27 | |
| 28 | - public const APPLIES_TO_PURCHASER = 'purchaser'; |
|
| 28 | + public const APPLIES_TO_PURCHASER = 'purchaser'; |
|
| 29 | 29 | |
| 30 | - public const APPLIES_TO_REGISTRANTS = 'registrants'; |
|
| 30 | + public const APPLIES_TO_REGISTRANTS = 'registrants'; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * @var EEM_Form_Section |
|
| 34 | - */ |
|
| 35 | - protected static $_instance; |
|
| 32 | + /** |
|
| 33 | + * @var EEM_Form_Section |
|
| 34 | + */ |
|
| 35 | + protected static $_instance; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @var RequestInterface |
|
| 39 | - */ |
|
| 40 | - private $request; |
|
| 37 | + /** |
|
| 38 | + * @var RequestInterface |
|
| 39 | + */ |
|
| 40 | + private $request; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * @var array |
|
| 44 | - */ |
|
| 45 | - private $valid_applies_to_options; |
|
| 42 | + /** |
|
| 43 | + * @var array |
|
| 44 | + */ |
|
| 45 | + private $valid_applies_to_options; |
|
| 46 | 46 | |
| 47 | 47 | |
| 48 | - protected function __construct(Element $element, $timezone = null) |
|
| 49 | - { |
|
| 50 | - $this->valid_applies_to_options = apply_filters( |
|
| 51 | - 'FHEE__EEM_Form_Section__valid_applies_to_options', |
|
| 52 | - [ |
|
| 53 | - EEM_Form_Section::APPLIES_TO_ALL => esc_html__('All Registrants', 'event_espresso'), |
|
| 54 | - EEM_Form_Section::APPLIES_TO_PRIMARY => esc_html__('Primary Registrant Only', 'event_espresso'), |
|
| 55 | - EEM_Form_Section::APPLIES_TO_PURCHASER => esc_html__('Purchasing Agent', 'event_espresso'), |
|
| 56 | - EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'), |
|
| 57 | - ] |
|
| 58 | - ); |
|
| 48 | + protected function __construct(Element $element, $timezone = null) |
|
| 49 | + { |
|
| 50 | + $this->valid_applies_to_options = apply_filters( |
|
| 51 | + 'FHEE__EEM_Form_Section__valid_applies_to_options', |
|
| 52 | + [ |
|
| 53 | + EEM_Form_Section::APPLIES_TO_ALL => esc_html__('All Registrants', 'event_espresso'), |
|
| 54 | + EEM_Form_Section::APPLIES_TO_PRIMARY => esc_html__('Primary Registrant Only', 'event_espresso'), |
|
| 55 | + EEM_Form_Section::APPLIES_TO_PURCHASER => esc_html__('Purchasing Agent', 'event_espresso'), |
|
| 56 | + EEM_Form_Section::APPLIES_TO_REGISTRANTS => esc_html__('Additional Registrants', 'event_espresso'), |
|
| 57 | + ] |
|
| 58 | + ); |
|
| 59 | 59 | |
| 60 | - $related_entity_types = apply_filters( |
|
| 61 | - 'FHEE__EEM_Form_Section__related_entity_types', |
|
| 62 | - [ |
|
| 63 | - 'Datetime', |
|
| 64 | - 'Event', |
|
| 65 | - 'Form_Section', |
|
| 66 | - 'Ticket', |
|
| 67 | - 'Venue', |
|
| 68 | - ] |
|
| 69 | - ); |
|
| 60 | + $related_entity_types = apply_filters( |
|
| 61 | + 'FHEE__EEM_Form_Section__related_entity_types', |
|
| 62 | + [ |
|
| 63 | + 'Datetime', |
|
| 64 | + 'Event', |
|
| 65 | + 'Form_Section', |
|
| 66 | + 'Ticket', |
|
| 67 | + 'Venue', |
|
| 68 | + ] |
|
| 69 | + ); |
|
| 70 | 70 | |
| 71 | - $this->singular_item = esc_html__('Form Section', 'event_espresso'); |
|
| 72 | - $this->plural_item = esc_html__('Form Sections', 'event_espresso'); |
|
| 71 | + $this->singular_item = esc_html__('Form Section', 'event_espresso'); |
|
| 72 | + $this->plural_item = esc_html__('Form Sections', 'event_espresso'); |
|
| 73 | 73 | |
| 74 | - $this->_tables = [ |
|
| 75 | - 'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_ID'), |
|
| 76 | - ]; |
|
| 77 | - $this->_fields = [ |
|
| 78 | - 'Form_Section' => [ |
|
| 79 | - 'FSC_ID' => new EE_Integer_Field( |
|
| 80 | - 'FSC_ID', |
|
| 81 | - esc_html__('Form Section ID (autoincrement db id)', 'event_espresso'), |
|
| 82 | - false |
|
| 83 | - ), |
|
| 84 | - 'FSC_UUID' => new EE_Primary_Key_String_Field( |
|
| 85 | - 'FSC_UUID', |
|
| 86 | - esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso') |
|
| 87 | - ), |
|
| 88 | - 'FSC_appliesTo' => new EE_Enum_Text_Field( |
|
| 89 | - 'FSC_appliesTo', |
|
| 90 | - esc_html__( |
|
| 91 | - 'Form user types that this form section should be presented to. Values correspond to the EEM_Form_Section::APPLIES_TO_* constants.', |
|
| 92 | - 'event_espresso' |
|
| 93 | - ), |
|
| 94 | - false, |
|
| 95 | - EEM_Form_Section::APPLIES_TO_ALL, |
|
| 96 | - $this->valid_applies_to_options |
|
| 97 | - ), |
|
| 98 | - // 'FSC_attributes' => new EE_Serialized_Text_Field( |
|
| 99 | - // 'FSC_attributes', |
|
| 100 | - // esc_html__( |
|
| 101 | - // 'Array of HTML attributes that apply to this form section.', |
|
| 102 | - // 'event_espresso' |
|
| 103 | - // ), |
|
| 104 | - // true, |
|
| 105 | - // [] |
|
| 106 | - // ), |
|
| 107 | - 'FSC_belongsTo' => new EE_Foreign_Key_String_Field( |
|
| 108 | - 'FSC_belongsTo', |
|
| 109 | - esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso'), |
|
| 110 | - true, |
|
| 111 | - null, |
|
| 112 | - $related_entity_types |
|
| 113 | - ), |
|
| 114 | - 'FSC_htmlClass' => new EE_Plain_Text_Field( |
|
| 115 | - 'FSC_htmlClass', |
|
| 116 | - esc_html__('HTML classes to be applied to this form section\'s container.', 'event_espresso'), |
|
| 117 | - true, |
|
| 118 | - null |
|
| 119 | - ), |
|
| 120 | - 'FSC_order' => new EE_Integer_Field( |
|
| 121 | - 'FSC_order', |
|
| 122 | - esc_html__('Order in which form section appears in a form.', 'event_espresso'), |
|
| 123 | - false, |
|
| 124 | - 0 |
|
| 125 | - ), |
|
| 126 | - 'FSC_relation' => new EE_Any_Foreign_Model_Name_Field( |
|
| 127 | - 'FSC_relation', |
|
| 128 | - esc_html__('Related model type.', 'event_espresso'), |
|
| 129 | - true, |
|
| 130 | - null, |
|
| 131 | - $related_entity_types |
|
| 132 | - ), |
|
| 133 | - 'FSC_status' => new EE_Enum_Text_Field( |
|
| 134 | - 'FSC_status', |
|
| 135 | - esc_html__( |
|
| 136 | - 'Whether form section is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Section::STATUS_TO_* constants.', |
|
| 137 | - 'event_espresso' |
|
| 138 | - ), |
|
| 139 | - false, |
|
| 140 | - Element::STATUS_ACTIVE, |
|
| 141 | - $element->validStatusOptions() |
|
| 142 | - ), |
|
| 143 | - 'FSC_wpUser' => new EE_WP_User_Field( |
|
| 144 | - 'FSC_wpUser', |
|
| 145 | - esc_html__('ID of the WP User that created this form section.', 'event_espresso'), |
|
| 146 | - false |
|
| 147 | - ), |
|
| 148 | - ], |
|
| 149 | - ]; |
|
| 150 | - $this->_model_relations = []; |
|
| 151 | - foreach ($related_entity_types as $model) { |
|
| 152 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 153 | - } |
|
| 154 | - // this model is generally available for reading |
|
| 155 | - $restrictions = []; |
|
| 156 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 157 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 158 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 159 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 160 | - $this->_cap_restriction_generators = $restrictions; |
|
| 161 | - parent::__construct($element, $timezone); |
|
| 162 | - $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
| 163 | - } |
|
| 74 | + $this->_tables = [ |
|
| 75 | + 'Form_Section' => new EE_Primary_Table('esp_form_section', 'FSC_ID'), |
|
| 76 | + ]; |
|
| 77 | + $this->_fields = [ |
|
| 78 | + 'Form_Section' => [ |
|
| 79 | + 'FSC_ID' => new EE_Integer_Field( |
|
| 80 | + 'FSC_ID', |
|
| 81 | + esc_html__('Form Section ID (autoincrement db id)', 'event_espresso'), |
|
| 82 | + false |
|
| 83 | + ), |
|
| 84 | + 'FSC_UUID' => new EE_Primary_Key_String_Field( |
|
| 85 | + 'FSC_UUID', |
|
| 86 | + esc_html__('Form Section UUID (universally unique identifier)', 'event_espresso') |
|
| 87 | + ), |
|
| 88 | + 'FSC_appliesTo' => new EE_Enum_Text_Field( |
|
| 89 | + 'FSC_appliesTo', |
|
| 90 | + esc_html__( |
|
| 91 | + 'Form user types that this form section should be presented to. Values correspond to the EEM_Form_Section::APPLIES_TO_* constants.', |
|
| 92 | + 'event_espresso' |
|
| 93 | + ), |
|
| 94 | + false, |
|
| 95 | + EEM_Form_Section::APPLIES_TO_ALL, |
|
| 96 | + $this->valid_applies_to_options |
|
| 97 | + ), |
|
| 98 | + // 'FSC_attributes' => new EE_Serialized_Text_Field( |
|
| 99 | + // 'FSC_attributes', |
|
| 100 | + // esc_html__( |
|
| 101 | + // 'Array of HTML attributes that apply to this form section.', |
|
| 102 | + // 'event_espresso' |
|
| 103 | + // ), |
|
| 104 | + // true, |
|
| 105 | + // [] |
|
| 106 | + // ), |
|
| 107 | + 'FSC_belongsTo' => new EE_Foreign_Key_String_Field( |
|
| 108 | + 'FSC_belongsTo', |
|
| 109 | + esc_html__('UUID or ID of related entity this form section belongs to.', 'event_espresso'), |
|
| 110 | + true, |
|
| 111 | + null, |
|
| 112 | + $related_entity_types |
|
| 113 | + ), |
|
| 114 | + 'FSC_htmlClass' => new EE_Plain_Text_Field( |
|
| 115 | + 'FSC_htmlClass', |
|
| 116 | + esc_html__('HTML classes to be applied to this form section\'s container.', 'event_espresso'), |
|
| 117 | + true, |
|
| 118 | + null |
|
| 119 | + ), |
|
| 120 | + 'FSC_order' => new EE_Integer_Field( |
|
| 121 | + 'FSC_order', |
|
| 122 | + esc_html__('Order in which form section appears in a form.', 'event_espresso'), |
|
| 123 | + false, |
|
| 124 | + 0 |
|
| 125 | + ), |
|
| 126 | + 'FSC_relation' => new EE_Any_Foreign_Model_Name_Field( |
|
| 127 | + 'FSC_relation', |
|
| 128 | + esc_html__('Related model type.', 'event_espresso'), |
|
| 129 | + true, |
|
| 130 | + null, |
|
| 131 | + $related_entity_types |
|
| 132 | + ), |
|
| 133 | + 'FSC_status' => new EE_Enum_Text_Field( |
|
| 134 | + 'FSC_status', |
|
| 135 | + esc_html__( |
|
| 136 | + 'Whether form section is active, archived, trashed, or used as a default on new forms. Values correspond to the EEM_Form_Section::STATUS_TO_* constants.', |
|
| 137 | + 'event_espresso' |
|
| 138 | + ), |
|
| 139 | + false, |
|
| 140 | + Element::STATUS_ACTIVE, |
|
| 141 | + $element->validStatusOptions() |
|
| 142 | + ), |
|
| 143 | + 'FSC_wpUser' => new EE_WP_User_Field( |
|
| 144 | + 'FSC_wpUser', |
|
| 145 | + esc_html__('ID of the WP User that created this form section.', 'event_espresso'), |
|
| 146 | + false |
|
| 147 | + ), |
|
| 148 | + ], |
|
| 149 | + ]; |
|
| 150 | + $this->_model_relations = []; |
|
| 151 | + foreach ($related_entity_types as $model) { |
|
| 152 | + $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 153 | + } |
|
| 154 | + // this model is generally available for reading |
|
| 155 | + $restrictions = []; |
|
| 156 | + $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 157 | + $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 158 | + $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 159 | + $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 160 | + $this->_cap_restriction_generators = $restrictions; |
|
| 161 | + parent::__construct($element, $timezone); |
|
| 162 | + $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |
|
| 163 | + } |
|
| 164 | 164 | |
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * @param bool $constants_only |
|
| 168 | - * @return array |
|
| 169 | - */ |
|
| 170 | - public function validAppliesToOptions(bool $constants_only = false): array |
|
| 171 | - { |
|
| 172 | - return $constants_only |
|
| 173 | - ? array_keys($this->valid_applies_to_options) |
|
| 174 | - : $this->valid_applies_to_options; |
|
| 175 | - } |
|
| 166 | + /** |
|
| 167 | + * @param bool $constants_only |
|
| 168 | + * @return array |
|
| 169 | + */ |
|
| 170 | + public function validAppliesToOptions(bool $constants_only = false): array |
|
| 171 | + { |
|
| 172 | + return $constants_only |
|
| 173 | + ? array_keys($this->valid_applies_to_options) |
|
| 174 | + : $this->valid_applies_to_options; |
|
| 175 | + } |
|
| 176 | 176 | |
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * returns an array of Form Sections for the specified parent Form Section |
|
| 180 | - * |
|
| 181 | - * @param string $FSC_UUID |
|
| 182 | - * @return EE_Form_Section[] |
|
| 183 | - * @throws EE_Error |
|
| 184 | - */ |
|
| 185 | - public function getChildFormSections(string $FSC_UUID): array |
|
| 186 | - { |
|
| 187 | - return $this->getFormSectionsFor('FormSection.FSC_UUID', $FSC_UUID); |
|
| 188 | - } |
|
| 178 | + /** |
|
| 179 | + * returns an array of Form Sections for the specified parent Form Section |
|
| 180 | + * |
|
| 181 | + * @param string $FSC_UUID |
|
| 182 | + * @return EE_Form_Section[] |
|
| 183 | + * @throws EE_Error |
|
| 184 | + */ |
|
| 185 | + public function getChildFormSections(string $FSC_UUID): array |
|
| 186 | + { |
|
| 187 | + return $this->getFormSectionsFor('FormSection.FSC_UUID', $FSC_UUID); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | 190 | |
| 191 | - /** |
|
| 192 | - * returns an array of Form Sections for the specified Event |
|
| 193 | - * |
|
| 194 | - * @param string $EVT_ID |
|
| 195 | - * @return EE_Form_Section[] |
|
| 196 | - * @throws EE_Error |
|
| 197 | - */ |
|
| 198 | - public function getFormSectionsForEvent(string $EVT_ID): array |
|
| 199 | - { |
|
| 200 | - return $this->getFormSectionsFor('Event.EVT_ID', $EVT_ID); |
|
| 201 | - } |
|
| 191 | + /** |
|
| 192 | + * returns an array of Form Sections for the specified Event |
|
| 193 | + * |
|
| 194 | + * @param string $EVT_ID |
|
| 195 | + * @return EE_Form_Section[] |
|
| 196 | + * @throws EE_Error |
|
| 197 | + */ |
|
| 198 | + public function getFormSectionsForEvent(string $EVT_ID): array |
|
| 199 | + { |
|
| 200 | + return $this->getFormSectionsFor('Event.EVT_ID', $EVT_ID); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | 203 | |
| 204 | - /** |
|
| 205 | - * returns an array of Form Sections for the specified Datetime |
|
| 206 | - * |
|
| 207 | - * @param string $DTT_ID |
|
| 208 | - * @return EE_Form_Section[] |
|
| 209 | - * @throws EE_Error |
|
| 210 | - */ |
|
| 211 | - public function getFormSectionsForDatetime(string $DTT_ID): array |
|
| 212 | - { |
|
| 213 | - return $this->getFormSectionsFor('Datetime.DTT_ID', $DTT_ID); |
|
| 214 | - } |
|
| 204 | + /** |
|
| 205 | + * returns an array of Form Sections for the specified Datetime |
|
| 206 | + * |
|
| 207 | + * @param string $DTT_ID |
|
| 208 | + * @return EE_Form_Section[] |
|
| 209 | + * @throws EE_Error |
|
| 210 | + */ |
|
| 211 | + public function getFormSectionsForDatetime(string $DTT_ID): array |
|
| 212 | + { |
|
| 213 | + return $this->getFormSectionsFor('Datetime.DTT_ID', $DTT_ID); |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | |
| 217 | - /** |
|
| 218 | - * returns an array of Form Sections for the specified Ticket |
|
| 219 | - * |
|
| 220 | - * @param string $TKT_ID |
|
| 221 | - * @return EE_Form_Section[] |
|
| 222 | - * @throws EE_Error |
|
| 223 | - */ |
|
| 224 | - public function getFormSectionsForTicket(string $TKT_ID): array |
|
| 225 | - { |
|
| 226 | - return $this->getFormSectionsFor('Ticket.TKT_ID', $TKT_ID); |
|
| 227 | - } |
|
| 217 | + /** |
|
| 218 | + * returns an array of Form Sections for the specified Ticket |
|
| 219 | + * |
|
| 220 | + * @param string $TKT_ID |
|
| 221 | + * @return EE_Form_Section[] |
|
| 222 | + * @throws EE_Error |
|
| 223 | + */ |
|
| 224 | + public function getFormSectionsForTicket(string $TKT_ID): array |
|
| 225 | + { |
|
| 226 | + return $this->getFormSectionsFor('Ticket.TKT_ID', $TKT_ID); |
|
| 227 | + } |
|
| 228 | 228 | |
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * returns an array of Form Sections for the specified Venue |
|
| 232 | - * |
|
| 233 | - * @param string $VNU_ID |
|
| 234 | - * @return EE_Form_Section[] |
|
| 235 | - * @throws EE_Error |
|
| 236 | - */ |
|
| 237 | - public function getFormSectionsForVenue(string $VNU_ID): array |
|
| 238 | - { |
|
| 239 | - return $this->getFormSectionsFor('Venue.VNU_ID', $VNU_ID); |
|
| 240 | - } |
|
| 230 | + /** |
|
| 231 | + * returns an array of Form Sections for the specified Venue |
|
| 232 | + * |
|
| 233 | + * @param string $VNU_ID |
|
| 234 | + * @return EE_Form_Section[] |
|
| 235 | + * @throws EE_Error |
|
| 236 | + */ |
|
| 237 | + public function getFormSectionsForVenue(string $VNU_ID): array |
|
| 238 | + { |
|
| 239 | + return $this->getFormSectionsFor('Venue.VNU_ID', $VNU_ID); |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | 242 | |
| 243 | - /** |
|
| 244 | - * @return EE_Form_Section[] |
|
| 245 | - * @throws EE_Error |
|
| 246 | - */ |
|
| 247 | - private function getFormSectionsFor(string $relation, string $related_UUID): array |
|
| 248 | - { |
|
| 249 | - $where_params = [$relation => $related_UUID]; |
|
| 250 | - $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
| 251 | - $query_params = $this->addOrderByQueryParams($query_params); |
|
| 252 | - return $this->get_all($query_params); |
|
| 253 | - } |
|
| 243 | + /** |
|
| 244 | + * @return EE_Form_Section[] |
|
| 245 | + * @throws EE_Error |
|
| 246 | + */ |
|
| 247 | + private function getFormSectionsFor(string $relation, string $related_UUID): array |
|
| 248 | + { |
|
| 249 | + $where_params = [$relation => $related_UUID]; |
|
| 250 | + $query_params = $this->addDefaultWhereConditions([$where_params]); |
|
| 251 | + $query_params = $this->addOrderByQueryParams($query_params); |
|
| 252 | + return $this->get_all($query_params); |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | 255 | |
| 256 | - /** |
|
| 257 | - * @param array $query_params |
|
| 258 | - * @return array |
|
| 259 | - */ |
|
| 260 | - private function addDefaultWhereConditions(array $query_params): array |
|
| 261 | - { |
|
| 262 | - // might need to add a way to identify GQL requests for admin domains |
|
| 263 | - $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
| 264 | - $query_params['default_where_conditions'] = $admin_request |
|
| 265 | - ? EEM_Base::default_where_conditions_none |
|
| 266 | - : EEM_Base::default_where_conditions_all; |
|
| 267 | - return $query_params; |
|
| 268 | - } |
|
| 256 | + /** |
|
| 257 | + * @param array $query_params |
|
| 258 | + * @return array |
|
| 259 | + */ |
|
| 260 | + private function addDefaultWhereConditions(array $query_params): array |
|
| 261 | + { |
|
| 262 | + // might need to add a way to identify GQL requests for admin domains |
|
| 263 | + $admin_request = $this->request->isAdmin() || $this->request->isAdminAjax(); |
|
| 264 | + $query_params['default_where_conditions'] = $admin_request |
|
| 265 | + ? EEM_Base::default_where_conditions_none |
|
| 266 | + : EEM_Base::default_where_conditions_all; |
|
| 267 | + return $query_params; |
|
| 268 | + } |
|
| 269 | 269 | |
| 270 | 270 | |
| 271 | - /** |
|
| 272 | - * form sections should always be sorted in ascending order via the FSC_order field |
|
| 273 | - * |
|
| 274 | - * @param array $query_params |
|
| 275 | - * @return array |
|
| 276 | - */ |
|
| 277 | - private function addOrderByQueryParams(array $query_params): array |
|
| 278 | - { |
|
| 279 | - $query_params['order_by'] = ['FSC_order' => 'ASC']; |
|
| 280 | - return $query_params; |
|
| 281 | - } |
|
| 271 | + /** |
|
| 272 | + * form sections should always be sorted in ascending order via the FSC_order field |
|
| 273 | + * |
|
| 274 | + * @param array $query_params |
|
| 275 | + * @return array |
|
| 276 | + */ |
|
| 277 | + private function addOrderByQueryParams(array $query_params): array |
|
| 278 | + { |
|
| 279 | + $query_params['order_by'] = ['FSC_order' => 'ASC']; |
|
| 280 | + return $query_params; |
|
| 281 | + } |
|
| 282 | 282 | } |
@@ -149,14 +149,14 @@ |
||
| 149 | 149 | ]; |
| 150 | 150 | $this->_model_relations = []; |
| 151 | 151 | foreach ($related_entity_types as $model) { |
| 152 | - $this->_model_relations[ $model ] = new EE_Belongs_To_Any_Relation(); |
|
| 152 | + $this->_model_relations[$model] = new EE_Belongs_To_Any_Relation(); |
|
| 153 | 153 | } |
| 154 | 154 | // this model is generally available for reading |
| 155 | 155 | $restrictions = []; |
| 156 | - $restrictions[ EEM_Base::caps_read ] = new EE_Restriction_Generator_Public(); |
|
| 157 | - $restrictions[ EEM_Base::caps_read_admin ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 158 | - $restrictions[ EEM_Base::caps_edit ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 159 | - $restrictions[ EEM_Base::caps_delete ] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 156 | + $restrictions[EEM_Base::caps_read] = new EE_Restriction_Generator_Public(); |
|
| 157 | + $restrictions[EEM_Base::caps_read_admin] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 158 | + $restrictions[EEM_Base::caps_edit] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 159 | + $restrictions[EEM_Base::caps_delete] = new EE_Restriction_Generator_Reg_Form('FSC_applies_to'); |
|
| 160 | 160 | $this->_cap_restriction_generators = $restrictions; |
| 161 | 161 | parent::__construct($element, $timezone); |
| 162 | 162 | $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\RequestInterface'); |