Created
October 10, 2017 21:15
-
-
Save cyberlex404/4cd1c55b62cf75d4f855cad9d6459ada to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace Drupal\housing\Entity; | |
| use Drupal\views\EntityViewsData; | |
| /** | |
| * Provides Views data for Housing entities. | |
| */ | |
| class HousingViewsData extends EntityViewsData { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function getViewsData() { | |
| $data = parent::getViewsData(); | |
| // Additional information for Views integration, such as table joins, can be | |
| // put here. | |
| // subscription__housings | |
| $data['housing']['subscription'] = [ | |
| 'title' => $this->t('Subscription reverse'), | |
| 'help' => $this->t('Subscription to a Housing.'), | |
| 'field_name ' => 'name_subscription', | |
| 'relationship' => [ | |
| 'field table' => 'subscription__housings', | |
| 'field field' => 'housings_target_id', | |
| 'field_name ' => 'name', | |
| 'id' => 'entity_reverse', | |
| 'base' => 'subscription', | |
| 'base field' => 'id', | |
| 'label' => $this->t('Subscription reverse'), | |
| ], | |
| ]; | |
| /* | |
| $data['{MAIN ENTITY BASE TABLE}']['{useful non-conflicting name - I used the {RELATED ENTITY BASE TABLE}}'] = [ | |
| 'title' => t('{some useful title that displays in Add Relationships popup}'), | |
| 'help' => t('{some useful description that displays in Add Relationships popup}'), | |
| 'relationship' => [ | |
| 'field table' => '{name of intermediary table - it is probably {RELATED ENTITY}__{FIELD NAME}', | |
| 'field field' => '{name of intermediary field - it is probably {FIELD NAME}_target_id', | |
| 'base' => '{RELATED ENTITY BASE TABLE}', | |
| 'base field' => '{RELATED ENTITY ID FIELD}', | |
| 'id' => 'entity_reverse', | |
| 'label' => '{some useful label that displays in Relationship select in various views field settings popups}', | |
| ], | |
| ]; | |
| */ | |
| return $data; | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Notice: Undefined index: field_name in Drupal\views\Plugin\views\relationship\EntityReverse->query()