-
Notifications
You must be signed in to change notification settings - Fork 14
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
Expand event API to include partners
as array string. DDFHER-119
#1743
base: develop
Are you sure you want to change the base?
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.
👍 but I think the handling of multivalue fields needs a some more consideration.
@@ -63,6 +63,7 @@ public function getResponse(EventInstance $event_instance): EventsGET200Response | |||
'branches' => $this->getBranches(), | |||
'address' => $this->getAddress(), | |||
'tags' => $this->getTags(), | |||
'partners' => $this->getMultiValue('event_partners'), |
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.
Consider what happens with this value if there are no partners.
The spec requires an optional array of strings.getMultiValue()
returns null
or an array of strings. Will the response leave out the partners
property if the value is null
or automatically convert it to an empty array?
Personally I would prefer getMultiValue()
to always return an array of strings. The value might then be empty.
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.
Fair point. I've updated it so it'll always return an array, even if it is empty.
return NULL; | ||
} | ||
|
||
return explode(', ', $strings); |
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.
Please consider if this is an appropriate way to handle multivalue fields.
As I read it, if one of the value contain ,
then it will be treated as a multivalue. That does not seem right. Is there a better way to go about this?
If we go with this approach I would appreciate a reference to why ,
is an appropriate separator.
event_partners
is a multivalue field and to me it is not obvious that multiple values are separated by ,
by Drupal Core/$field->getString()
.
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 was an attempt to reuse the custom getValue() method, but, i didnt consider that strings might actually contain ,
.
I've updated it, to use the Drupal getValue
method instead, and using array_column
to turn it into a simple array.
71df799
to
5a08e10
Compare
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.
👍 LGTM
Link to issue
https://reload.atlassian.net/browse/DDFHER-119
/api/v1/events