Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
This constants are used by comment field to indicate the visibility/commentability of the attached field.
We should move this constants to separate class to make unit-testing easy.
Comment | File | Size | Author |
---|---|---|---|
#27 | move_comment_const-2169361-27.patch | 39.77 KB | plopesc |
#24 | interdiff.txt | 1.35 KB | plopesc |
#24 | move_comment_const-2169361-24.patch | 39.74 KB | plopesc |
Comments
Comment #1
plopescThis approach moves these variables to
CommentInterface
and replaces the occurrences of those variables.Regards.
Comment #3
andypost@plopesc Great patch, not so huge as I think!
The trouble here that this constants does not related to comment entity itself, they are used only by comment field as values but we have no
CommentFieldInterface
and probably moving them intoCommentManagerInterface
makes more sense.Let's get @larowlan feedback on it
Comment #4
larowlanInline with #2169447: DX: Supply CacheBackendInterface::CACHE_PERMANENT as Cache::PERMANENT why not CommentItem::OPEN? Provides the best dx?
CommentInterface is the comment entity where as these constants are to do with the field
Comment #5
andypostProbably we need to add
CommentItemInterface
Comment #6
plopescNew round including new
CommentItemInterface
. Not sure about if it is placed in the right place...Interdiff is not included because this patch differs a lot from the previous one.
Regards.
Comment #7
andypostI'm fine with this place for interface, RTBC if green.
PS: Will require re-roll If related #2097123: Deprecate comment_num_new() in favour of method on CommentManager commited first
Comment #8
plopescRe-rolling here.
Although #2097123: Deprecate comment_num_new() in favour of method on CommentManager has been postponed, I believe we can continue with this patch.
Regards.
Comment #9
andypost8: move_comment_const-2169361-8.patch queued for re-testing.
Comment #11
plopescRe-rolling
Comment #12
plopescRe-rolling
Comment #13
plopescRe-rolling
Comment #14
andypostRTBC but this one needs change notice draft now
Comment #15
plopescChange record added https://drupal.org/node/2197921
Comment #16
alexpottmove_comment_const-2169361-13.patch no longer applies.
Comment #17
plopescRe-rolling
Comment #18
alexpottShouldn't this now be
And perhaps we should consider adding isOpen(), isHidden(), isClosed() methods?
So then we could do
We can remove the use and the CommentItemInterface::OPEN as this is the default value.
Comment #19
andypostIt should be
class CommentItem extends ConfigFieldItemBase implements CommentItemInterface {
+1 to add
is*
methodsComment #20
plopescHello
I'm adding those methods to CommentItem and ComentItemInterface. However, most of times, the comment status comparison is done against the ConfigFieldItemList class, like in the example, and these methods are not available at ItemList level.
We could create new FieldItemList class for comments, called CommentFieldItemList and its interface CommentFieldItemListInterface where we could add those methods in order to be able to do $entity->{$field_name}->isOpen();
What do you think?
Comment #21
andypostDiscussed with @berdir
Comment #22
andypostI think we should file a follow-up anyway, because comment field has more than "value" inside.
Let's just fix #19 in issue scope and file new issue to discuss methods and integration of
{comment_entity_statistics}
from#148849: Refactor {comment_entity_statistics} into performant Field and #2101183: Move {comment_entity_statistics} to proper service
Comment #23
BerdirYes, adding methods on field item classes is not something anyone else is doing and has the mentioned issues, adding a class and interface to repeat it on the level would be pretty unfortunate.
Comment #24
plopescNew patch fixing class declaration and removing unnecessary reference in forum.install.
Comment #25
plopescRe-rolling after #2200821: Rename Fieldinterface and FieldInstanceInterface
Comment #26
plopescRe-rolling previous patch no longer applies.
Comment #27
plopescRe-rolling. Previous patch no longer applies...
Comment #28
andypost27: move_comment_const-2169361-27.patch queued for re-testing.
Comment #29
andypostback to rtbc
Comment #30
alexpottWe need a change record for this before we can commit - once one exists can set back to rtbc
Comment #31
plopescThere is already a change record for this issue COMMENT_HIDDEN & COMMENT_CLOSED & COMMENT_OPEN converted to constants on CommentItemInterface.
Setting back to RTBC.
Comment #32
YesCT CreditAttribution: YesCT commented27: move_comment_const-2169361-27.patch queued for re-testing.
Comment #33
alexpottMissed it - sorry.
Committed fd2613d and pushed to 8.x. Thanks!
Comment #34
plopesc@alexpott no problem. Thank you so much :)