class JSONViews in JSON Field 8
Class JSONViews.
@package Drupal\json_field
Hierarchy
- class \Drupal\json_field\JSONViews implements JSONViewsInterface uses StringTranslationTrait
Expanded class hierarchy of JSONViews
1 string reference to 'JSONViews'
1 service uses JSONViews
File
- src/
JSONViews.php, line 13
Namespace
Drupal\json_fieldView source
class JSONViews implements JSONViewsInterface {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function getViewsFieldData(FieldStorageConfigInterface $field_storage) {
// Make sure views.views.inc is loaded.
module_load_include('inc', 'views', 'views.views');
// Get the default data from the views module.
$data = views_field_default_views_data($field_storage);
$field_name = $field_storage
->getName();
$value_field_name = $field_name . '_value';
$entity_entry = $field_storage
->getTargetEntityTypeId() . '__' . $field_name;
if (!empty($data[$entity_entry][$value_field_name])) {
$data[$entity_entry][$field_name . '_json_value'] = [
'group' => $data[$entity_entry][$value_field_name]['group'],
'title' => $this
->t('@value_title (data)', [
'@value_title' => $data[$entity_entry][$value_field_name]['title'],
]),
'title short' => $data[$entity_entry][$value_field_name]['title short'],
'help' => $data[$entity_entry][$value_field_name]['help'],
'field' => $data[$entity_entry][$field_name]['field'],
];
$data[$entity_entry][$field_name . '_json_value']['field']['id'] = 'json_data';
}
return $data;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JSONViews:: |
public | function |
Gets the views data for a field instance. Overrides JSONViewsInterface:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. |