Closed (fixed)
Project:
Facets
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Jun 2016 at 06:17 UTC
Updated:
25 Jul 2016 at 15:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
borisson_Hi Jasper,
I found a couple of things that are not up to the drupal standards, I fixed those myself in the attached patch. We'll be committing a few issues today, and I think this'll get in as well. Thanks for the patch!
Comment #5
borisson_@LammensJ, because the test was no in the correct namespace earlier, it wasn't executed. Can you fix the test fails?
Comment #6
lammensj commentedYep, my bad.
Comment #9
lammensj commented*grmmbl* Drupal using its own deprecated functions... *grmmbl*
Comment #12
lammensj commentedHad some problems with PHPUnit on my laptop. Tests are successful now :)
Comment #13
borisson_Awesome, thanks!
Comment #14
borisson_Can we change the current taxonomy term processor to an entity processor and use entity::load instead? If possible useing loadMultiple as well to have less individual loads.
Comment #15
lammensj commentedThe patch includes the all new TranslateEntityProcessor. I didn't replace the previous ones just yet because I'm not sure if this implementation is the way to go... The processor requires that you specify the entity type when selecting it. I needed to add that because EntityTypeManager->loadMultiple asks for one. Makes sense if you think about it, but it was rather hard to find a way to provide this.
I could have loaded the index and retrieved it from there. That should have been the solution in D7, but not in D8 where you can select multiple types of datasource. In other words, take a look at the file and tell me what you think.
Comment #16
nick_vhYou can actually find it through the index. Since a field cannot be shared across entity types you can look up the entity type in the storage of the field.
So: facet processor -> datasource -> index -> field -> storage -> fetch entity type. Unless I'm missing something here? Discussed this briefly with drunkenmonkey and borisson
Comment #17
lammensj commentedHi Nick!
I did look in that direction before switching to the configuration form solution. It's just that when you call $facet->getFacetSource(), it will return a FacetSourcePluginInterface object. Can we be sure that this will always be a View?
Comment #18
borisson_It won't always be a view, we also support drupal core and search_api_page as facet sources, they don't have that.
Comment #19
lammensj commentedThat's what I was thinking... Anyway, the interdiff will show the proposed solution to find the entity type and it works :)
Comment #20
mpp commentedHadn't seen this issue so I made another try at this in https://www.drupal.org/node/2760401.
I made some small tweaks to #20:
- added . at the end of a comment
- load entity_type the same way as in ListItemProcessor::build()
- don't set setDisplayValue twice
Quick questions though: why do we have three processors (entity, node, term) while they're all entities?
Comment #21
mpp commentedComment #22
borisson_That makes sense, it should be sufficient if we only have an entity processor.
Comment #23
mpp commentedComment #24
mpp commentedComment #27
mpp commentedGuess I'll have to mock the language_manager and entity_type.manager aswell.
Comment #28
mpp commentedInjected services:
- language_manager
- entity_type.manager
WIP, still needs testing.
Comment #29
mpp commentedMocking all dependencies is tricky. But I noticed $source->getIndex() is based upon SearchApiFacetSourceInterface and thus only available for SearchApiViews, correct?
Comment #30
mpp commentedComment #31
mpp commentedComment #32
borisson_I fixed some coding style things and added extra documentation.
This looks great overall. I'd love to hear from @LammensJ if this also works in his usecase, if it does, we can commit this.
Comment #33
mpp commentedThanks for the review!
Comment #34
lammensj commentedToo bad we have to rely on the SearchApiFacetSourceInterface class to get the entity type. I guess that's an api change in Search Api if we want to remove that if. @borisson_, @Nick_vh, correct me if I'm wrong.
I also removed the switch-statement for rendering the title. Since every term or node descends from the Entity class, we can just use $object->label().
Furthermore, it works in my use case. No errors and no warning, so good job!
Comment #37
borisson_That is too bad, I agree. But this is not because of search api, but because we also support creating facets for drupal core. And because core's search doesn't have an "index" concept we have write the check.
I'll have a look at the test-failures tonight and when those are resolved, we can commit this. Thanks for the review and for removing the switch @LammensJ, that looks great!
Comment #38
lammensj commentedThe tests broke because of the getTitle- and getName-usages which were removed.
Comment #39
lammensj commentedComment #42
lammensj commentedWrong patch source, my bad.
Comment #43
lammensj commentedComment #44
borisson_Awesome, committing this later today.
Comment #46
borisson_Committed, thanks everyone!