You are here

class GroupMembershipViewsController in Group 7

Controller for generating Views data for Group memberships.

Hierarchy

Expanded class hierarchy of GroupMembershipViewsController

1 string reference to 'GroupMembershipViewsController'
group_entity_info in ./group.entity.inc
Implements hook_entity_info().

File

classes/group_membership.views_controller.inc, line 10
Defines the Entity API Views controller class for group memberships.

View source
class GroupMembershipViewsController extends EntityDefaultViewsController {

  /**
   * Add group entity relationships to groups.
   */
  public function views_data() {
    $data = parent::views_data();
    $data['group_membership']['role'] = array(
      'title' => t('Group role'),
      'help' => t('The granted group roles for a membership.'),
      'real field' => 'mid',
      // We do not add this field onto the {group_membership_role} table,
      // because the handler only requires the selected mids which it then
      // uses in a subquery to avoid duplicate rows. For more info, read the
      // handler's class documentation.
      'field' => array(
        'handler' => 'group_handler_field_membership_role',
        'no group by' => TRUE,
      ),
      'relationship' => array(
        'handler' => 'group_handler_relationship_membership_role',
        'label' => t('Membership role'),
        'base' => 'group_role',
      ),
    );

    // Define the many-to-many table so we can filter on group roles without
    // having to create a relationship first.
    $data['group_membership_role']['table'] = array(
      'group' => t('Group membership'),
      'join' => array(
        'group_membership' => array(
          'left_field' => 'mid',
          'field' => 'mid',
        ),
      ),
    );
    $data['group_membership_role']['role'] = array(
      'title' => t('Group role'),
      'help' => t('The granted group roles for a membership.'),
      'filter' => array(
        'handler' => 'group_handler_filter_membership_role',
        'allow empty' => TRUE,
      ),
    );
    return $data;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDefaultViewsController::$type protected property
EntityDefaultViewsController::getRelationshipHandlerClass public function Determines the handler to use for a relationship to an entity type.
EntityDefaultViewsController::map_from_schema_info protected function Comes up with views information based on the given schema and property info.
EntityDefaultViewsController::optionsListCallback public static function A callback returning property options, suitable to be used as views options callback.
EntityDefaultViewsController::schema_fields protected function Try to come up with some views fields with the help of the schema and the entity property information.
EntityDefaultViewsController::schema_revision_fields protected function Try to come up with some views fields with the help of the revision schema and the entity property information.
EntityDefaultViewsController::__construct public function
GroupMembershipViewsController::views_data public function Add group entity relationships to groups. Overrides EntityDefaultViewsController::views_data