Closed (fixed)
Project:
Content fixtures
Version:
3.0.0
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
6 Jan 2022 at 20:02 UTC
Updated:
23 Jan 2022 at 13:15 UTC
Jump to comment: Most recent
Comments
Comment #2
luke_nuke commentedHello! Thanks for your feedback. content_fixture_test module is not supposed to have examples, this module just provides some features for tests, and it is its only purpose.
Documentation assumes some pre-existing knowledge of Drupal/Symfony's services and tagging, and it surely could be improved. I might add a dedicated example module to the codebase if that would help.
Note that there are `drush help` commands specified in the readme, where you might get some details regarding usage of groups for example.
Comment #3
Mario_o commentedComment #4
Mario_o commentedComment #6
luke_nuke commentedThank you for your contribution! It's very appreciated. I went through the updated README.md and added some tweaks/clarifications. Before merging it, I think I will take the opportunity and add some commonly used patterns to the example module. For example: generating images.
I have two questions though:
Once again: thank you for your contribution, it was much needed.
Comment #7
Mario_o commentedHappy to work together toward a greater module, that can grow faster over time with the right contribution :) .
Comment #8
luke_nuke commentedI did some tweaks to the docs of the example module to reduce repeated statements, group them in places they fit better, like in the methods docs, etc. I also added an example of image generation with a test. I think it should be good to go, but I will give it a moment, to make sure I didn't miss anything.
Comment #9
luke_nuke commentedComment #10
Mario_o commentedfor the ImageProvider, it will be better to include the logic of generating content in the content_fixtures module itself and rename it to DataGenerator why?
because in the future features we can add more methods to the DataGenerator service factory that enable us to generate other type of data ,like for example:
we can even go further and make the data Generator factory service use an extra layer : fzaninotto/Faker package to generate close to real world data fixtures.
The big advantage here that the dataGenerator service factory can be used in 2 ways :
Comment #11
luke_nuke commentedIt would be less flexible though, because it would couple logics that don't need to be coupled. If fixture needs a generator, it probably doesn't need every generator. Generators being independent units make for a more flexible design: end user can group them in higher level logical units as he wants. He can implement this kind of a "super-generator" you described by just injecting existing generators to it, and he can even make it configurable, and make generator implementations switchable. This gives him much more power. Or in other words: Coupling them in a single class would make them always move around together, and that's just less flexible. Also adding new methods to the interface of such "super-generator" would always break backwards compatibility, because someone could use this interface. That's why I don't see any gain from it.
Currently we have existing namespace for generators, user can inject them as he needs them, and we can add new in a non-BC-breaking way, so it seems perfect.Edit: Sorry, we have namespace and a generator in example module only. But I'm not sure if we need generators in the main module to be honest, because they could be very project specific, and some of them would require external dependencies, like a PDF generation. I think it should be up to developers to implement their own generators, because implementing them in this module and aiming for all possible requirements would probably prove to be difficult. So I consider going beyond the example image generation based on Drupal's core features to be out of the scope of this module for now.
We could make an online documentation with some arbitrary examples though.
Comment #12
luke_nuke commentedLet's consider other possibility: creating a supplementary module named, for example: content_fixtures_tools . Let's say you would want to implement as many useful generators as you can. PDFs, pulling images from the external services, images in many formats, Office's documents etc. You would end up with a lot of external dependencies. Would it be wise to install a module that makes your code base that much heavier? I think not. It also wouldn't be easy to maintain such dependencies, taking into account security updates etc. That's why I prefer guidance in implementing custom generators instead of implementing them for everyone.
Comment #13
Mario_o commentedYeah I get the point and I didn't think abut this points ,
so I think you are right it will be better to include just an example and let the user create his own generators .
Comment #15
luke_nuke commentedMerge request has been merged! 🎉 Thank you for your initiative and help!
Comment #16
Mario_o commentedGreate happy to hear that :)
Comment #17
luke_nuke commented