protected EntityViewsData::mapSingleFieldViewsData($table, $field_name, $field_type, $column_name, $column_type, $first, FieldDefinitionInterface $field_definition)
Provides the views data for a given data type and schema field.
Parameters
string $table: The table of the field to handle.
string $field_name: The machine name of the field being processed.
string $field_type: The type of field being handled.
string $column_name: For fields containing multiple columns, the column name being processed.
string $column_type: Within the field, the column type being handled.
bool $first: TRUE if this is the first column within the field.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.
Return value
array The modified views data field definition.
File
- core/modules/views/src/EntityViewsData.php, line 406
Class
- EntityViewsData
- Provides generic views integration for entities.
Namespace
Drupal\views
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | protected function mapSingleFieldViewsData( $table , $field_name , $field_type , $column_name , $column_type , $first , FieldDefinitionInterface $field_definition ) { $views_field = array (); // Provide a nicer, less verbose label for the first column within a field. // @todo Introduce concept of the "main" column for a field, rather than // assuming the first one is the main column. if ( $first ) { $views_field [ 'title' ] = $field_definition ->getLabel(); } else { $views_field [ 'title' ] = $field_definition ->getLabel() . " ($column_name)" ; } if ( $description = $field_definition ->getDescription()) { $views_field [ 'help' ] = $description ; } // Set up the field, sort, argument, and filters, based on // the column and/or field data type. // @todo Allow field types to customize this. switch ( $field_type ) { // Special case a few field types. case 'timestamp' : case 'created' : case 'changed' : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'date' ; $views_field [ 'filter' ][ 'id' ] = 'date' ; $views_field [ 'sort' ][ 'id' ] = 'date' ; break ; case 'language' : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'language' ; $views_field [ 'filter' ][ 'id' ] = 'language' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; break ; case 'boolean' : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'numeric' ; $views_field [ 'filter' ][ 'id' ] = 'boolean' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; break ; case 'uri' : // Let's render URIs as URIs by default, not links. $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'field' ][ 'default_formatter' ] = 'string' ; $views_field [ 'argument' ][ 'id' ] = 'string' ; $views_field [ 'filter' ][ 'id' ] = 'string' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; break ; case 'text' : case 'text_with_summary' : // Treat these three long text fields the same. $field_type = 'text_long' ; // Intentional fall-through here to the default processing! default : // For most fields, the field type is generic enough to just use // the column type to determine the filters etc. switch ( $column_type ) { case 'int' : case 'integer' : case 'smallint' : case 'tinyint' : case 'mediumint' : case 'float' : case 'double' : case 'decimal' : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'numeric' ; $views_field [ 'filter' ][ 'id' ] = 'numeric' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; break ; case 'char' : case 'string' : case 'varchar' : case 'varchar_ascii' : case 'tinytext' : case 'text' : case 'mediumtext' : case 'longtext' : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'string' ; $views_field [ 'filter' ][ 'id' ] = 'string' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; break ; default : $views_field [ 'field' ][ 'id' ] = 'field' ; $views_field [ 'argument' ][ 'id' ] = 'standard' ; $views_field [ 'filter' ][ 'id' ] = 'standard' ; $views_field [ 'sort' ][ 'id' ] = 'standard' ; } } // Do post-processing for a few field types. $process_method = 'processViewsDataFor' . Container::camelize( $field_type ); if (method_exists( $this , $process_method )) { $this ->{ $process_method }( $table , $field_definition , $views_field , $column_name ); } return $views_field ; } |
Please login to continue.