You are here

public function LicenseViewsData::getViewsData in Commerce License 8.2

Returns views data for the entity type.

Return value

array Views data in the format of hook_views_data().

Overrides CommerceEntityViewsData::getViewsData

File

src/LicenseViewsData.php, line 15

Class

LicenseViewsData
Provides views data for the License entity type.

Namespace

Drupal\commerce_license

Code

public function getViewsData() {
  $data = parent::getViewsData();
  $base_table = $this->entityType
    ->getBaseTable() ?: $this->entityType
    ->id();
  $data[$base_table]['label'] = [
    'title' => $this
      ->t('Label'),
    'help' => $this
      ->t('The label of the license.'),
    'real field' => 'license_id',
    'field' => [
      'id' => 'commerce_license__entity_label',
    ],
  ];

  // Workaround for core shortcoming.
  // TODO: remove once https://www.drupal.org/node/2337515 is fixed.
  $data[$base_table]['state']['filter']['id'] = 'state_machine_state';
  return $data;
}