You are here

function domain_access_views_data_alter in Domain Access 8

Implements hook_views_data_alter().

File

domain_access/domain_access.module, line 610
Domain-based access control for content.

Code

function domain_access_views_data_alter(array &$data) {
  $table = 'node__' . DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD;
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD]['field']['id'] = 'domain_access_field';
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD . '_target_id']['filter']['id'] = 'domain_access_filter';
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD . '_target_id']['argument']['id'] = 'domain_access_argument';

  // Current domain filter.
  $data[$table]['current_all'] = [
    'title' => t('Current domain'),
    'group' => t('Domain'),
    'filter' => [
      'field' => DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD . '_target_id',
      'id' => 'domain_access_current_all_filter',
      'title' => t('Available on current domain'),
      'help' => t('Filters out nodes available on current domain (published to current domain or all affiliates).'),
    ],
  ];

  // Since domains are not stored in the database, relationships cannot be used.
  unset($data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD]['relationship']);

  // Set the user data.
  $table = 'user__' . DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD;
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD]['field']['id'] = 'domain_access_field';
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD . '_target_id']['filter']['id'] = 'domain_access_filter';
  $data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD . '_target_id']['argument']['id'] = 'domain_access_argument';

  // Since domains are not stored in the database, relationships cannot be used.
  unset($data[$table][DomainAccessManagerInterface::DOMAIN_ACCESS_FIELD]['relationship']);
}