We currently have an entity reference field that uses a view. In profiling this view (which returns > 1000 users) I’ve found it to be very slow. My goal was to see if creating a custom selection plugin would help this out.
I currently have:
content_type_course_page.module
/** * Implements hook_ctools_plugin_directory(). */ function content_type_course_page_ctools_plugin_directory($ owner, $ plugin_type) { if ($ owner == 'entityreference' && $ plugin_type == 'selection') { return 'plugins/entityreference_' . $ plugin_type; } }
module_folder/entityreference_selection/content_type_course_page__all_users__selection_plugin.inc
$ plugin = array( 'title' => t('CME all users selection'), 'class' => 'ContentTypeCoursePageSelectionPlugin', );
module_folder/entityreference_selection/ContentTypeCoursePageSelectionPlugin.class.inc
class ContentTypeCoursePageSelectionPlugin extends EntityReference_SelectionHandler_Generic_user { protected function __construct($ field, $ instance = NULL, $ entity_type = NULL, $ entity = NULL) { drupal_debug('a;lsdkja;sfdj'); $ debug = TRUE; parent::__construct($ field, $ instance, $ entity_type, $ entity); } public function entityFieldQueryAlter(SelectQueryInterface $ query) { $ debug = TRUE; parent::entityFieldQueryAlter($ query); //$ query->addTag('add_profile'); } }
My breakpoint is never triggering (at $ debug = TRUE;
), nothing is logged in the drupal_debug
.
When editing the field, I do see “CME all users selection” as an option within Mode of the Entity Selection fieldset but selecting it results in no users being populated and, again, not hitting my debug code or breakpoints.
What have I missed? Maybe I’m completely misunderstanding what selection plugins are capable of doing/meant to do?