Click sorting, filters and sorts are disabled for non-database fields. But one might want to use a custom handler to support this functionality for fields which are provided by by for instance hook_entity_property_info_alter(). Below is a patch which allows users to register their custom handler is the entity metadata.

Example of usage:

function my_module_entity_property_info_alter(&$info) {
  $properties = &$info['my_entity']['properties'];
  $properties['under-age'] = array(
    'label' => t('Is under-age'),
    'type' => 'boolean',
    'description' => t('Boolean value indicting whether the person is under-age.'),
    'getter callback' => 'my_module_entity_getter_callback',
    'views' => array(
      'filter' => 'my_module_filter_under_age',
    ),
  );
}

Full support for entity metadata must imho be a goal of efq_views. As far is a know there is no other (simpler) way to achieve this.
Thanx in advance for reviewing!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bojanz’s picture

Status: Active » Postponed

I agree in principle.
However, let's first wait for #1077148: add an entity-view row plugin to land in Entity API, because I'm attempting the same thing there (keys in the metadata to override the handlers determined by Entity API)

colan’s picture

Issue summary: View changes
Status: Postponed » Needs review

I support we can reopen this now that the other issue is closed (fixed)?

I need to figure this out for my current project so I'll see if the above patch (now 3 years old) is still useful.

colan’s picture

Status: Needs review » Needs work

The above patch applies cleanly, but that's misleading, as errors like this start showing up:
Invalid argument supplied for foreach() efq_views.views.inc:184

The code looks like it's supposed to be inserted into _efq_views_get_property_data(), but that function no longer exists.

As mentioned above, we may not need this as it looks like it can be done through the Entity API as per Views integration. I'll try that and see what happens. If it works, we can close this.

colan’s picture

Title: Allow entity metadata to specify custom view handlers » Add support for custom Views handlers
Assigned: Unassigned » colan

The Entity API approach doesn't work because it combines both the EFQ filter and the custom filter into an array. This of course causes problems because code further down the line is expecting a class name string, not an array.

I'll try to come up with a solution for this.

colan’s picture

Status: Needs work » Needs review
FileSize
1.99 KB

The problem is the array_merge_recursive() call when combining data from this module and the Entity API. The latter processes the custom views_data() methods.

So the fix is to rework the above patch for modern times. See attached.

  • Commit d2e1537 on 7.x-1.x authored by xatoo, committed by colan:
    Issue #1138542 by xatoo, colan: Added support for custom Views handlers.
    
colan’s picture

Status: Needs review » Fixed

Now in dev.

  • Commit 19bb87a on 7.x-1.x by colan:
    Issue #1138542 by colan: Added support for custom contextual filters as...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.