Closed (fixed)
Project:
Entity reference
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
1 May 2012 at 12:46 UTC
Updated:
24 May 2012 at 08:50 UTC
Jump to comment: Most recent file
Comments
Comment #1
itamar commentedPatch alters entityreference_options_list to accept entity_type and entity arguments.
Comment #2
damien tournoud commentedThat makes sense.
Let's make those optional too, to make sure people understand that they might not be available.
Comment #3
itamar commentedThe $entity_type and $entity arguments in the constructor actually are optional, because the constructor is invoked using getInstance() which has default values for them;
Comment #4
damien tournoud commentedI know, but let's make those optional too, to make sure people understand that they might not be available :)
Comment #5
itamar commentedAmending the previous patch; Setting default values in EntityReference_SelectionHandler_Generic::_construct().
Comment #6
amitaibu#1541672: Don't check "create" access in OgSelectionHandler::buildEntityFieldQuery() now depends on this.
Comment #7
damien tournoud commentedThinking about this more, shouldn't we just add $entity_type and $entity as (optional) parameters to the
->getReferencableEntities()? Amitai, any thoughts?Comment #8
amitaibu> shouldn't we just add $entity_type and $entity as (optional) parameters to the ->getReferencableEntities()?
Indeed, at the beginning I thought about this option, however, I was thinking it is possible that one would call also
validateReferencableEntities()needing the entity. Maybe also onentityFieldQueryAlter().So I think that the proposed solution is more future proof to feature requests.
Comment #9
damien tournoud commentedOk, in that case, we need to fix or remove the caching in
entityreference_get_selection_handler(). I just removed it in the attached patch and added some more context where we have it.We still need to figure out how to pass the entity context to
entityreference_autocomplete_callback().Comment #10
amitaibu> we need to fix or remove the caching in entityreference_get_selection_handler()
Damz, what do you think about this caching? (attached interdiff)
Comment #12
damien tournoud commentedI started writing something like that, then decided that it was not worth it. We can decide later, can we focus on the autocomplete callback?
Comment #13
amitaibuPatch (based on #9 -- without objet cache) adds optional $entity to autocomplete.
Comment #15
damien tournoud commented#13 looks good to me on visual inspection. Let's move forward with it and tag a rc2.
Comment #16
damien tournoud commentedI ended up committing the following patch with some minor fixes.
Comment #17
amitaibuIs this a debug leftover?
Comment #18
amitaibu#17 seems to be fixed -- http://drupalcode.org/project/entityreference.git/commitdiff/099f8e94216...
Comment #19
damien tournoud commentedIt was, I quickly tested what happens with unsaved entities. I caught it in time :)