2015-08-17 17:00:26 -07:00
< ? php
namespace Drupal\taxonomy ;
use Drupal\views\EntityViewsData ;
/**
* Provides the views data for the taxonomy entity type .
*/
class TermViewsData extends EntityViewsData {
/**
* { @ inheritdoc }
*/
public function getViewsData () {
$data = parent :: getViewsData ();
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'table' ][ 'base' ][ 'help' ] = $this -> t ( 'Taxonomy terms are attached to nodes.' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_field_data' ][ 'table' ][ 'base' ][ 'access query tag' ] = 'term_access' ;
$data [ 'taxonomy_term_field_data' ][ 'table' ][ 'wizard_id' ] = 'taxonomy_term' ;
$data [ 'taxonomy_term_field_data' ][ 'table' ][ 'join' ] = array (
// This is provided for the many_to_one argument.
'taxonomy_index' => array (
'field' => 'tid' ,
'left_field' => 'tid' ,
),
);
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'help' ] = $this -> t ( 'The tid of a taxonomy term.' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'argument' ][ 'id' ] = 'taxonomy' ;
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'argument' ][ 'name field' ] = 'name' ;
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'argument' ][ 'zero is null' ] = TRUE ;
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'filter' ][ 'id' ] = 'taxonomy_index_tid' ;
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'filter' ][ 'title' ] = $this -> t ( 'Term' );
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'filter' ][ 'help' ] = $this -> t ( 'Taxonomy term chosen from autocomplete or select widget.' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'filter' ][ 'hierarchy table' ] = 'taxonomy_term_hierarchy' ;
$data [ 'taxonomy_term_field_data' ][ 'tid' ][ 'filter' ][ 'numeric' ] = TRUE ;
$data [ 'taxonomy_term_field_data' ][ 'tid_raw' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Term ID' ),
'help' => $this -> t ( 'The tid of a taxonomy term.' ),
2015-08-17 17:00:26 -07:00
'real field' => 'tid' ,
'filter' => array (
'id' => 'numeric' ,
'allow empty' => TRUE ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'tid_representative' ] = array (
'relationship' => array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Representative node' ),
'label' => $this -> t ( 'Representative node' ),
'help' => $this -> t ( 'Obtains a single representative node for each term, according to a chosen sort criterion.' ),
2015-08-17 17:00:26 -07:00
'id' => 'groupwise_max' ,
'relationship field' => 'tid' ,
'outer field' => 'taxonomy_term_field_data.tid' ,
'argument table' => 'taxonomy_term_field_data' ,
'argument field' => 'tid' ,
'base' => 'node_field_data' ,
'field' => 'nid' ,
'relationship' => 'node_field_data:term_node_tid'
),
);
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'vid' ][ 'help' ] = $this -> t ( 'Filter the results of "Taxonomy: Term" to a particular vocabulary.' );
2015-08-17 17:00:26 -07:00
unset ( $data [ 'taxonomy_term_field_data' ][ 'vid' ][ 'field' ]);
unset ( $data [ 'taxonomy_term_field_data' ][ 'vid' ][ 'argument' ]);
unset ( $data [ 'taxonomy_term_field_data' ][ 'vid' ][ 'sort' ]);
$data [ 'taxonomy_term_field_data' ][ 'name' ][ 'field' ][ 'id' ] = 'term_name' ;
$data [ 'taxonomy_term_field_data' ][ 'name' ][ 'argument' ][ 'many to one' ] = TRUE ;
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'name' ][ 'argument' ][ 'empty field name' ] = $this -> t ( 'Uncategorized' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_field_data' ][ 'description__value' ][ 'field' ][ 'click sortable' ] = FALSE ;
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_field_data' ][ 'changed' ][ 'title' ] = $this -> t ( 'Updated date' );
$data [ 'taxonomy_term_field_data' ][ 'changed' ][ 'help' ] = $this -> t ( 'The date the term was last updated.' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_field_data' ][ 'changed_fulldate' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated date' ),
'help' => $this -> t ( 'Date in the form of CCYYMMDD.' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_fulldate' ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'changed_year_month' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated year + month' ),
'help' => $this -> t ( 'Date in the form of YYYYMM.' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_year_month' ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'changed_year' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated year' ),
'help' => $this -> t ( 'Date in the form of YYYY.' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_year' ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'changed_month' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated month' ),
'help' => $this -> t ( 'Date in the form of MM (01 - 12).' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_month' ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'changed_day' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated day' ),
'help' => $this -> t ( 'Date in the form of DD (01 - 31).' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_day' ,
),
);
$data [ 'taxonomy_term_field_data' ][ 'changed_week' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Updated week' ),
'help' => $this -> t ( 'Date in the form of WW (01 - 53).' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'field' => 'changed' ,
'id' => 'date_week' ,
),
);
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_index' ][ 'table' ][ 'group' ] = $this -> t ( 'Taxonomy term' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_index' ][ 'table' ][ 'join' ] = array (
'taxonomy_term_field_data' => array (
// links directly to taxonomy_term_field_data via tid
'left_field' => 'tid' ,
'field' => 'tid' ,
),
'node_field_data' => array (
// links directly to node via nid
'left_field' => 'nid' ,
'field' => 'nid' ,
),
'taxonomy_term_hierarchy' => array (
'left_field' => 'tid' ,
'field' => 'tid' ,
),
);
$data [ 'taxonomy_index' ][ 'nid' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Content with term' ),
'help' => $this -> t ( 'Relate all content tagged with a term.' ),
2015-08-17 17:00:26 -07:00
'relationship' => array (
'id' => 'standard' ,
'base' => 'node' ,
'base field' => 'nid' ,
2016-04-20 09:56:34 -07:00
'label' => $this -> t ( 'node' ),
2015-08-17 17:00:26 -07:00
'skip base' => 'node' ,
),
);
// @todo This stuff needs to move to a node field since really it's all
// about nodes.
$data [ 'taxonomy_index' ][ 'tid' ] = array (
2016-04-20 09:56:34 -07:00
'group' => $this -> t ( 'Content' ),
'title' => $this -> t ( 'Has taxonomy term ID' ),
'help' => $this -> t ( 'Display content if it has the selected taxonomy terms.' ),
2015-08-17 17:00:26 -07:00
'argument' => array (
'id' => 'taxonomy_index_tid' ,
'name table' => 'taxonomy_term_field_data' ,
'name field' => 'name' ,
2016-04-20 09:56:34 -07:00
'empty field name' => $this -> t ( 'Uncategorized' ),
2015-08-17 17:00:26 -07:00
'numeric' => TRUE ,
'skip base' => 'taxonomy_term_field_data' ,
),
'filter' => array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Has taxonomy term' ),
2015-08-17 17:00:26 -07:00
'id' => 'taxonomy_index_tid' ,
'hierarchy table' => 'taxonomy_term_hierarchy' ,
'numeric' => TRUE ,
'skip base' => 'taxonomy_term_field_data' ,
'allow empty' => TRUE ,
),
);
$data [ 'taxonomy_index' ][ 'status' ] = [
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Publish status' ),
'help' => $this -> t ( 'Whether or not the content related to a term is published.' ),
2015-08-17 17:00:26 -07:00
'filter' => [
'id' => 'boolean' ,
2016-04-20 09:56:34 -07:00
'label' => $this -> t ( 'Published status' ),
2015-08-17 17:00:26 -07:00
'type' => 'yes-no' ,
],
];
$data [ 'taxonomy_index' ][ 'sticky' ] = [
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Sticky status' ),
'help' => $this -> t ( 'Whether or not the content related to a term is sticky.' ),
2015-08-17 17:00:26 -07:00
'filter' => [
'id' => 'boolean' ,
2016-04-20 09:56:34 -07:00
'label' => $this -> t ( 'Sticky status' ),
2015-08-17 17:00:26 -07:00
'type' => 'yes-no' ,
],
'sort' => [
'id' => 'standard' ,
2016-04-20 09:56:34 -07:00
'help' => $this -> t ( 'Whether or not the content related to a term is sticky. To list sticky content first, set this to descending.' ),
2015-08-17 17:00:26 -07:00
],
];
$data [ 'taxonomy_index' ][ 'created' ] = [
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Post date' ),
'help' => $this -> t ( 'The date the content related to a term was posted.' ),
2015-08-17 17:00:26 -07:00
'sort' => [
'id' => 'date'
],
'filter' => [
'id' => 'date' ,
],
];
2016-04-20 09:56:34 -07:00
$data [ 'taxonomy_term_hierarchy' ][ 'table' ][ 'group' ] = $this -> t ( 'Taxonomy term' );
2015-08-17 17:00:26 -07:00
$data [ 'taxonomy_term_hierarchy' ][ 'table' ][ 'provider' ] = 'taxonomy' ;
$data [ 'taxonomy_term_hierarchy' ][ 'table' ][ 'join' ] = array (
'taxonomy_term_hierarchy' => array (
// Link to self through left.parent = right.tid (going down in depth).
'left_field' => 'tid' ,
'field' => 'parent' ,
),
'taxonomy_term_field_data' => array (
// Link directly to taxonomy_term_field_data via tid.
'left_field' => 'tid' ,
'field' => 'tid' ,
),
);
$data [ 'taxonomy_term_hierarchy' ][ 'parent' ] = array (
2016-04-20 09:56:34 -07:00
'title' => $this -> t ( 'Parent term' ),
'help' => $this -> t ( 'The parent term of the term. This can produce duplicate entries if you are using a vocabulary that allows multiple parents.' ),
2015-08-17 17:00:26 -07:00
'relationship' => array (
'base' => 'taxonomy_term_field_data' ,
'field' => 'parent' ,
2016-04-20 09:56:34 -07:00
'label' => $this -> t ( 'Parent' ),
2015-08-17 17:00:26 -07:00
'id' => 'standard' ,
),
'filter' => array (
2016-04-20 09:56:34 -07:00
'help' => $this -> t ( 'Filter the results of "Taxonomy: Term" by the parent pid.' ),
2015-08-17 17:00:26 -07:00
'id' => 'numeric' ,
),
'argument' => array (
2016-04-20 09:56:34 -07:00
'help' => $this -> t ( 'The parent term of the term.' ),
2015-08-17 17:00:26 -07:00
'id' => 'taxonomy' ,
),
);
return $data ;
}
}