following the work done in this my previous issue: https://www.drupal.org/node/2745595 (now closed),
I went forward refactoring ALL the Leaflet_views submodule plug-ins to better comply to the Drupal 8 coding best practice regarding Dependency Injection, Service Container, and Unit Testability (https://www.drupal.org/node/2133171).
In synthesis the following has been done:
- removed direct calls to static functions/methods, and more correctly implemented dependency_injection of services withe the service container and the "create" method;
- removed deprecated classes with the preferred ones and methods (mainly from EntityManager to its new EntityTypeManager and relevant other sub services ...);
- re-titled the plugin to "Leaflet map (classic)" (sounded me better than the actual Leaflet map (old));
- corrected the plugin id to "leaflet_map";
- fixed several mini adjustments on the coding standards, mainly on the correct commenting standards side (my code sniffer in phpstorm is very strict on this).
Patch attached about all the this.
Hope this helps and feel free to reject the undesired amendments ...
Comments
Comment #2
itamair CreditAttribution: itamair commentedComment #3
szeidler CreditAttribution: szeidler at Ramsalt Lab commentedThanks itamair, great effort.
For me that patch didn't applied cleanly, so that I needed to reroll it for the current HEAD. I wasn't able to figure out, what was the problem with your patch in detail.
I can confirm, that the patch is working. It's really a nice step to move the modules code quality forward.
Through the change of the plugin id from
leafet_map
toleaflet_map
we need a proper handling for existing sites to work with the plugin name change. Otherwise all of these maps need to be reconfigured. When applying the patch on an existing installation you will get aComment #4
itamair CreditAttribution: itamair commented@szeidler that error you mention (regarding the plugin name change) is a proper matter of D8 configuration settings. It arises from the original views configuration yaml files, that will keep looking for the (original) "leafet_map" views plugin style.
To fix them you will need to export/copy (admin/config/development/configuration/single/export) each views config yaml file and re-import it (admin/config/development/configuration/full/import), with the following lines corrected:
Comment #5
pvhee CreditAttribution: pvhee at Marzee commenteditamair, could you reroll the patch against the current head? Agree with your observations and this will clean up the Leaflet code which was ported rather fast to Drupal 8.
Comment #6
itamair CreditAttribution: itamair commentednew update patch on this rerolled on the current head. This should be tested. Hope will be reviewed in time not to make this old again ;-)
Comment #7
itamair CreditAttribution: itamair commentedComment #8
pvhee CreditAttribution: pvhee at Marzee commentedThis looks good and working well in my leaflet sandbox site:
A couple of comments though.
You seem to revert some of the work that went into #273657: No events are shown in year view or calendar month block (you changed number fields back to textfields)
Can we rewrite this more concise?
e.g. to
Comment #9
pvhee CreditAttribution: pvhee at Marzee commentedFYI, I've set up a mirror repository of Leaflet at https://github.com/marzeelabs/leaflet -- this should make it easier to create a PR and review changes.
Comment #10
pvhee CreditAttribution: pvhee at Marzee commentedAnother note: we might need to provide an upgrade path in order to avoid the following error
Comment #11
itamair CreditAttribution: itamair commented@pvhee tnx for your comments and suggestions.
Here is the updated patch for with you suggested more concise code.
Couple of things:
- I don't get your first note at the #8 comment: You seem to revert some of the work that went into #273657: No events are shown in year view or calendar month block (you changed number fields back to textfields).
It seems to be a 2008 D5 issue, regarding the Calendar module. Isn't it?
- right, we might need to provide an upgrade path in order to avoid the error regarding 'The "leafet_map" plugin does not exist.'. But how?
Might be just a copy class of the leaflet_views/src/Plugin/views/style/LeafletMap.php one, just with an annotation like the following ... ?
* @ViewsStyle(
* id = "leafet_map",
* title = @Translation("Leaflet map (uncorrect one)"),
* help = @Translation("Displays a View as a Leaflet map with a buggy id. Should be changed to the Leaflet map (classic) one ."),
* display_types = {"normal"},
* theme = "leaflet-map"
* )
Comment #12
itamair CreditAttribution: itamair commentedComment #13
pvhee CreditAttribution: pvhee at Marzee commentedApologies, I meant to refer to issue #2736573: Number validation in formatter forms not working
I'd suggest removing the refactoring of the leafet to leaflet change and do this in a separate issue where we can discuss upgrade path (if we really want to provide that).
Other than that this looks good so we can commit this back after these fixes.
Comment #14
itamair CreditAttribution: itamair commented@pvhee ok I fixed it (everything):
- re- included the code for the issue #2736573: Number validation in formatter forms not working, plus some further minor fixer on code refactoring and Drupal Standards
- I provided a (so called) upgrade path (that might be thought as temporary, but perfectly working, imho) in the form of a further LeafetMap Class View Style Plugin (id= leafet_map) that just extends the correct LaefletMap Class (id=leaflet_map), with any additional code (it works exactly as the id=leaflet_map one). In this way every user set with the (UN-CORRECT) leafet_map plugin id won't have any application error but just an advised message in the view backend that invites him to shift to the new correct and ANALOG Leaflet map (classic) one.
Hope this finally helps. Feel free to amend all this the way you prefer, and commit this to the head ...
Comment #15
itamair CreditAttribution: itamair commentedComment #16
itamair CreditAttribution: itamair commentedA further improvement and a better "upgrade path" might be
Let me know if this upgrade path might be worth to be done (I just started to draft the hook_requirements update ...)
Comment #17
pvhee CreditAttribution: pvhee at Marzee commentedThanks for the new patch, but not sure about the upgrade path, and I would like people to test this first in their current installs.
If we want to get the rest merged in earlier, we need to remove the leafet->leaflet change and handle this in a separate issue as I suggested in #13, can this be done?
Comment #18
itamair CreditAttribution: itamair commentedOk, sure ... I will update this patch on this, by the we ;-) (and open a new issue on the leafet->leaflet change)
Comment #19
itamair CreditAttribution: itamair commentedHere is a new rerolled patch, specifically regarding refactoring with dependency injections (more complaints with Drupal best practices and testability),
and skipping the matter regarding the error on the leafet_map view style plugin.
Once committed this to the head/actual dev of the project, I will open a new issue addressing a proper path to correct the leafet_map -> leaflet_map plugin name.
Just let us know when this will be committed/merged.
Comment #20
itamair CreditAttribution: itamair commentedComment #22
pvhee CreditAttribution: pvhee at Marzee commentedThanks itamair, I've reviewed this, removed some slashes from the namespace use statements that weren't needed, and committed this!