- Issue created by @just_like_good_vibes
- Merge request !116Introduce tags and context_requirements → (Merged) created by just_like_good_vibes
- Status changed to Needs review
5 months ago 11:17pm 14 June 2024 - 🇩🇪Germany Christian.wiedemann
You are a machine. Looks great and brutal fast. :)
Just one thing:
SourcePluginBase::addContextRequirementsValues
is not clear for me. Why is the first argument contexts and not only the context which needs the "RequirementsValues". Maybe we create an own Context Class like "Drupal\Core\Plugin\Context\EntityContext"
and Add a static Method$context = RequirementsValuesContext::create('key', ['value1'])
andRequirementsValuesContext::attach($context, ['value1'])
- Status changed to Needs work
5 months ago 7:19am 15 June 2024 - 🇫🇷France just_like_good_vibes PARIS
Thank you Christian for reviewing.
about the method you mentioned, i just created it to factorize a piece of code that would:
1: create the context when missing and adds the values provided
2: overwrite the context if it already exists and adds the values provided to the already existing values.that's why i need the whole contexts array,
from the caller point of view, this makes adding values very easy, one line of code. you provide the context array and the values you want to add to the requirements, and it does the job (the method may also allow to update implementation later maybe by hiding the key in the context)i put it as a static method in that class, but we could have put it elsewhere if we wanted.
i am not so sure to introduce a new context class as you suggested,
probably more elegant in terms of code, but unfortunately it adds even more code (& complexity ?) without really adding a new functionality.i wanted this MR to removes code at the end, i think this is achieved if you do no count comment lines.
so i would rather keep it like this for now. what do you think?
- Status changed to Needs review
5 months ago 2:26pm 15 June 2024 - 🇫🇷France just_like_good_vibes PARIS
ok, i addressed your remark,
created specific classed for context definition and context. It is quite nice actually...
I also kept the method in SourcePluginBase to keep the management of requirements simple from consumer point of view.
please review :) - 🇩🇪Germany Christian.wiedemann
Sorry for the late answer. I was also fine with the solution before. But I think it is better now in sense of more clear. Let's merge!
- 🇫🇷France pdureau Paris
Hi guys,
I am not sure i understand everything in this ticket, but i want to share than I love it, especially 3 stuffs:
- the way you are presenting and organizing the work together
- the way you extend
Drupal\Core\Plugin\Context\Context
andDrupal\Core\Plugin\Context\ContextDefinition
- the removal of specific code in
ui_patterns_field_formatters
&ui_patterns_view
and the addition of generic code inui_patterns
It would be great if every public method is covered by an interface
- By implementing an already existing interface if possible (this is the "dream" target, it worth taking the time of investigating existing interfaces
- Else, by extending or adding a custom interface
For example,
RequirementsContextDefinition::fromRequirements(array $requirements = [], ?string $label = NULL) : RequirementsContextDefinition
is not covered by
ContextDefinitionInterfaceSourcePluginBase::addRequirementsToContext(array $context, array $values): array;
is not described by any interface AFAIK. - 🇫🇷France pdureau Paris
Also, it would be great to document this, especially by updating the (now outdated) schema: https://app.diagrams.net/#G1DdZDq3CYjnkev1aT_kpyrX7oNkk_2kNv#%7B%22pageI...
- 🇫🇷France pdureau Paris
Also, it would be great to document this, especially by updating the (now outdated) schema: https://app.diagrams.net/#G1DdZDq3CYjnkev1aT_kpyrX7oNkk_2kNv#%7B%22pageI...
- 🇩🇪Germany Christian.wiedemann
Hi Piere, both functions are factory functions which are usually not covered by an interface.
So for me
1.RequirementsContextDefinition
andRequirementsContext
is fine without an interface. I like your proposal of an ?additional? factory methodforRequirements(array $requirements = [], ?string $label = NULL)
or forRequirements(array $requirements = [], ?string $label = NULL) .
2. SourcePluginBase::addRequirementsToContext(array $context, array $values): array; could we maybe move also to the
RequirementsContext
class. I "think" factory should belong to the class which is created.
RequirementsContext::attach(RequirementsContext::forRequirements(['field_property']), $contexts)
. - 🇩🇪Germany Christian.wiedemann
Short talk to finalize this. Than we I can rebase my stuff today and also provide the MR for the attribute stuff.
- 🇩🇪Germany Christian.wiedemann
But lets merge. It would be easy to refactor that later.
- 🇫🇷France pdureau Paris
Sure. If you both agree, let's merge. I am just commenting, you are deciding here.
-
Christian.wiedemann →
committed 0cc17941 on 2.0.x authored by
just_like_good_vibes →
Issue #3454615: [2.0.0-alpha3] Improved source plugins organization
-
Christian.wiedemann →
committed 0cc17941 on 2.0.x authored by
just_like_good_vibes →
- Status changed to Fixed
5 months ago 6:36pm 15 June 2024 Automatically closed - issue fixed for 2 weeks with no activity.