Closed (fixed)
Project:
Paragraph View Mode
Version:
8.x-1.5
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
6 Aug 2020 at 15:32 UTC
Updated:
25 Nov 2020 at 12:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
sayco commentedHi @UriDrupal, could you verify first if your issue is similar to:
https://www.drupal.org/project/paragraph_view_mode/issues/3157506
especially if you could verify if you enabled those view modes on your paragraph type.
Comment #3
sayco commented@UriDrupal I would be very glad if you can answer my question or provide me with any additional information to debug your issue.
Comment #4
granikThe error has been fixed. I added the patch.
Comment #5
sayco commentedThank you for introducing the patch. I maybe not follow, but could you explain why the __CLASS__ is better then get_called_class()? The second one is more flexible, as it allows to call the method from the current class - so it's usefull in case of inheritance. I would rather stick to get_called_class, but I would like to know opinion from the community.
I also don't understand why did you change the method to a static one? Even in Ajax Form API examples a non-static methods are used.
Comment #6
granikIt's my personal opinion. I'm used to see php callable array with this constant. Maybe it's not a very good style in drupal context.
It was the reason of the error. How are you going to use a non-static method in php callable? In this case you have to set an object as the first element of callable-array. But as you already said, get_called_class() returns the classname string, not object, __CLASS__ is the same.
It's just a callback. You can use any callable. Read more about ajax callbacks
Comment #7
sayco commentedOk I see your point. IMO get_called_class() could better because it's like with a
static vs selfso basicaly get_called_class will return the current executed class, the __CLASS__ will return the specific class - ParagraphViewModeWidget.Of course, it can be altered - it's a matter of changing the callback in the form element, but I think that the current solution is a bit more clean solution. What is your opinion on this?
In terms of changing a method into static, yes I totally get it now, so it's definitely a great thing :-)
Comment #9
sayco commented