- Issue created by @jrockowitz
- πΊπΈUnited States jrockowitz Brooklyn, NY
Approach 2: Solves the immediate requirement of supporting multiple categories while leaving the possibility for future improvements open.
- πΊπΈUnited States FatherShawn New York
This looks like the best solution because it is portable within webforms
- πΊπΈUnited States devanbicher
I agree with approach 2. Portability across webforms seems like a nice advantage. Potential translation issues don't seem as important if that issue hasn't been raised before, but hopefully that is fixable should that situation arise.
- Status changed to Needs review
over 1 year ago 10:22pm 14 February 2023 - @jrockowitz opened merge request.
The last submitted patch, 7: 3339769-7.patch, failed testing. View results β
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.The last submitted patch, 9: 3339769-9.patch, failed testing. View results β
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- Status changed to Needs work
over 1 year ago 12:20am 16 February 2023 - π§π·Brazil RenatoG Campinas
Seems good. My suggestion if on
_webform_update_webform_setting_properties
atincludes/webform.install.inc
we we're using two ifs on this piece:if (isset($properties['category'])) { $properties['categories'] = []; if (!empty($properties['category'])) {
I think we can use the opposite, instead of verifying
if (isset($properties['category']))
with the code there, we can verify the oppositeif (!isset($properties['category']))
and with early return there, like this:if (!isset($properties['category'])) { return $properties; }
With that we can reduce the code indentation you know? For example:
From (before)
function _webform_update_webform_setting_properties(array $properties) { // Issue #3339769: Improve Webform categorization to support assigning multiple categories and default categories if (isset($properties['category'])) { $properties['categories'] = []; if (!empty($properties['category'])) { $properties['categories'] = array_values(array_filter(array_merge( $properties['categories'], (array) $properties['category'] ))); } unset($properties['category']); } return $properties; }
To: (new)
function _webform_update_webform_setting_properties(array $properties) { // Issue #3339769: Improve Webform categorization to support assigning multiple categories and default categories if (!isset($properties['category'])) { return $properties; } $properties['categories'] = []; if (!empty($properties['category'])) { $properties['categories'] = array_values(array_filter(array_merge( $properties['categories'], (array) $properties['category'] ))); } unset($properties['category']); return $properties; }
- Status changed to Needs review
over 1 year ago 12:31am 16 February 2023 - πΊπΈUnited States jrockowitz Brooklyn, NY
I don't want to do an early return via _webform_update_webform_setting_properties to allow other tickets to alter a webform's properties in the future.
- π§π·Brazil RenatoG Campinas
Got it, really Makes sense. Good catch
I just hid #14 in favor of #11
-
jrockowitz β
authored 76d13440 on 6.2.x
Issue #3339769 by jrockowitz, RenatoG: Improve Webform categorization to...
-
jrockowitz β
authored 76d13440 on 6.2.x
-
jrockowitz β
authored 3e13b4c9 on 6.2.x
Issue #3339769 by jrockowitz, RenatoG: Improve Webform categorization to...
-
jrockowitz β
authored 3e13b4c9 on 6.2.x
- Status changed to Fixed
about 1 year ago 10:04am 27 April 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- π¨π¦Canada endless_wander
In case someone finds this thread with same issue as me, the change to 'categories' instead of 'category' broke some entityQuery instances. So must change any conditions for categories from:
->condition('category', 'Category Name')
to:
->condition('categories.*', 'Category Name')
As a side note, it may be nice to add a `hasCategory()` method to the Webform class as well
- π©πͺGermany kle
Yes endless_wander, this would be nice.. ->hasCategory()
- π§πͺBelgium arno_vgh
Hi,
Although I appreciate this adjustment immensely, I would have preferred to see it documented in the change records as it could potentially break existing code and therefore likely requires changes.
In the past, using
$category = $webform->get('category')
(assuming a webform could only have one category) will now returnNULL
. Updating the code to$webform->get('categories')
will now return an array of categories.(My apologies if this information is already documented somewhere and I overlooked it).