-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
@@ -450,7 +450,7 @@ public function processResults(ResultSet $results, $log_id) { | |||
'location_name' => '', | |||
'location_address' => '', | |||
'location_phone' => '', | |||
'spots_available' => !$entity->field_availability->isEmpty() ? $entity->field_availability->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.
Drupal's isEmpty
just wraps PHP's, which considers 0
as 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.
No, Drupal's isEmpty()
specifically checks for NULL - https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21TypedData%21Plugin%21DataType%21ItemList.php/function/ItemList%3A%3AisEmpty/9.3.x
I did a deep dive on it about a year ago: abe64f9 and c2495cb
Null coalescence on the value is probably doing the same thing, meaning that this code change shouldn't actually change a thing. I still tend to have Drupal API isEmpty()
here.
Activity Finder 4 already uses the 0 value of available spots: https://github.com/ymcatwincities/openy_activity_finder/blob/4.x/openy_af4_vue_app/src/components/modals/ActivityDetails.vue#L254 - see getButtonTitle()
and isRegisterDisabled()
; and here https://github.com/ymcatwincities/openy_activity_finder/blob/4.x/openy_af4_vue_app/src/components/AvailableSpots.vue#L26
And you can see it working on the sandbox here: https://sandbox-carnation-cus-d9.openy.org/activity-finder-v4?step=results
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.
@duozersk thanks for your clarification. I think I had two issues:
- My project was on an older version and didn't have your new logic using Drupal's
isEmpty
, it was still using PHP'sempty
. I believe you're correct and my edit here is not necessary. - My project it still using AF3, which uses the twig templates below. I think that change is still necessary, but won't be reflected in the sandbox as they're using AF4.
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.
Drupal API is checking for NULL
@@ -450,7 +450,7 @@ public function processResults(ResultSet $results, $log_id) { | |||
'location_name' => '', | |||
'location_address' => '', | |||
'location_phone' => '', | |||
'spots_available' => !$entity->field_availability->isEmpty() ? $entity->field_availability->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.
No, Drupal's isEmpty()
specifically checks for NULL - https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21TypedData%21Plugin%21DataType%21ItemList.php/function/ItemList%3A%3AisEmpty/9.3.x
I did a deep dive on it about a year ago: abe64f9 and c2495cb
Null coalescence on the value is probably doing the same thing, meaning that this code change shouldn't actually change a thing. I still tend to have Drupal API isEmpty()
here.
Activity Finder 4 already uses the 0 value of available spots: https://github.com/ymcatwincities/openy_activity_finder/blob/4.x/openy_af4_vue_app/src/components/modals/ActivityDetails.vue#L254 - see getButtonTitle()
and isRegisterDisabled()
; and here https://github.com/ymcatwincities/openy_activity_finder/blob/4.x/openy_af4_vue_app/src/components/AvailableSpots.vue#L26
And you can see it working on the sandbox here: https://sandbox-carnation-cus-d9.openy.org/activity-finder-v4?step=results
Is it ready ? @froboy |
@podarok yes, I believe so. |
Activities may have zero spots available but still have signups open (if they have a wait list).
I needed to:
0
to the front-end instead of''
Fixes #150
To test:
spots available
field on a session to0
FULL