views_views_data()
Implements hook_views_data().
File
- core/modules/views/views.views.inc, line 19
- Provide views data that isn't tied to any other module.
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 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | function views_views_data() { $data [ 'views' ][ 'table' ][ 'group' ] = t( 'Global' ); $data [ 'views' ][ 'table' ][ 'join' ] = array ( // #global is a special flag which allows a table to appear all the time. '#global' => array (), ); $data [ 'views' ][ 'random' ] = array ( 'title' => t( 'Random' ), 'help' => t( 'Randomize the display order.' ), 'sort' => array ( 'id' => 'random' , ), ); $data [ 'views' ][ 'null' ] = array ( 'title' => t( 'Null' ), 'help' => t( 'Allow a contextual filter value to be ignored. The query will not be altered by this contextual filter value. Can be used when contextual filter values come from the URL, and a part of the URL needs to be ignored.' ), 'argument' => array ( 'id' => 'null' , ), ); $data [ 'views' ][ 'nothing' ] = array ( 'title' => t( 'Custom text' ), 'help' => t( 'Provide custom text or link.' ), 'field' => array ( 'id' => 'custom' , ), ); $data [ 'views' ][ 'counter' ] = array ( 'title' => t( 'View result counter' ), 'help' => t( 'Displays the actual position of the view result' ), 'field' => array ( 'id' => 'counter' , ), ); $data [ 'views' ][ 'area' ] = array ( 'title' => t( 'Text area' ), 'help' => t( 'Provide markup text for the area.' ), 'area' => array ( 'id' => 'text' , ), ); $data [ 'views' ][ 'area_text_custom' ] = array ( 'title' => t( 'Unfiltered text' ), 'help' => t( 'Add unrestricted, custom text or markup. This is similar to the custom text field.' ), 'area' => array ( 'id' => 'text_custom' , ), ); $data [ 'views' ][ 'title' ] = array ( 'title' => t( 'Title override' ), 'help' => t( 'Override the default view title for this view. This is useful to display an alternative title when a view is empty.' ), 'area' => array ( 'id' => 'title' , 'sub_type' => 'empty' , ), ); $data [ 'views' ][ 'view' ] = array ( 'title' => t( 'View area' ), 'help' => t( 'Insert a view inside an area.' ), 'area' => array ( 'id' => 'view' , ), ); $data [ 'views' ][ 'result' ] = array ( 'title' => t( 'Result summary' ), 'help' => t( 'Shows result summary, for example the items per page.' ), 'area' => array ( 'id' => 'result' , ), ); $data [ 'views' ][ 'messages' ] = array ( 'title' => t( 'Messages' ), 'help' => t( 'Displays messages in an area.' ), 'area' => array ( 'id' => 'messages' , ), ); $data [ 'views' ][ 'http_status_code' ] = array ( 'title' => t( 'Response status code' ), 'help' => t( 'Alter the HTTP response status code used by this view, mostly helpful for empty results.' ), 'area' => array ( 'id' => 'http_status_code' , ), ); $data [ 'views' ][ 'combine' ] = array ( 'title' => t( 'Combine fields filter' ), 'help' => t( 'Combine multiple fields together and search by them.' ), 'filter' => array ( 'id' => 'combine' , ), ); $data [ 'views' ][ 'dropbutton' ] = array ( 'title' => t( 'Dropbutton' ), 'help' => t( 'Display fields in a dropbutton.' ), 'field' => array ( 'id' => 'dropbutton' , ), ); // Registers an entity area handler per entity type. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type ) { // Excludes entity types, which cannot be rendered. if ( $entity_type ->hasViewBuilderClass()) { $label = $entity_type ->getLabel(); $data [ 'views' ][ 'entity_' . $entity_type_id ] = array ( 'title' => t( 'Rendered entity - @label' , array ( '@label' => $label )), 'help' => t( 'Displays a rendered @label entity in an area.' , array ( '@label' => $label )), 'area' => array ( 'entity_type' => $entity_type_id , 'id' => 'entity' , ), ); } } // Registers an action bulk form per entity. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type => $entity_info ) { $actions = array_filter (\Drupal::entityManager()->getStorage( 'action' )->loadMultiple(), function (ActionConfigEntityInterface $action ) use ( $entity_type ) { return $action -> getType () == $entity_type ; }); if ( empty ( $actions )) { continue ; } $data [ $entity_info ->getBaseTable()][ $entity_type . '_bulk_form' ] = array ( 'title' => t( 'Bulk update' ), 'help' => t( 'Allows users to apply an action to one or more items.' ), 'field' => array ( 'id' => 'bulk_form' , ), ); } // Registers views data for the entity itself. foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type ) { if ( $entity_type ->hasHandlerClass( 'views_data' )) { /** @var \Drupal\views\EntityViewsDataInterface $views_data */ $views_data = \Drupal::entityManager()->getHandler( $entity_type_id , 'views_data' ); $data = NestedArray::mergeDeep( $data , $views_data ->getViewsData()); } } // Field modules can implement hook_field_views_data() to override the default // behavior for adding fields. $module_handler = \Drupal::moduleHandler(); $entity_manager = \Drupal::entityManager(); if ( $entity_manager ->hasDefinition( 'field_storage_config' )) { /** @var \Drupal\field\FieldStorageConfigInterface $field_storage */ foreach ( $entity_manager ->getStorage( 'field_storage_config' )->loadMultiple() as $field_storage ) { if (_views_field_get_entity_type_storage( $field_storage )) { $result = ( array ) $module_handler ->invoke( $field_storage ->getTypeProvider(), 'field_views_data' , array ( $field_storage )); if ( empty ( $result )) { $result = views_field_default_views_data( $field_storage ); } $module_handler ->alter( 'field_views_data' , $result , $field_storage ); if ( is_array ( $result )) { $data = NestedArray::mergeDeep( $result , $data ); } } } } return $data ; } |
Please login to continue.