class PhotosViewsData in Album Photos 6.0.x
Same name and namespace in other branches
- 8.5 src/PhotosViewsData.php \Drupal\photos\PhotosViewsData
Provides the views data for photos module and the photos_image entity type.
Hierarchy
- class \Drupal\views\EntityViewsData implements EntityHandlerInterface, EntityViewsDataInterface uses StringTranslationTrait
- class \Drupal\photos\PhotosViewsData
Expanded class hierarchy of PhotosViewsData
File
- src/
PhotosViewsData.php, line 10
Namespace
Drupal\photosView source
class PhotosViewsData extends EntityViewsData {
/**
* {@inheritdoc}
*/
public function getViewsData() {
$data = parent::getViewsData();
$data['photos_album'] = [];
$data['photos_album']['table'] = [];
$data['photos_album']['table']['group'] = $this
->t('Photos');
$data['photos_album']['table']['provider'] = 'photos';
// Join {node_field_data} and {photos_image_field_data}.
$data['photos_album']['table']['join'] = [
'node_field_data' => [
'left_field' => 'nid',
'field' => 'album_id',
],
'photos_image_field_data' => [
'left_field' => 'album_id',
'field' => 'album_id',
],
];
// Cover ID field.
$data['photos_album']['cover_id'] = [
'title' => $this
->t('Album cover'),
'help' => $this
->t('The album cover image.'),
'field' => [
'id' => 'photos_image_cover',
],
'sort' => [
'id' => 'standard',
],
];
// Album weight.
$data['photos_album']['weight'] = [
'title' => $this
->t('Album weight'),
'help' => $this
->t('The weight of this album.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
// Album image count.
// @todo move out to photos_count table.
$data['photos_album']['count'] = [
'title' => $this
->t('Album image count'),
'help' => $this
->t('The number of images in this album.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
$data['photos_image_field_data']['table']['group'] = $this
->t('Photos');
$data['photos_image_field_data']['table']['provider'] = 'photos';
// Join album info to images.
$data['photos_image_field_data']['table']['join'] = [
'node_field_data' => [
'left_field' => 'nid',
'field' => 'album_id',
],
'photos_album' => [
'left_field' => 'album_id',
'field' => 'album_id',
],
];
// Album node ID table field.
$data['photos_image_field_data']['album_id'] = [
'title' => $this
->t('Album'),
'help' => $this
->t('Album nid.'),
'sort' => [
'id' => 'standard',
],
'relationship' => [
'id' => 'standard',
'base' => 'node_field_data',
'entity type' => 'node',
'base field' => 'nid',
'label' => $this
->t('The album'),
'title' => $this
->t('Album'),
'help' => $this
->t('The album associated with this image.'),
],
'argument' => [
'id' => 'node_nid',
'name field' => 'title',
'numeric' => TRUE,
'validate type' => 'nid',
],
];
// Set as album cover link.
$data['photos_image_field_data']['set_cover'] = [
'field' => [
'title' => $this
->t('Set as album cover link'),
'help' => $this
->t('Provide a link to set this image as the album cover.'),
'id' => 'photos_image_set_cover',
],
];
// Image views count.
$data['photos_count'] = [];
$data['photos_count']['table'] = [];
$data['photos_count']['table']['group'] = $this
->t('Photos');
$data['photos_count']['table']['provider'] = 'photos';
// Join {photos_image_field_data}.
$data['photos_count']['table']['join'] = [
'photos_image_field_data' => [
'left_field' => 'id',
'field' => 'cid',
'extra' => [
[
'field' => 'type',
'value' => 'image_views',
],
],
],
];
$data['photos_count']['value'] = [
'title' => $this
->t('Image views'),
'help' => $this
->t('Number of times this image has been viewed.'),
'field' => [
'id' => 'numeric',
],
'filter' => [
'id' => 'numeric',
],
'sort' => [
'id' => 'standard',
],
];
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityViewsData:: |
protected | property | The entity field manager. | |
EntityViewsData:: |
protected | property | Entity type for this views data handler instance. | |
EntityViewsData:: |
protected | property | The entity type manager. | |
EntityViewsData:: |
protected | property | The field storage definitions for all base fields of the entity type. | |
EntityViewsData:: |
protected | property | The module handler. | |
EntityViewsData:: |
protected | property | The storage used for this entity type. | |
EntityViewsData:: |
protected | property | The translation manager. | |
EntityViewsData:: |
protected | function | Sets the entity links in case corresponding link templates exist. | |
EntityViewsData:: |
public static | function |
Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface:: |
|
EntityViewsData:: |
protected | function | Gets the field storage definitions. | |
EntityViewsData:: |
public | function |
Gets the table of an entity type to be used as base table in views. Overrides EntityViewsDataInterface:: |
|
EntityViewsData:: |
protected | function | Puts the views data for a single field onto the views data. | |
EntityViewsData:: |
protected | function | Provides the views data for a given data type and schema field. | |
EntityViewsData:: |
protected | function | Processes the views data for an entity reference field. | |
EntityViewsData:: |
protected | function | Processes the views data for a language field. | |
EntityViewsData:: |
protected | function | Processes the views data for a text field with formatting. | |
EntityViewsData:: |
protected | function | Processes the views data for a UUID field. | |
EntityViewsData:: |
public | function | Constructs an EntityViewsData object. | |
PhotosViewsData:: |
public | function |
Returns views data for the entity type. Overrides EntityViewsData:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |