@@ -21,96 +21,96 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class WordpressPluginsPageAssetManager extends ReactAssetManager |
| 23 | 23 | { |
| 24 | - const JS_HANDLE_WP_PLUGINS_PAGE = 'eventespresso-main'; |
|
| 24 | + const JS_HANDLE_WP_PLUGINS_PAGE = 'eventespresso-main'; |
|
| 25 | 25 | |
| 26 | - /** |
|
| 27 | - * @var ExitModal $exit_modal |
|
| 28 | - */ |
|
| 29 | - private $exit_modal; |
|
| 26 | + /** |
|
| 27 | + * @var ExitModal $exit_modal |
|
| 28 | + */ |
|
| 29 | + private $exit_modal; |
|
| 30 | 30 | |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * WordpressPluginsPageAssetManager constructor. |
|
| 34 | - * |
|
| 35 | - * @param AssetCollection $assets |
|
| 36 | - * @param DomainInterface $domain |
|
| 37 | - * @param Registry $registry |
|
| 38 | - * @param ExitModal $exit_modal |
|
| 39 | - */ |
|
| 40 | - public function __construct( |
|
| 41 | - AssetCollection $assets, |
|
| 42 | - DomainInterface $domain, |
|
| 43 | - Registry $registry, |
|
| 44 | - ExitModal $exit_modal |
|
| 45 | - ) { |
|
| 46 | - $this->exit_modal = $exit_modal; |
|
| 47 | - parent::__construct($domain, $assets, $registry); |
|
| 48 | - } |
|
| 32 | + /** |
|
| 33 | + * WordpressPluginsPageAssetManager constructor. |
|
| 34 | + * |
|
| 35 | + * @param AssetCollection $assets |
|
| 36 | + * @param DomainInterface $domain |
|
| 37 | + * @param Registry $registry |
|
| 38 | + * @param ExitModal $exit_modal |
|
| 39 | + */ |
|
| 40 | + public function __construct( |
|
| 41 | + AssetCollection $assets, |
|
| 42 | + DomainInterface $domain, |
|
| 43 | + Registry $registry, |
|
| 44 | + ExitModal $exit_modal |
|
| 45 | + ) { |
|
| 46 | + $this->exit_modal = $exit_modal; |
|
| 47 | + parent::__construct($domain, $assets, $registry); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * @inheritDoc |
|
| 53 | - */ |
|
| 54 | - public function addAssets() |
|
| 55 | - { |
|
| 56 | - parent::addAssets(); |
|
| 57 | - $this->registerJavascript(); |
|
| 58 | - $this->registerStyleSheets(); |
|
| 59 | - add_action('admin_enqueue_scripts', [$this, 'enqueueBrowserAssets'], 10); |
|
| 60 | - } |
|
| 51 | + /** |
|
| 52 | + * @inheritDoc |
|
| 53 | + */ |
|
| 54 | + public function addAssets() |
|
| 55 | + { |
|
| 56 | + parent::addAssets(); |
|
| 57 | + $this->registerJavascript(); |
|
| 58 | + $this->registerStyleSheets(); |
|
| 59 | + add_action('admin_enqueue_scripts', [$this, 'enqueueBrowserAssets'], 10); |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * Register javascript assets |
|
| 65 | - * |
|
| 66 | - * @throws InvalidDataTypeException |
|
| 67 | - * @throws InvalidEntityException |
|
| 68 | - * @throws DuplicateCollectionIdentifierException |
|
| 69 | - * @throws DomainException |
|
| 70 | - */ |
|
| 71 | - private function registerJavascript() |
|
| 72 | - { |
|
| 73 | - $this->addJs( |
|
| 74 | - WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 75 | - [ |
|
| 76 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 77 | - ReactAssetManager::JS_HANDLE_REACT, |
|
| 78 | - ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
| 79 | - 'wp-components', |
|
| 80 | - 'wp-i18n', |
|
| 81 | - 'wp-url' |
|
| 82 | - ] |
|
| 83 | - ) |
|
| 84 | - ->setRequiresTranslation() |
|
| 85 | - ->setInlineDataCallback( |
|
| 86 | - function () { |
|
| 87 | - wp_localize_script( |
|
| 88 | - WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 89 | - 'eeExitSurveyInfo', |
|
| 90 | - $this->exit_modal->getExitSurveyInfo() |
|
| 91 | - ); |
|
| 92 | - wp_add_inline_script( |
|
| 93 | - WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 94 | - " |
|
| 63 | + /** |
|
| 64 | + * Register javascript assets |
|
| 65 | + * |
|
| 66 | + * @throws InvalidDataTypeException |
|
| 67 | + * @throws InvalidEntityException |
|
| 68 | + * @throws DuplicateCollectionIdentifierException |
|
| 69 | + * @throws DomainException |
|
| 70 | + */ |
|
| 71 | + private function registerJavascript() |
|
| 72 | + { |
|
| 73 | + $this->addJs( |
|
| 74 | + WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 75 | + [ |
|
| 76 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 77 | + ReactAssetManager::JS_HANDLE_REACT, |
|
| 78 | + ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
| 79 | + 'wp-components', |
|
| 80 | + 'wp-i18n', |
|
| 81 | + 'wp-url' |
|
| 82 | + ] |
|
| 83 | + ) |
|
| 84 | + ->setRequiresTranslation() |
|
| 85 | + ->setInlineDataCallback( |
|
| 86 | + function () { |
|
| 87 | + wp_localize_script( |
|
| 88 | + WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 89 | + 'eeExitSurveyInfo', |
|
| 90 | + $this->exit_modal->getExitSurveyInfo() |
|
| 91 | + ); |
|
| 92 | + wp_add_inline_script( |
|
| 93 | + WordpressPluginsPageAssetManager::JS_HANDLE_WP_PLUGINS_PAGE, |
|
| 94 | + " |
|
| 95 | 95 | var eeDomain='wpPluginsPage'; |
| 96 | 96 | ", |
| 97 | - 'before' |
|
| 98 | - ); |
|
| 99 | - } |
|
| 100 | - ); |
|
| 101 | - } |
|
| 97 | + 'before' |
|
| 98 | + ); |
|
| 99 | + } |
|
| 100 | + ); |
|
| 101 | + } |
|
| 102 | 102 | |
| 103 | 103 | |
| 104 | - /** |
|
| 105 | - * Register CSS assets. |
|
| 106 | - * |
|
| 107 | - * @throws DuplicateCollectionIdentifierException |
|
| 108 | - * @throws InvalidDataTypeException |
|
| 109 | - * @throws InvalidEntityException |
|
| 110 | - * @throws DomainException |
|
| 111 | - */ |
|
| 112 | - private function registerStyleSheets() |
|
| 113 | - { |
|
| 114 | - wp_enqueue_style('wp-components'); |
|
| 115 | - } |
|
| 104 | + /** |
|
| 105 | + * Register CSS assets. |
|
| 106 | + * |
|
| 107 | + * @throws DuplicateCollectionIdentifierException |
|
| 108 | + * @throws InvalidDataTypeException |
|
| 109 | + * @throws InvalidEntityException |
|
| 110 | + * @throws DomainException |
|
| 111 | + */ |
|
| 112 | + private function registerStyleSheets() |
|
| 113 | + { |
|
| 114 | + wp_enqueue_style('wp-components'); |
|
| 115 | + } |
|
| 116 | 116 | } |
@@ -17,39 +17,39 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class EspressoEditorAssetManager extends ReactAssetManager |
| 19 | 19 | { |
| 20 | - const JS_HANDLE_EDITOR = 'eventespresso-main'; |
|
| 20 | + const JS_HANDLE_EDITOR = 'eventespresso-main'; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * @throws InvalidDataTypeException |
|
| 24 | - * @throws InvalidEntityException |
|
| 25 | - * @throws DuplicateCollectionIdentifierException |
|
| 26 | - * @throws DomainException |
|
| 27 | - */ |
|
| 28 | - public function addAssets() |
|
| 29 | - { |
|
| 30 | - parent::addAssets(); |
|
| 31 | - $this->registerJavascript(); |
|
| 32 | - } |
|
| 22 | + /** |
|
| 23 | + * @throws InvalidDataTypeException |
|
| 24 | + * @throws InvalidEntityException |
|
| 25 | + * @throws DuplicateCollectionIdentifierException |
|
| 26 | + * @throws DomainException |
|
| 27 | + */ |
|
| 28 | + public function addAssets() |
|
| 29 | + { |
|
| 30 | + parent::addAssets(); |
|
| 31 | + $this->registerJavascript(); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Register javascript assets |
|
| 37 | - * |
|
| 38 | - * @throws InvalidDataTypeException |
|
| 39 | - * @throws InvalidEntityException |
|
| 40 | - * @throws DuplicateCollectionIdentifierException |
|
| 41 | - * @throws DomainException |
|
| 42 | - */ |
|
| 43 | - private function registerJavascript() |
|
| 44 | - { |
|
| 45 | - $this->addJs( |
|
| 46 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
| 47 | - [ |
|
| 48 | - ReactAssetManager::JS_HANDLE_REACT, |
|
| 49 | - ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
| 50 | - CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 51 | - 'wp-i18n', |
|
| 52 | - ] |
|
| 53 | - )->setRequiresTranslation(); |
|
| 54 | - } |
|
| 35 | + /** |
|
| 36 | + * Register javascript assets |
|
| 37 | + * |
|
| 38 | + * @throws InvalidDataTypeException |
|
| 39 | + * @throws InvalidEntityException |
|
| 40 | + * @throws DuplicateCollectionIdentifierException |
|
| 41 | + * @throws DomainException |
|
| 42 | + */ |
|
| 43 | + private function registerJavascript() |
|
| 44 | + { |
|
| 45 | + $this->addJs( |
|
| 46 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
| 47 | + [ |
|
| 48 | + ReactAssetManager::JS_HANDLE_REACT, |
|
| 49 | + ReactAssetManager::JS_HANDLE_REACT_DOM, |
|
| 50 | + CoreAssetManager::JS_HANDLE_JS_CORE, |
|
| 51 | + 'wp-i18n', |
|
| 52 | + ] |
|
| 53 | + )->setRequiresTranslation(); |
|
| 54 | + } |
|
| 55 | 55 | } |
@@ -30,131 +30,131 @@ |
||
| 30 | 30 | class EventEditor |
| 31 | 31 | { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @var EE_Admin_Config |
|
| 35 | - */ |
|
| 36 | - protected $admin_config; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var CurrentUser $current_user |
|
| 40 | - */ |
|
| 41 | - protected $current_user; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var EE_Event |
|
| 45 | - */ |
|
| 46 | - protected $event; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var EventEditorGraphQLData |
|
| 50 | - */ |
|
| 51 | - protected $event_editor_gql_data; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * @var GeneralSettings $general_settings |
|
| 55 | - */ |
|
| 56 | - protected $general_settings; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @var JedLocaleData $jed_locale |
|
| 60 | - */ |
|
| 61 | - private $jed_locale; |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * EventEditor constructor. |
|
| 66 | - * |
|
| 67 | - * @param EE_Admin_Config $admin_config |
|
| 68 | - * @param CurrentUser $current_user |
|
| 69 | - * @param EE_Event $event |
|
| 70 | - * @param EventEditorGraphQLData $event_editor_gql_data |
|
| 71 | - * @param GeneralSettings $general_settings |
|
| 72 | - * @param JedLocaleData $jed_locale |
|
| 73 | - */ |
|
| 74 | - public function __construct( |
|
| 75 | - EE_Admin_Config $admin_config, |
|
| 76 | - CurrentUser $current_user, |
|
| 77 | - EE_Event $event, |
|
| 78 | - EventEditorGraphQLData $event_editor_gql_data, |
|
| 79 | - GeneralSettings $general_settings, |
|
| 80 | - JedLocaleData $jed_locale |
|
| 81 | - ) { |
|
| 82 | - $this->admin_config = $admin_config; |
|
| 83 | - $this->current_user = $current_user; |
|
| 84 | - $this->event = $event; |
|
| 85 | - $this->event_editor_gql_data = $event_editor_gql_data; |
|
| 86 | - $this->general_settings = $general_settings; |
|
| 87 | - $this->jed_locale = $jed_locale; |
|
| 88 | - add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @throws EE_Error |
|
| 94 | - * @throws InvalidArgumentException |
|
| 95 | - * @throws InvalidDataTypeException |
|
| 96 | - * @throws InvalidInterfaceException |
|
| 97 | - * @throws ModelConfigurationException |
|
| 98 | - * @throws ReflectionException |
|
| 99 | - * @throws UnexpectedEntityException |
|
| 100 | - * @throws DomainException |
|
| 101 | - * @since $VID:$ |
|
| 102 | - */ |
|
| 103 | - public function loadScriptsStyles() |
|
| 104 | - { |
|
| 105 | - if ($this->admin_config->useAdvancedEditor()) { |
|
| 106 | - $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
| 107 | - if (! $eventId) { |
|
| 108 | - global $post; |
|
| 109 | - $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
| 110 | - // if there's no event ID but there IS a WP Post... then use the Post ID |
|
| 111 | - $use_post_id = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'; |
|
| 112 | - $eventId = $use_post_id ? $post->ID : $eventId; |
|
| 113 | - } |
|
| 114 | - if ($eventId) { |
|
| 115 | - $data = $this->getEditorData($eventId); |
|
| 116 | - $data = wp_json_encode($data); |
|
| 117 | - add_action( |
|
| 118 | - 'admin_footer', |
|
| 119 | - static function () use ($data) { |
|
| 120 | - wp_add_inline_script( |
|
| 121 | - EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
| 122 | - " |
|
| 33 | + /** |
|
| 34 | + * @var EE_Admin_Config |
|
| 35 | + */ |
|
| 36 | + protected $admin_config; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var CurrentUser $current_user |
|
| 40 | + */ |
|
| 41 | + protected $current_user; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var EE_Event |
|
| 45 | + */ |
|
| 46 | + protected $event; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var EventEditorGraphQLData |
|
| 50 | + */ |
|
| 51 | + protected $event_editor_gql_data; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * @var GeneralSettings $general_settings |
|
| 55 | + */ |
|
| 56 | + protected $general_settings; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @var JedLocaleData $jed_locale |
|
| 60 | + */ |
|
| 61 | + private $jed_locale; |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * EventEditor constructor. |
|
| 66 | + * |
|
| 67 | + * @param EE_Admin_Config $admin_config |
|
| 68 | + * @param CurrentUser $current_user |
|
| 69 | + * @param EE_Event $event |
|
| 70 | + * @param EventEditorGraphQLData $event_editor_gql_data |
|
| 71 | + * @param GeneralSettings $general_settings |
|
| 72 | + * @param JedLocaleData $jed_locale |
|
| 73 | + */ |
|
| 74 | + public function __construct( |
|
| 75 | + EE_Admin_Config $admin_config, |
|
| 76 | + CurrentUser $current_user, |
|
| 77 | + EE_Event $event, |
|
| 78 | + EventEditorGraphQLData $event_editor_gql_data, |
|
| 79 | + GeneralSettings $general_settings, |
|
| 80 | + JedLocaleData $jed_locale |
|
| 81 | + ) { |
|
| 82 | + $this->admin_config = $admin_config; |
|
| 83 | + $this->current_user = $current_user; |
|
| 84 | + $this->event = $event; |
|
| 85 | + $this->event_editor_gql_data = $event_editor_gql_data; |
|
| 86 | + $this->general_settings = $general_settings; |
|
| 87 | + $this->jed_locale = $jed_locale; |
|
| 88 | + add_action('admin_enqueue_scripts', [$this, 'loadScriptsStyles']); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @throws EE_Error |
|
| 94 | + * @throws InvalidArgumentException |
|
| 95 | + * @throws InvalidDataTypeException |
|
| 96 | + * @throws InvalidInterfaceException |
|
| 97 | + * @throws ModelConfigurationException |
|
| 98 | + * @throws ReflectionException |
|
| 99 | + * @throws UnexpectedEntityException |
|
| 100 | + * @throws DomainException |
|
| 101 | + * @since $VID:$ |
|
| 102 | + */ |
|
| 103 | + public function loadScriptsStyles() |
|
| 104 | + { |
|
| 105 | + if ($this->admin_config->useAdvancedEditor()) { |
|
| 106 | + $eventId = $this->event instanceof EE_Event ? $this->event->ID() : 0; |
|
| 107 | + if (! $eventId) { |
|
| 108 | + global $post; |
|
| 109 | + $eventId = isset($_REQUEST['post']) ? absint($_REQUEST['post']) : 0; |
|
| 110 | + // if there's no event ID but there IS a WP Post... then use the Post ID |
|
| 111 | + $use_post_id = $eventId === 0 && $post instanceof WP_Post && $post->post_type === 'espresso_events'; |
|
| 112 | + $eventId = $use_post_id ? $post->ID : $eventId; |
|
| 113 | + } |
|
| 114 | + if ($eventId) { |
|
| 115 | + $data = $this->getEditorData($eventId); |
|
| 116 | + $data = wp_json_encode($data); |
|
| 117 | + add_action( |
|
| 118 | + 'admin_footer', |
|
| 119 | + static function () use ($data) { |
|
| 120 | + wp_add_inline_script( |
|
| 121 | + EspressoEditorAssetManager::JS_HANDLE_EDITOR, |
|
| 122 | + " |
|
| 123 | 123 | var eeEditorData={$data}; |
| 124 | 124 | var eeDomain='eventEditor'; |
| 125 | 125 | ", |
| 126 | - 'before' |
|
| 127 | - ); |
|
| 128 | - } |
|
| 129 | - ); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - } |
|
| 126 | + 'before' |
|
| 127 | + ); |
|
| 128 | + } |
|
| 129 | + ); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | 133 | |
| 134 | 134 | |
| 135 | - /** |
|
| 136 | - * @param int $eventId |
|
| 137 | - * @return array |
|
| 138 | - * @throws EE_Error |
|
| 139 | - * @throws ReflectionException |
|
| 140 | - * @since $VID:$ |
|
| 141 | - */ |
|
| 142 | - protected function getEditorData($eventId) |
|
| 143 | - { |
|
| 144 | - $event = $this->event_editor_gql_data->getData($eventId); |
|
| 145 | - $event['dbId'] = $eventId; |
|
| 135 | + /** |
|
| 136 | + * @param int $eventId |
|
| 137 | + * @return array |
|
| 138 | + * @throws EE_Error |
|
| 139 | + * @throws ReflectionException |
|
| 140 | + * @since $VID:$ |
|
| 141 | + */ |
|
| 142 | + protected function getEditorData($eventId) |
|
| 143 | + { |
|
| 144 | + $event = $this->event_editor_gql_data->getData($eventId); |
|
| 145 | + $event['dbId'] = $eventId; |
|
| 146 | 146 | |
| 147 | - $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
| 148 | - $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
| 147 | + $graphqlEndpoint = class_exists('WPGraphQL') ? trailingslashit(site_url()) . Router::$route : ''; |
|
| 148 | + $graphqlEndpoint = esc_url($graphqlEndpoint); |
|
| 149 | 149 | |
| 150 | - $currentUser = $this->current_user->getData(); |
|
| 150 | + $currentUser = $this->current_user->getData(); |
|
| 151 | 151 | |
| 152 | - $generalSettings = $this->general_settings->getData(); |
|
| 152 | + $generalSettings = $this->general_settings->getData(); |
|
| 153 | 153 | |
| 154 | - $i18n = $this->jed_locale->getData('event_espresso'); |
|
| 154 | + $i18n = $this->jed_locale->getData('event_espresso'); |
|
| 155 | 155 | |
| 156 | - $assetsUrl = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
| 156 | + $assetsUrl = EE_PLUGIN_DIR_URL . 'assets/dist/'; |
|
| 157 | 157 | |
| 158 | - return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assetsUrl'); |
|
| 159 | - } |
|
| 158 | + return compact('event', 'graphqlEndpoint', 'currentUser', 'generalSettings', 'i18n', 'assetsUrl'); |
|
| 159 | + } |
|
| 160 | 160 | } |
@@ -19,121 +19,121 @@ |
||
| 19 | 19 | { |
| 20 | 20 | |
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * AttendeeConnection constructor. |
|
| 24 | - * |
|
| 25 | - * @param EEM_Attendee $model |
|
| 26 | - */ |
|
| 27 | - public function __construct(EEM_Attendee $model) |
|
| 28 | - { |
|
| 29 | - $this->model = $model; |
|
| 30 | - } |
|
| 22 | + /** |
|
| 23 | + * AttendeeConnection constructor. |
|
| 24 | + * |
|
| 25 | + * @param EEM_Attendee $model |
|
| 26 | + */ |
|
| 27 | + public function __construct(EEM_Attendee $model) |
|
| 28 | + { |
|
| 29 | + $this->model = $model; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * @return array |
|
| 35 | - * @since $VID:$ |
|
| 36 | - */ |
|
| 37 | - public function config() |
|
| 38 | - { |
|
| 39 | - return [ |
|
| 40 | - 'fromType' => 'RootQuery', |
|
| 41 | - 'toType' => $this->namespace . 'Attendee', |
|
| 42 | - 'fromFieldName' => lcfirst($this->namespace) . 'Attendees', |
|
| 43 | - 'connectionTypeName' => "{$this->namespace}RootQueryAttendeesConnection", |
|
| 44 | - 'connectionArgs' => self::get_connection_args(), |
|
| 45 | - 'resolve' => [$this, 'resolveConnection'], |
|
| 46 | - ]; |
|
| 47 | - } |
|
| 33 | + /** |
|
| 34 | + * @return array |
|
| 35 | + * @since $VID:$ |
|
| 36 | + */ |
|
| 37 | + public function config() |
|
| 38 | + { |
|
| 39 | + return [ |
|
| 40 | + 'fromType' => 'RootQuery', |
|
| 41 | + 'toType' => $this->namespace . 'Attendee', |
|
| 42 | + 'fromFieldName' => lcfirst($this->namespace) . 'Attendees', |
|
| 43 | + 'connectionTypeName' => "{$this->namespace}RootQueryAttendeesConnection", |
|
| 44 | + 'connectionArgs' => self::get_connection_args(), |
|
| 45 | + 'resolve' => [$this, 'resolveConnection'], |
|
| 46 | + ]; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * @param $entity |
|
| 52 | - * @param $args |
|
| 53 | - * @param $context |
|
| 54 | - * @param $info |
|
| 55 | - * @return AttendeeConnectionResolver |
|
| 56 | - * @throws Exception |
|
| 57 | - * @since $VID:$ |
|
| 58 | - */ |
|
| 59 | - public function getConnectionResolver($entity, $args, $context, $info) |
|
| 60 | - { |
|
| 61 | - return new AttendeeConnectionResolver($entity, $args, $context, $info); |
|
| 62 | - } |
|
| 50 | + /** |
|
| 51 | + * @param $entity |
|
| 52 | + * @param $args |
|
| 53 | + * @param $context |
|
| 54 | + * @param $info |
|
| 55 | + * @return AttendeeConnectionResolver |
|
| 56 | + * @throws Exception |
|
| 57 | + * @since $VID:$ |
|
| 58 | + */ |
|
| 59 | + public function getConnectionResolver($entity, $args, $context, $info) |
|
| 60 | + { |
|
| 61 | + return new AttendeeConnectionResolver($entity, $args, $context, $info); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Given an optional array of args, this returns the args to be used in the connection |
|
| 66 | - * |
|
| 67 | - * @access public |
|
| 68 | - * @param array $args The args to modify the defaults |
|
| 69 | - * |
|
| 70 | - * @return array |
|
| 71 | - */ |
|
| 72 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 73 | - public static function get_connection_args($args = []) |
|
| 74 | - { |
|
| 75 | - return array_merge( |
|
| 76 | - [ |
|
| 77 | - 'datetime' => [ |
|
| 78 | - 'type' => 'ID', |
|
| 79 | - 'description' => esc_html__( |
|
| 80 | - 'Globally unique datetime ID to get the attendees for.', |
|
| 81 | - 'event_espresso' |
|
| 82 | - ), |
|
| 83 | - ], |
|
| 84 | - 'datetimeIn' => [ |
|
| 85 | - 'type' => ['list_of' => 'ID'], |
|
| 86 | - 'description' => esc_html__( |
|
| 87 | - 'Globally unique datetime IDs to get the attendees for.', |
|
| 88 | - 'event_espresso' |
|
| 89 | - ), |
|
| 90 | - ], |
|
| 91 | - 'event' => [ |
|
| 92 | - 'type' => 'ID', |
|
| 93 | - 'description' => esc_html__( |
|
| 94 | - 'Globally unique event ID to get the attendees for.', |
|
| 95 | - 'event_espresso' |
|
| 96 | - ), |
|
| 97 | - ], |
|
| 98 | - 'eventIn' => [ |
|
| 99 | - 'type' => ['list_of' => 'ID'], |
|
| 100 | - 'description' => esc_html__( |
|
| 101 | - 'Globally unique event IDs to get the attendees for.', |
|
| 102 | - 'event_espresso' |
|
| 103 | - ), |
|
| 104 | - ], |
|
| 105 | - 'orderby' => [ |
|
| 106 | - 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], |
|
| 107 | - 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
| 108 | - ], |
|
| 109 | - 'regTicket' => [ |
|
| 110 | - 'type' => 'ID', |
|
| 111 | - 'description' => esc_html__( |
|
| 112 | - 'Globally unique registration ticket ID to get the attendees for.', |
|
| 113 | - 'event_espresso' |
|
| 114 | - ), |
|
| 115 | - ], |
|
| 116 | - 'regTicketIn' => [ |
|
| 117 | - 'type' => ['list_of' => 'ID'], |
|
| 118 | - 'description' => esc_html__( |
|
| 119 | - 'Globally unique registration ticket IDs to get the attendees for.', |
|
| 120 | - 'event_espresso' |
|
| 121 | - ), |
|
| 122 | - ], |
|
| 123 | - 'regTicketId' => [ |
|
| 124 | - 'type' => 'Int', |
|
| 125 | - 'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), |
|
| 126 | - ], |
|
| 127 | - 'regTicketIdIn' => [ |
|
| 128 | - 'type' => ['list_of' => 'Int'], |
|
| 129 | - 'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), |
|
| 130 | - ], |
|
| 131 | - 'regStatus' => [ |
|
| 132 | - 'type' => 'EspressoRegistrationStatusEnum', |
|
| 133 | - 'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), |
|
| 134 | - ], |
|
| 135 | - ], |
|
| 136 | - $args |
|
| 137 | - ); |
|
| 138 | - } |
|
| 64 | + /** |
|
| 65 | + * Given an optional array of args, this returns the args to be used in the connection |
|
| 66 | + * |
|
| 67 | + * @access public |
|
| 68 | + * @param array $args The args to modify the defaults |
|
| 69 | + * |
|
| 70 | + * @return array |
|
| 71 | + */ |
|
| 72 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 73 | + public static function get_connection_args($args = []) |
|
| 74 | + { |
|
| 75 | + return array_merge( |
|
| 76 | + [ |
|
| 77 | + 'datetime' => [ |
|
| 78 | + 'type' => 'ID', |
|
| 79 | + 'description' => esc_html__( |
|
| 80 | + 'Globally unique datetime ID to get the attendees for.', |
|
| 81 | + 'event_espresso' |
|
| 82 | + ), |
|
| 83 | + ], |
|
| 84 | + 'datetimeIn' => [ |
|
| 85 | + 'type' => ['list_of' => 'ID'], |
|
| 86 | + 'description' => esc_html__( |
|
| 87 | + 'Globally unique datetime IDs to get the attendees for.', |
|
| 88 | + 'event_espresso' |
|
| 89 | + ), |
|
| 90 | + ], |
|
| 91 | + 'event' => [ |
|
| 92 | + 'type' => 'ID', |
|
| 93 | + 'description' => esc_html__( |
|
| 94 | + 'Globally unique event ID to get the attendees for.', |
|
| 95 | + 'event_espresso' |
|
| 96 | + ), |
|
| 97 | + ], |
|
| 98 | + 'eventIn' => [ |
|
| 99 | + 'type' => ['list_of' => 'ID'], |
|
| 100 | + 'description' => esc_html__( |
|
| 101 | + 'Globally unique event IDs to get the attendees for.', |
|
| 102 | + 'event_espresso' |
|
| 103 | + ), |
|
| 104 | + ], |
|
| 105 | + 'orderby' => [ |
|
| 106 | + 'type' => ['list_of' => 'EspressoAttendeesConnectionOrderbyInput'], |
|
| 107 | + 'description' => esc_html__('What parameter to use to order the objects by.', 'event_espresso'), |
|
| 108 | + ], |
|
| 109 | + 'regTicket' => [ |
|
| 110 | + 'type' => 'ID', |
|
| 111 | + 'description' => esc_html__( |
|
| 112 | + 'Globally unique registration ticket ID to get the attendees for.', |
|
| 113 | + 'event_espresso' |
|
| 114 | + ), |
|
| 115 | + ], |
|
| 116 | + 'regTicketIn' => [ |
|
| 117 | + 'type' => ['list_of' => 'ID'], |
|
| 118 | + 'description' => esc_html__( |
|
| 119 | + 'Globally unique registration ticket IDs to get the attendees for.', |
|
| 120 | + 'event_espresso' |
|
| 121 | + ), |
|
| 122 | + ], |
|
| 123 | + 'regTicketId' => [ |
|
| 124 | + 'type' => 'Int', |
|
| 125 | + 'description' => esc_html__('Registration ticket ID to get the attendees for.', 'event_espresso'), |
|
| 126 | + ], |
|
| 127 | + 'regTicketIdIn' => [ |
|
| 128 | + 'type' => ['list_of' => 'Int'], |
|
| 129 | + 'description' => esc_html__('Registration ticket IDs to get the attendees for.', 'event_espresso'), |
|
| 130 | + ], |
|
| 131 | + 'regStatus' => [ |
|
| 132 | + 'type' => 'EspressoRegistrationStatusEnum', |
|
| 133 | + 'description' => esc_html__('Limit attendees to registration status.', 'event_espresso'), |
|
| 134 | + ], |
|
| 135 | + ], |
|
| 136 | + $args |
|
| 137 | + ); |
|
| 138 | + } |
|
| 139 | 139 | } |
@@ -16,174 +16,174 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | class AttendeeConnectionResolver extends AbstractConnectionResolver |
| 18 | 18 | { |
| 19 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 20 | - public function get_loader_name() |
|
| 21 | - { |
|
| 22 | - return 'espresso_attendee'; |
|
| 23 | - } |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * @return EEM_Attendee |
|
| 27 | - * @throws EE_Error |
|
| 28 | - * @throws InvalidArgumentException |
|
| 29 | - * @throws InvalidDataTypeException |
|
| 30 | - * @throws InvalidInterfaceException |
|
| 31 | - */ |
|
| 32 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 33 | - public function get_query() |
|
| 34 | - { |
|
| 35 | - return EEM_Attendee::instance(); |
|
| 36 | - } |
|
| 37 | - |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * Return an array of item IDs from the query |
|
| 41 | - * |
|
| 42 | - * @return array |
|
| 43 | - */ |
|
| 44 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 45 | - public function get_ids() |
|
| 46 | - { |
|
| 47 | - $results = $this->query->get_col($this->query_args); |
|
| 48 | - |
|
| 49 | - return ! empty($results) ? $results : []; |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Determine whether the Query should execute. If it's determined that the query should |
|
| 55 | - * not be run based on context such as, but not limited to, who the user is, where in the |
|
| 56 | - * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
| 57 | - * Return false to prevent the query from executing. |
|
| 58 | - * |
|
| 59 | - * @return bool |
|
| 60 | - */ |
|
| 61 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 62 | - public function should_execute() |
|
| 63 | - { |
|
| 64 | - if (false === $this->should_execute) { |
|
| 65 | - return false; |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - return $this->should_execute; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Here, we map the args from the input, then we make sure that we're only querying |
|
| 74 | - * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
| 75 | - * handle batch resolution of the posts. |
|
| 76 | - * |
|
| 77 | - * @return array |
|
| 78 | - * @throws EE_Error |
|
| 79 | - * @throws InvalidArgumentException |
|
| 80 | - * @throws ReflectionException |
|
| 81 | - * @throws InvalidDataTypeException |
|
| 82 | - * @throws InvalidInterfaceException |
|
| 83 | - */ |
|
| 84 | - // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 85 | - public function get_query_args() |
|
| 86 | - { |
|
| 87 | - $where_params = []; |
|
| 88 | - $query_args = []; |
|
| 89 | - |
|
| 90 | - $query_args['limit'] = $this->getLimit(); |
|
| 91 | - |
|
| 92 | - // Avoid multiple entries by join. |
|
| 93 | - $query_args['group_by'] = 'ATT_ID'; |
|
| 94 | - |
|
| 95 | - $query_args['default_where_conditions'] = 'minimum'; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
| 99 | - */ |
|
| 100 | - $input_fields = []; |
|
| 101 | - if (! empty($this->args['where'])) { |
|
| 102 | - $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
| 103 | - |
|
| 104 | - // Since we do not have any falsy values in query params |
|
| 105 | - // Lets get rid of empty values |
|
| 106 | - $input_fields = array_filter($input_fields); |
|
| 107 | - |
|
| 108 | - // Use the proper operator. |
|
| 109 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
| 110 | - $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
|
| 111 | - } |
|
| 112 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 113 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
|
| 114 | - } |
|
| 115 | - // If Ticket param is passed, it will have preference over Datetime param |
|
| 116 | - // So, use Datetime param only if a Ticket param is not passed |
|
| 117 | - if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 118 | - $datetimeIds = $input_fields['Datetime.DTT_ID']; |
|
| 119 | - // Make sure it's an array, ready for "IN" operator |
|
| 120 | - $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
|
| 121 | - |
|
| 122 | - try { |
|
| 123 | - // Get related ticket IDs for the given dates |
|
| 124 | - $ticketIds = EEM_Ticket::instance()->get_col([ |
|
| 125 | - [ |
|
| 126 | - 'Datetime.DTT_ID' => ['IN', $datetimeIds], |
|
| 127 | - 'TKT_deleted' => ['IN', [true, false]], |
|
| 128 | - ], |
|
| 129 | - 'default_where_conditions' => 'minimum', |
|
| 130 | - ]); |
|
| 131 | - } catch (Throwable $th) { |
|
| 132 | - $ticketIds = []; |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - if (!empty($ticketIds)) { |
|
| 136 | - $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - // Since there is no relation between Attendee and Datetime, we need to remove it |
|
| 140 | - unset($input_fields['Datetime.DTT_ID']); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * Merge the input_fields with the default query_args |
|
| 145 | - */ |
|
| 146 | - if (! empty($input_fields)) { |
|
| 147 | - $where_params = array_merge($where_params, $input_fields); |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
| 151 | - |
|
| 152 | - $query_args[] = $where_params; |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * Return the $query_args |
|
| 156 | - */ |
|
| 157 | - return $query_args; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
| 163 | - * friendly keys. |
|
| 164 | - * |
|
| 165 | - * @param array $where_args |
|
| 166 | - * @return array |
|
| 167 | - */ |
|
| 168 | - public function sanitizeInputFields(array $where_args) |
|
| 169 | - { |
|
| 170 | - $arg_mapping = [ |
|
| 171 | - // There is no direct relation between Attendee and Datetime |
|
| 172 | - // But we will handle it via Tickets related to given dates |
|
| 173 | - 'datetime' => 'Datetime.DTT_ID', |
|
| 174 | - 'datetimeIn' => 'Datetime.DTT_ID', |
|
| 175 | - 'event' => 'Registration.Event.EVT_ID', |
|
| 176 | - 'eventIn' => 'Registration.Event.EVT_ID', |
|
| 177 | - 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
| 178 | - 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
| 179 | - 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
| 180 | - 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
| 181 | - 'regStatus' => 'Registration.Status.STS_ID', |
|
| 182 | - ]; |
|
| 183 | - return $this->sanitizeWhereArgsForInputFields( |
|
| 184 | - $where_args, |
|
| 185 | - $arg_mapping, |
|
| 186 | - ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
| 187 | - ); |
|
| 188 | - } |
|
| 19 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 20 | + public function get_loader_name() |
|
| 21 | + { |
|
| 22 | + return 'espresso_attendee'; |
|
| 23 | + } |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * @return EEM_Attendee |
|
| 27 | + * @throws EE_Error |
|
| 28 | + * @throws InvalidArgumentException |
|
| 29 | + * @throws InvalidDataTypeException |
|
| 30 | + * @throws InvalidInterfaceException |
|
| 31 | + */ |
|
| 32 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 33 | + public function get_query() |
|
| 34 | + { |
|
| 35 | + return EEM_Attendee::instance(); |
|
| 36 | + } |
|
| 37 | + |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * Return an array of item IDs from the query |
|
| 41 | + * |
|
| 42 | + * @return array |
|
| 43 | + */ |
|
| 44 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 45 | + public function get_ids() |
|
| 46 | + { |
|
| 47 | + $results = $this->query->get_col($this->query_args); |
|
| 48 | + |
|
| 49 | + return ! empty($results) ? $results : []; |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Determine whether the Query should execute. If it's determined that the query should |
|
| 55 | + * not be run based on context such as, but not limited to, who the user is, where in the |
|
| 56 | + * ResolveTree the Query is, the relation to the node the Query is connected to, etc |
|
| 57 | + * Return false to prevent the query from executing. |
|
| 58 | + * |
|
| 59 | + * @return bool |
|
| 60 | + */ |
|
| 61 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 62 | + public function should_execute() |
|
| 63 | + { |
|
| 64 | + if (false === $this->should_execute) { |
|
| 65 | + return false; |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + return $this->should_execute; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Here, we map the args from the input, then we make sure that we're only querying |
|
| 74 | + * for IDs. The IDs are then passed down the resolve tree, and deferred resolvers |
|
| 75 | + * handle batch resolution of the posts. |
|
| 76 | + * |
|
| 77 | + * @return array |
|
| 78 | + * @throws EE_Error |
|
| 79 | + * @throws InvalidArgumentException |
|
| 80 | + * @throws ReflectionException |
|
| 81 | + * @throws InvalidDataTypeException |
|
| 82 | + * @throws InvalidInterfaceException |
|
| 83 | + */ |
|
| 84 | + // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps |
|
| 85 | + public function get_query_args() |
|
| 86 | + { |
|
| 87 | + $where_params = []; |
|
| 88 | + $query_args = []; |
|
| 89 | + |
|
| 90 | + $query_args['limit'] = $this->getLimit(); |
|
| 91 | + |
|
| 92 | + // Avoid multiple entries by join. |
|
| 93 | + $query_args['group_by'] = 'ATT_ID'; |
|
| 94 | + |
|
| 95 | + $query_args['default_where_conditions'] = 'minimum'; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * Collect the input_fields and sanitize them to prepare them for sending to the Query |
|
| 99 | + */ |
|
| 100 | + $input_fields = []; |
|
| 101 | + if (! empty($this->args['where'])) { |
|
| 102 | + $input_fields = $this->sanitizeInputFields($this->args['where']); |
|
| 103 | + |
|
| 104 | + // Since we do not have any falsy values in query params |
|
| 105 | + // Lets get rid of empty values |
|
| 106 | + $input_fields = array_filter($input_fields); |
|
| 107 | + |
|
| 108 | + // Use the proper operator. |
|
| 109 | + if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
| 110 | + $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
|
| 111 | + } |
|
| 112 | + if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 113 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
|
| 114 | + } |
|
| 115 | + // If Ticket param is passed, it will have preference over Datetime param |
|
| 116 | + // So, use Datetime param only if a Ticket param is not passed |
|
| 117 | + if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 118 | + $datetimeIds = $input_fields['Datetime.DTT_ID']; |
|
| 119 | + // Make sure it's an array, ready for "IN" operator |
|
| 120 | + $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
|
| 121 | + |
|
| 122 | + try { |
|
| 123 | + // Get related ticket IDs for the given dates |
|
| 124 | + $ticketIds = EEM_Ticket::instance()->get_col([ |
|
| 125 | + [ |
|
| 126 | + 'Datetime.DTT_ID' => ['IN', $datetimeIds], |
|
| 127 | + 'TKT_deleted' => ['IN', [true, false]], |
|
| 128 | + ], |
|
| 129 | + 'default_where_conditions' => 'minimum', |
|
| 130 | + ]); |
|
| 131 | + } catch (Throwable $th) { |
|
| 132 | + $ticketIds = []; |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + if (!empty($ticketIds)) { |
|
| 136 | + $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + // Since there is no relation between Attendee and Datetime, we need to remove it |
|
| 140 | + unset($input_fields['Datetime.DTT_ID']); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * Merge the input_fields with the default query_args |
|
| 145 | + */ |
|
| 146 | + if (! empty($input_fields)) { |
|
| 147 | + $where_params = array_merge($where_params, $input_fields); |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + list($query_args, $where_params) = $this->mapOrderbyInputArgs($query_args, $where_params, 'ATT_ID'); |
|
| 151 | + |
|
| 152 | + $query_args[] = $where_params; |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * Return the $query_args |
|
| 156 | + */ |
|
| 157 | + return $query_args; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * This sets up the "allowed" args, and translates the GraphQL-friendly keys to model |
|
| 163 | + * friendly keys. |
|
| 164 | + * |
|
| 165 | + * @param array $where_args |
|
| 166 | + * @return array |
|
| 167 | + */ |
|
| 168 | + public function sanitizeInputFields(array $where_args) |
|
| 169 | + { |
|
| 170 | + $arg_mapping = [ |
|
| 171 | + // There is no direct relation between Attendee and Datetime |
|
| 172 | + // But we will handle it via Tickets related to given dates |
|
| 173 | + 'datetime' => 'Datetime.DTT_ID', |
|
| 174 | + 'datetimeIn' => 'Datetime.DTT_ID', |
|
| 175 | + 'event' => 'Registration.Event.EVT_ID', |
|
| 176 | + 'eventIn' => 'Registration.Event.EVT_ID', |
|
| 177 | + 'regTicket' => 'Registration.Ticket.TKT_ID', |
|
| 178 | + 'regTicketIn' => 'Registration.Ticket.TKT_ID', |
|
| 179 | + 'regTicketIdIn' => 'Registration.Ticket.TKT_ID', |
|
| 180 | + 'regTicketId' => 'Registration.Ticket.TKT_ID', // priority. |
|
| 181 | + 'regStatus' => 'Registration.Status.STS_ID', |
|
| 182 | + ]; |
|
| 183 | + return $this->sanitizeWhereArgsForInputFields( |
|
| 184 | + $where_args, |
|
| 185 | + $arg_mapping, |
|
| 186 | + ['datetime', 'datetimeIn', 'event', 'eventIn', 'regTicket', 'regTicketIn'] |
|
| 187 | + ); |
|
| 188 | + } |
|
| 189 | 189 | } |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * Collect the input_fields and sanitize them to prepare them for sending to the Query |
| 99 | 99 | */ |
| 100 | 100 | $input_fields = []; |
| 101 | - if (! empty($this->args['where'])) { |
|
| 101 | + if ( ! empty($this->args['where'])) { |
|
| 102 | 102 | $input_fields = $this->sanitizeInputFields($this->args['where']); |
| 103 | 103 | |
| 104 | 104 | // Since we do not have any falsy values in query params |
@@ -106,15 +106,15 @@ discard block |
||
| 106 | 106 | $input_fields = array_filter($input_fields); |
| 107 | 107 | |
| 108 | 108 | // Use the proper operator. |
| 109 | - if (! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
| 109 | + if ( ! empty($input_fields['Registration.Event.EVT_ID']) && is_array($input_fields['Registration.Event.EVT_ID'])) { |
|
| 110 | 110 | $input_fields['Registration.Event.EVT_ID'] = ['IN', $input_fields['Registration.Event.EVT_ID']]; |
| 111 | 111 | } |
| 112 | - if (! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 112 | + if ( ! empty($input_fields['Registration.Ticket.TKT_ID']) && is_array($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 113 | 113 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $input_fields['Registration.Ticket.TKT_ID']]; |
| 114 | 114 | } |
| 115 | 115 | // If Ticket param is passed, it will have preference over Datetime param |
| 116 | 116 | // So, use Datetime param only if a Ticket param is not passed |
| 117 | - if (! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 117 | + if ( ! empty($input_fields['Datetime.DTT_ID']) && empty($input_fields['Registration.Ticket.TKT_ID'])) { |
|
| 118 | 118 | $datetimeIds = $input_fields['Datetime.DTT_ID']; |
| 119 | 119 | // Make sure it's an array, ready for "IN" operator |
| 120 | 120 | $datetimeIds = is_array($datetimeIds) ? $datetimeIds : [$datetimeIds]; |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | $ticketIds = []; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - if (!empty($ticketIds)) { |
|
| 135 | + if ( ! empty($ticketIds)) { |
|
| 136 | 136 | $input_fields['Registration.Ticket.TKT_ID'] = ['IN', $ticketIds]; |
| 137 | 137 | } |
| 138 | 138 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | /** |
| 144 | 144 | * Merge the input_fields with the default query_args |
| 145 | 145 | */ |
| 146 | - if (! empty($input_fields)) { |
|
| 146 | + if ( ! empty($input_fields)) { |
|
| 147 | 147 | $where_params = array_merge($where_params, $input_fields); |
| 148 | 148 | } |
| 149 | 149 | |