Problem/Motivation
We need to store facet-source specific configuration e.g. the url processor configuration.
Why we need this
By default, the facets should use f[0]=article&f[1]=admin
when 2 facets are present on a page (bundle / author).
When more than one facet source is used on a page, (e.g. block views) we should be able to configure a different parameter for facets.
An example of such a url could be f[0]=article&f[1]=admin&facet[0]=blog_item
. We need to configure the key for these in a setting that is linked to a facetSource; that's where it belongs.
We'd like to avoid creating an entity just for that though, that would lead into a whole other world of problems (since all facetSources come from derivers we'd need to hook in to other modules's save events, ...).
Proposed resolution
We would like to create a default configuration that is overridable per facet source.
We can use this to store global facet source settings, the config will only exist for facet sources which do not use the default configuration.
Remaining tasks
Introduce a new configuration for the facetSourceMake sure that we're using the configuration in a facetChange the UI to add the ability to change this the settings. (add an edit button per facet source)
User interface changes
We should have an edit button for a facet source.
Comment | File | Size | Author |
---|---|---|---|
#21 | interdiff.txt | 1.32 KB | borisson_ |
#21 | add_a_storage_for-2612090-21.patch | 37.52 KB | borisson_ |
Comments
Comment #2
borisson_Updated IS.
Comment #3
borisson_Updated IS.
Comment #4
borisson_I started work on this yesterday and just committed and pushed that work to a new branch: http://cgit.drupalcode.org/sandbox-mikeker-2348769/log/?h=2612090--facet..., when I get further I will continue to push to that branch until I think this is ready for review.
Comment #5
borisson_Updated IS with current progress and added a link to github's diff view for better reviewing https://github.com/nickveenhof/facetapi/compare/8.x-1.x...2612090--facet...
Comment #6
borisson_Status update:
I created a new configuration for facet sources (
config/schema/facetapi.facet_source.schema.yml
) and a default setting (f) forfilter_key
, defined in that config. I added a new configuration for per facet source that saves into that config.I also changed the QueryStringUrlProcessor (the only current url processor) to use that config for the filter key and I made sure the unit test for that processor still passes.
I also extended the QueryStringUrlProcessorUnitTest to ensure the newly added functionality works as expected.
Those pieces of the puzzle work. The next part of this issue however doesn't work yet.
I created a
src/Config/FacetSourceConfigOverride
and related events modelled afterLanguageConfigOverride
but I still have no idea how that actually integrates with our code.You can look at the latest interdiff on github
Comment #7
borisson_So; a config override can override every config defined in the system, this is not something we need or want to do. Looks like we went overboard a little with that idea.
Attached is a working patch.
Comment #8
Nick_vhMissing a dot?
Comment longer than 80 chars
If we do not provide the cache param, does that mean it might be cached indefinitely? Should we add that here so that people understand why?
Is there a way how we can make this "pattern" more global so that we don't have to have internal knowledge where this is referenced but rather get a certain class variable / constant that defines what the pattern is? It's "antfucking" but I don't like it that we do this concatenation in multiple places.
Isn't there a convention that we can wrap this text in multiple lines? It mentions "Unless you are fully aware of why etc... but it doesn't really mention what happens unless. Please rewrite to be more clear.
Should we check if it is_null? what if it is empty but not null?
Can this form value ever be invalid as a configkey string? Any sanitization we need to add?
How is this related to this patch?
I'd remove this new line
Another "dark magic concatenation"
Comment #9
borisson_Attached a new update.
Fixes #8.1, .2, .3, .5
.4, .10 I made it a little bit more sane.
.6 I don't think so.
.7 It's a hidden field from a machine name. So it should always be valid.
I also removed some unrelated changes.
Comment #10
StryKaizerMaybe this documentation is too technical and not really needed for sitebuilders, we could add it in the code though?
In here we can maybe add something more basic like : "Global settings for this facet source and all facets belonging to it." or just leave it out.
Maybe as description: "The key used in the url to identify the facet source. When using multiple facet sources you should make sure each facet source has a different filter key."
One global remark.
Using the overrides system creates only 1 file for facetsource configuration when exporting config.
This *might* make this configuration more conflict-prone. Not sure if this issue is big enough to change the design though, facetsource overrides shouldnt happen often?
It would be nice if every override lived in their own configuration file though ;)
Comment #11
StryKaizerComment #12
borisson_Attached is a reroll, this also fixes the remarks from #10.
I discussed this with @swentel at the DUGBE sprint in antwerp and we figure this configuration is probably the best we can do. The configuration will not be conflictprone, because the config entities the depends on are also defined in code.
Comment #13
borisson_Uploaded the wrong patch in #12.
Comment #14
borisson_As I mentioned in #12, I discussed this storage with @swentel at the DUGBE sprint and I'd like to elaborate on that.
Currently, we're using one storage to save all the configuration for all of the facet sources. This is a lot easier as a solution compared to creating a config entity. One thing we need to keep in mind is that we have to remove configuration from the config-object when a plugin is removed.
I'm not sure how we should do that, and if we don't, how much this'll hurt us.
Comment #15
StryKaizerLet's discuss this tonight.
IMO we can not allow stale configuration at all, so we will need to find out a clean way on how to delete overridden config for non-existant facet sources.
Comment #16
borisson_We discussed this at last night's hangout and decided that we should go for a config entity anyway.
Comment #17
borisson_Patch has a config entity now
Comment #18
borisson_Reviewed my own patch again, there looks to be sufficient test coverage and everything works as expected.
Comment #19
Nick_vhtypo. Should be through. Also it mentions twice "on", probably should be create it on the fly
does Drupal code standards allow short-hand arrays here? I am still confused what the recommendation is.
same typo
More English typos. "This is handled for us". Also I do think this needs more clarifications what "usually" means and where an example can be seen.
Comment #20
Nick_vhComment #21
borisson_Fixed remarks made in #19.
Comment #22
borisson_Regarding #19.2: #2135291: [Policy, no patch] PHP 5.4 short array syntax coding standards for Drupal 8 mentions no final statement; as far as I can see. So that means we can use short array syntax everywhere in facets. Search API has decided against this but facets hasn't.
Comment #23
borisson_Back to NR, as the latest patch addresses all issues.
Comment #25
borisson_