-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: QL Events settings tab added and schema organized #55
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small comments, and double checking why are we using so much Anonymous functions? Instead of creating a new method, for example on ql_events_resolve_tec_order_type
and so many others. It's ok, just wanted to understand why.
includes/class-admin.php
Outdated
public function __construct() { | ||
add_action( 'graphql_register_settings', [ $this, 'register_settings' ] ); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a required change, but I would love to avoid adding filters on a construct, it prevents a misfire of double hooking if we move it to a hook()
method
includes/admin/class-general.php
Outdated
* @return array | ||
*/ | ||
public static function get_fields() { | ||
$test_mode_status = (bool) defined( 'QL_EVENTS_TEST_MODE' ) && QL_EVENTS_TEST_MODE ? 'force enabled' : 'force disabled'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wounder if we should have a method for the test mode verification.
Cuz I was rushing lol |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor things and some questions, would love to see us having @since TBD
in general.
And replace all TBDs right before launch with the version.
'resolve' => function( $source ) { | ||
$decorator = tribe( Attendee::class ); | ||
$decorated_attendee = $decorator->get_attendee( get_post( $source->ID ) ); | ||
|
||
$meta = tribe( 'tickets-plus.meta' ); | ||
$attendee_meta_data = $meta->get_attendee_meta_fields( $decorated_attendee->ticket_id, $decorated_attendee->ID ); | ||
if ( isset( $attendee_meta_data[0] ) ) { | ||
unset( $attendee_meta_data[0] ); | ||
} | ||
|
||
if ( ! is_array( $attendee_meta_data ) ) { | ||
return []; | ||
} | ||
|
||
return array_map( | ||
function( $key, $value ) { | ||
return (object) compact( 'value', 'key' ); | ||
}, | ||
array_keys( $attendee_meta_data ), | ||
array_values( $attendee_meta_data ) | ||
); | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not for this PR, but I would love to see us move towards having the actual method live in this class, and we pass it as a Callable
here. Feels like it would be better for long term unit testing and readability.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What method are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the actual function that is assigned to the 'resolve' key, I would love for us to go towards using methods from this class, instead of anonymous functions. Which will make the code harder to test and read down the line.
default: | ||
$type = apply_filters( 'ql_events_resolve_ticket_type', null, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docblock missing here.
default: | ||
$type = apply_filters( 'ql_events_resolve_tec_order_type', null, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docblock missing here.
default: | ||
$type = apply_filters( 'ql_events_resolve_attendee_type', null, $value ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docblock missing here.
* | ||
* @param array $ticket_classes - TEC ticket class names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be cool to see some @since TBD
in the docblocks.
Co-authored-by: Gustavo Bordoni <[email protected]>
Summary