2009-05-17 11:16:51 +00:00
< ? php
/**
* @ file
2013-11-20 18:38:33 +00:00
* Provide views data that isn ' t tied to any other module .
2009-05-17 11:16:51 +00:00
*/
2014-02-02 20:06:53 +00:00
use Drupal\system\ActionConfigEntityInterface ;
2009-05-17 11:16:51 +00:00
/**
* Implements hook_views_data () .
*/
2012-08-19 13:19:00 +00:00
function views_views_data () {
$data [ 'views' ][ 'table' ][ 'group' ] = t ( 'Global' );
$data [ 'views' ][ 'table' ][ 'join' ] = array (
2014-06-09 14:50:45 +00:00
// #global is a special flag which allows a table to appear all the time.
2012-08-19 13:19:00 +00:00
'#global' => array (),
);
2009-05-17 11:16:51 +00:00
2012-08-19 13:19:00 +00:00
$data [ 'views' ][ 'random' ] = array (
'title' => t ( 'Random' ),
'help' => t ( 'Randomize the display order.' ),
'sort' => array (
'id' => 'random' ,
),
);
2009-05-17 11:16:51 +00:00
$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 (
2012-08-11 11:46:07 +00:00
'id' => 'null' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views' ][ 'nothing' ] = array (
'title' => t ( 'Custom text' ),
'help' => t ( 'Provide custom text or link.' ),
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'custom' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views' ][ 'counter' ] = array (
'title' => t ( 'View result counter' ),
'help' => t ( 'Displays the actual position of the view result' ),
'field' => array (
2012-08-11 11:46:07 +00:00
'id' => 'counter' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views' ][ 'area' ] = array (
'title' => t ( 'Text area' ),
'help' => t ( 'Provide markup text for the area.' ),
'area' => array (
2012-08-11 11:46:07 +00:00
'id' => 'text' ,
2009-05-17 11:16:51 +00:00
),
);
2012-07-29 21:44:28 +00:00
$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 (
2012-08-11 11:46:07 +00:00
'id' => 'text_custom' ,
2012-07-29 21:44:28 +00:00
),
);
2012-07-17 16:56:36 +00:00
2012-10-10 18:01:37 +00:00
$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' ,
2012-10-17 16:31:40 +00:00
'sub_type' => 'empty' ,
2012-10-10 18:01:37 +00:00
),
);
2009-05-17 11:16:51 +00:00
$data [ 'views' ][ 'view' ] = array (
'title' => t ( 'View area' ),
'help' => t ( 'Insert a view inside an area.' ),
'area' => array (
2012-08-11 11:46:07 +00:00
'id' => 'view' ,
2009-05-17 11:16:51 +00:00
),
);
$data [ 'views' ][ 'result' ] = array (
'title' => t ( 'Result summary' ),
'help' => t ( 'Shows result summary, for example the items per page.' ),
'area' => array (
2012-08-11 11:46:07 +00:00
'id' => 'result' ,
2009-05-17 11:16:51 +00:00
),
);
2014-04-25 22:09:06 +00:00
$data [ 'views' ][ 'messages' ] = array (
'title' => t ( 'Messages' ),
'help' => t ( 'Displays messages in an area.' ),
'area' => array (
'id' => 'messages' ,
),
);
2013-08-02 13:26:16 +00:00
$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' ,
),
);
2009-05-17 11:16:51 +00:00
$data [ 'views' ][ 'combine' ] = array (
'title' => t ( 'Combine fields filter' ),
'help' => t ( 'Combine two fields together and search by them.' ),
'filter' => array (
2012-08-11 11:46:07 +00:00
'id' => 'combine' ,
2009-05-17 11:16:51 +00:00
),
);
2012-12-17 22:38:55 +00:00
$data [ 'views' ][ 'dropbutton' ] = array (
'title' => t ( 'Dropbutton' ),
'help' => t ( 'Display fields in a dropbutton.' ),
'field' => array (
'id' => 'dropbutton' ,
),
);
2013-03-10 07:00:51 +00:00
// Registers an entity area handler per entity type.
2014-02-10 09:24:05 +00:00
foreach ( \Drupal :: entityManager () -> getDefinitions () as $entity_type_id => $entity_type ) {
2014-06-09 14:50:45 +00:00
// Excludes entity types, which cannot be rendered.
2014-02-10 09:24:05 +00:00
if ( $entity_type -> hasViewBuilderClass ()) {
$label = $entity_type -> getLabel ();
$data [ 'views' ][ 'entity_' . $entity_type_id ] = array (
2013-03-10 07:00:51 +00:00
'title' => t ( 'Rendered entity - @label' , array ( '@label' => $label )),
'help' => t ( 'Displays a rendered @label entity in an area.' , array ( '@label' => $label )),
'area' => array (
2014-02-10 09:24:05 +00:00
'entity_type' => $entity_type_id ,
2013-03-10 07:00:51 +00:00
'id' => 'entity' ,
),
);
}
}
2014-02-02 20:06:53 +00:00
// Registers an action bulk form per entity.
foreach ( \Drupal :: entityManager () -> getDefinitions () as $entity_type => $entity_info ) {
2014-03-27 11:54:40 +00:00
$actions = array_filter ( \Drupal :: entityManager () -> getStorage ( 'action' ) -> loadMultiple (), function ( ActionConfigEntityInterface $action ) use ( $entity_type ) {
2014-02-02 20:06:53 +00:00
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' ,
),
);
}
2009-05-17 11:16:51 +00:00
return $data ;
}