Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
d8bfd3b9
Commit
d8bfd3b9
authored
Jul 28, 2012
by
dawehner
Committed by
tim.plunkett
Oct 21, 2012
Browse files
Use annotation for relationships
parent
d00169d1
Changes
14
Hide whitespace changes
Inline
Side-by-side
lib/Drupal/views/Plugins/views/relationship/GroupwiseMax.php
View file @
d8bfd3b9
...
...
@@ -10,6 +10,7 @@
use
Drupal\Core\Database\Query\AlterableInterface
;
use
Drupal\views\View
;
use
Drupal\views\JoinSubquery
;
use
Drupal\Core\Annotation\Plugin
;
/**
* Relationship handler that allows a groupwise maximum of the linked in table.
...
...
@@ -59,7 +60,13 @@
*
* @ingroup views_relationship_handlers
*/
class
GroupwiseMax
extends
relationshipPluginBase
{
/**
* @plugin(
* plugin_id = "groupwise_max"
* )
*/
class
GroupwiseMax
extends
RelationshipPluginBase
{
/**
* Defines default values for options.
...
...
lib/Drupal/views/Plugins/views/relationship/RelationshipPluginBase.php
View file @
d8bfd3b9
...
...
@@ -7,8 +7,9 @@
namespace
Drupal\views\Plugins\views\relationship
;
use
Drupal\views\Plugins\views\
Plugin
;
use
Drupal\views\Plugins\views\
Handler
;
use
Drupal\views\Join
;
use
Drupal\Core\Annotation\Plugin
;
/**
* @defgroup views_relationship_handlers Views relationship handlers
...
...
@@ -40,7 +41,13 @@
*
* @ingroup views_relationship_handlers
*/
class
RelationshipPluginBase
extends
Plugin
{
/**
* @Plugin(
* plugin_id = "standard"
* )
*/
class
RelationshipPluginBase
extends
Handler
{
/**
* Init handler to let relationships live on tables other than
* the table they operate on.
...
...
modules/book.views.inc
View file @
d8bfd3b9
...
...
@@ -27,7 +27,7 @@ function book_views_data() {
'help'
=>
t
(
'The book the node is in.'
),
'relationship'
=>
array
(
'base'
=>
'node'
,
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'label'
=>
t
(
'Book'
),
),
// There is no argument here; if you need an argument, add the relationship
...
...
@@ -107,7 +107,7 @@ function book_views_data() {
'relationship'
=>
array
(
'base'
=>
'node'
,
'base field'
=>
'nid'
,
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'label'
=>
t
(
'Book parent'
),
),
);
...
...
modules/comment.views.inc
View file @
d8bfd3b9
...
...
@@ -402,7 +402,7 @@ function comment_views_data() {
'help'
=>
t
(
'The parent comment.'
),
'base'
=>
'comment'
,
'base field'
=>
'cid'
,
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'label'
=>
t
(
'Parent comment'
),
),
);
...
...
@@ -500,7 +500,7 @@ function comment_views_data() {
'group'
=>
t
(
'Comment'
),
'base'
=>
'comment'
,
'base field'
=>
'cid'
,
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'label'
=>
t
(
'Last Comment'
),
),
);
...
...
@@ -596,7 +596,7 @@ function comment_views_data_alter(&$data) {
'base'
=>
'comment'
,
'base field'
=>
'nid'
,
'relationship field'
=>
'nid'
,
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
),
);
...
...
modules/file.views.inc
View file @
d8bfd3b9
...
...
@@ -20,7 +20,7 @@ function file_field_views_data($field) {
foreach
(
$data
as
$table_name
=>
$table_data
)
{
// Add the relationship only on the fid field.
$data
[
$table_name
][
$field
[
'field_name'
]
.
'_fid'
][
'relationship'
]
=
array
(
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'file_managed'
,
'entity type'
=>
'file'
,
'base field'
=>
'fid'
,
...
...
modules/image.views.inc
View file @
d8bfd3b9
...
...
@@ -20,7 +20,7 @@ function image_field_views_data($field) {
foreach
(
$data
as
$table_name
=>
$table_data
)
{
// Add the relationship only on the fid field.
$data
[
$table_name
][
$field
[
'field_name'
]
.
'_fid'
][
'relationship'
]
=
array
(
'
handler'
=>
'views_handler_relationship
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'file_managed'
,
'base field'
=>
'fid'
,
'label'
=>
t
(
'image from !field_name'
,
array
(
'!field_name'
=>
$field
[
'field_name'
])),
...
...
modules/node.views.inc
View file @
d8bfd3b9
...
...
@@ -380,7 +380,7 @@ function node_views_data() {
'relationship'
=>
array
(
'title'
=>
t
(
'Author'
),
'help'
=>
t
(
'Relate content to the user who created it.'
),
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'users'
,
'field'
=>
'uid'
,
'label'
=>
t
(
'author'
),
...
...
@@ -450,7 +450,7 @@ function node_views_data() {
'title'
=>
t
(
'User'
),
'help'
=>
t
(
'Relate a content revision to the user who created the revision.'
),
'relationship'
=>
array
(
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'users'
,
'base field'
=>
'uid'
,
'label'
=>
t
(
'revision user'
),
...
...
@@ -473,14 +473,14 @@ function node_views_data() {
),
// Information for accepting a nid as a filter
'filter'
=>
array
(
'
handler'
=>
'Drupal\views\Plugins\views\filter\N
umeric'
,
'
plugin_id'
=>
'n
umeric'
,
),
// Information for sorting on a nid.
'sort'
=>
array
(
'plugin_id'
=>
'standard'
,
),
'relationship'
=>
array
(
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'node'
,
'base field'
=>
'vid'
,
'title'
=>
t
(
'Content'
),
...
...
modules/statistics.views.inc
View file @
d8bfd3b9
...
...
@@ -220,7 +220,7 @@ function statistics_views_data() {
'title'
=>
t
(
'User'
),
'help'
=>
t
(
'The user who visited the site.'
),
'relationship'
=>
array
(
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'users'
,
'base field'
=>
'uid'
,
),
...
...
modules/taxonomy.views.inc
View file @
d8bfd3b9
...
...
@@ -292,7 +292,7 @@ function taxonomy_views_data() {
'title'
=>
t
(
'Content with term'
),
'help'
=>
t
(
'Relate all content tagged with a term.'
),
'relationship'
=>
array
(
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'node'
,
'base field'
=>
'nid'
,
'label'
=>
t
(
'node'
),
...
...
@@ -436,7 +436,7 @@ function taxonomy_field_views_data($field) {
// Add the relationship only on the tid field.
$data
[
$table_name
][
$field
[
'field_name'
]
.
'_tid'
][
'relationship'
]
=
array
(
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'taxonomy_term_data'
,
'base field'
=>
'tid'
,
'label'
=>
t
(
'term from !field_name'
,
array
(
'!field_name'
=>
$field
[
'field_name'
])),
...
...
modules/taxonomy/views_handler_relationship_node_term_data.inc
View file @
d8bfd3b9
...
...
@@ -6,13 +6,14 @@
*/
use
Drupal\views\Join
;
use
Drupal\views\Plugins\views\relationship\RelationshipPluginBase
;
/**
* Relationship handler to return the taxonomy terms of nodes.
*
* @ingroup views_relationship_handlers
*/
class
views_handler_relationship_node_term_data
extends
views_handler_r
elationship
{
class
views_handler_relationship_node_term_data
extends
R
elationship
PluginBase
{
function
init
(
&
$view
,
&
$options
)
{
parent
::
init
(
$view
,
$options
);
...
...
modules/translation.views.inc
View file @
d8bfd3b9
...
...
@@ -46,7 +46,7 @@ function translation_views_data_alter(&$data) {
'help'
=>
t
(
'The source that this content was translated from.'
),
'base'
=>
'node'
,
'base field'
=>
'nid'
,
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'label'
=>
t
(
'Source translation'
),
),
);
...
...
modules/translation/views_handler_relationship_translation.inc
View file @
d8bfd3b9
...
...
@@ -6,6 +6,7 @@
*/
use
Drupal\views\Join
;
use
Drupal\views\Plugins\views\relationship\RelationshipPluginBase
;
/**
* Handles relationships for content translation sets and provides multiple
...
...
@@ -13,7 +14,7 @@
*
* @ingroup views_relationship_handlers
*/
class
views_handler_relationship_translation
extends
views_handler_r
elationship
{
class
views_handler_relationship_translation
extends
R
elationship
PluginBase
{
function
option_definition
()
{
$options
=
parent
::
option_definition
();
$options
[
'language'
]
=
array
(
'default'
=>
'current'
);
...
...
modules/user.views.inc
View file @
d8bfd3b9
...
...
@@ -64,7 +64,7 @@ function user_views_data() {
'relationship'
=>
array
(
'title'
=>
t
(
'Content authored'
),
'help'
=>
t
(
'Relate content to the user who created it. This relationship will create one record for each content item created by the user.'
),
'
handler'
=>
'Drupal\views\Plugins\views\relationship\RelationshipPluginBase
'
,
'
plugin_id'
=>
'standard
'
,
'base'
=>
'node'
,
'base field'
=>
'uid'
,
'field'
=>
'uid'
,
...
...
views.api.php
View file @
d8bfd3b9
...
...
@@ -372,13 +372,10 @@ function hook_views_data() {
// other direction, use hook_views_data_alter(), or use the 'implicit' join
// method described above.
'relationship'
=>
array
(
'base'
=>
'node'
,
// The name of the table to join with.
'base field'
=>
'nid'
,
// The name of the field on the joined table.
// 'field' => 'nid' -- see hook_views_data_alter(); not needed here.
'handler'
=>
'views_handler_relationship'
,
'label'
=>
t
(
'Default label for the relationship'
),
'title'
=>
t
(
'Title shown when adding the relationship'
),
'help'
=>
t
(
'More information on this relationship'
),
'base'
=>
'node'
,
// The name of the table to join with
'field'
=>
'nid'
,
// The name of the field to join with
'plugin_id'
=>
'standard'
,
'label'
=>
t
(
'Example node'
),
),
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment