Unable to override ctools selection plugin class from my module I am trying to add a custom ctools selection plugin for entity reference field as explained Here but it is never bing called but it is calling the parent class (EntityReference_SelectionHandler_Generic). Following is my code.

1) Implements hook_ctools_plugin_directory

function mymodule_ctools_plugin_directory($module, $plugin) {

   if ($module == 'entityreference') {
    dsm($plugin);
    return 'plugins/' . $plugin;
  }
 }


Than I created "plugins/selection" folder in my module directory following is the code I have in this file respectively-

1) Base.inc

$plugin = array(
'title' =&gt; t('Simple (with optional filter by bundle)'),
'class' =&gt; 'myClass',
'weight' =&gt; -100,
);


2) myClass.class.php

class myClass extends EntityReference_SelectionHandler_Generic{
public static function getInstance($field, $instance = NULL, $entity_type = NULL, $entity = NULL) {
watchdog('getInstance', "print something for test ");
return new ExampleSelectionHandler($field, $instance, $entity_type,  $entity);


}
public function buildEntityFieldQuery($match = NULL, $match_operator =CONTAINS'){
}
}

But Myclass is never getting called instate it is calling the
 parent class(I have added a watchdog in that class).
same problem, two days wasted according to http://lookalive.co.uk/blog/drupal-entity-reference-how-make-custom-entity-reference-selection-handler and all it's copies.

entityreference_get_selection_handler() code dpm() showed that "*.inc" should be named 'base.inc' as in your case.

After renaming in my case *class.php started to execute.

So all i can advice to you - check if module has higher weight than 'entityreference' module, see here https://www.drupal.org/node/110238

And add the first line to '*class.php' (for inheritance)

require_once drupal_get_path('module', 'entityreference') . '/plugins/selection/EntityReference_SelectionHandler_Generic.class.php';


If this helped to you - pleace vote [+] this answer (i need more scores, tks)