You are here

class RedhenContactViewsController in RedHen CRM 7

RedhenContact Views Controller class.

Hierarchy

Expanded class hierarchy of RedhenContactViewsController

1 string reference to 'RedhenContactViewsController'
redhen_contact_entity_info in modules/redhen_contact/redhen_contact.module
Implements hook_entity_info().

File

modules/redhen_contact/lib/redhen_contact.views.inc, line 10
Views controller for RedHen Contacts.

View source
class RedhenContactViewsController extends EntityDefaultViewsController {

  /**
   * Add extra fields to views_data().
   */
  public function views_data() {
    $data = parent::views_data();

    // Base table definition for redhen_contact_user so we can use it for joins.
    $data['redhen_contact_user']['table']['group'] = t('User');
    $data['redhen_contact_user']['table']['join'] = array(
      'redhen_contact' => array(
        'left_field' => 'contact_id',
        'field' => 'contact_id',
        // Only join where the linkage is active.
        'extra' => array(
          array(
            'field' => 'status',
            'value' => '1',
            'operator' => '=',
          ),
        ),
      ),
      'users' => array(
        'left_field' => 'uid',
        'field' => 'uid',
        // Only join where the linkage is active.
        'extra' => array(
          array(
            'field' => 'status',
            'value' => '1',
            'operator' => '=',
          ),
        ),
      ),
    );
    $data['redhen_contact_user']['uid'] = array(
      'group' => t('User'),
      'title' => t('Contact User UID'),
      'help' => t('The user id associated with this contact via redhen_contact_user'),
      'relationship' => array(
        'base' => 'users',
        'base field' => 'uid',
        'handler' => 'views_handler_relationship',
        'label' => t('User'),
        'title' => t('Contact User'),
        'help' => t('The user associated with this contact via redhen_contact_user'),
      ),
      'field' => array(
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    );
    $data['redhen_contact_user']['contact_id'] = array(
      'group' => t('Contact'),
      'title' => t('User Contact ID'),
      'help' => t('The contact id associated with this user via redhen_contact_user'),
      'relationship' => array(
        'base' => 'redhen_contact',
        'base field' => 'contact_id',
        'handler' => 'views_handler_relationship',
        'label' => t('Contact'),
        'title' => t('User Contact'),
        'help' => t('The contact associated with this user via redhen_contact_user'),
      ),
      'field' => array(
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE,
      ),
      'filter' => array(
        'handler' => 'views_handler_filter_numeric',
      ),
      'sort' => array(
        'handler' => 'views_handler_sort',
      ),
    );

    // View link.
    $data['redhen_contact']['link'] = array(
      'title' => t('Link'),
      'help' => t('Provide a simple link to the RedHen Contact.'),
      'field' => array(
        'handler' => 'redhen_contact_views_handler_field_redhen_contact_link',
        'click sortable' => TRUE,
        'real field' => 'contact_id',
        'additional fields' => array(
          'contact_id',
        ),
      ),
    );

    // Edit link.
    $data['redhen_contact']['edit'] = array(
      'title' => t('Edit link'),
      'help' => t('Provide a simple link to edit the RedHen Contact.'),
      'field' => array(
        'handler' => 'redhen_contact_views_handler_field_redhen_contact_link_edit',
        'click sortable' => TRUE,
        'real field' => 'contact_id',
        'additional fields' => array(
          'contact_id',
        ),
      ),
    );

    // Delete link.
    $data['redhen_contact']['delete'] = array(
      'title' => t('Delete link'),
      'help' => t('Provide a simple link to delete the RedHen Contact.'),
      'field' => array(
        'handler' => 'redhen_contact_views_handler_field_redhen_contact_link_delete',
        'click sortable' => TRUE,
        'real field' => 'contact_id',
        'additional fields' => array(
          'contact_id',
        ),
      ),
    );
    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
RedhenContactViewsController::views_data public function Add extra fields to views_data(). Overrides EntityDefaultViewsController::views_data