Issue #3426956 by sorlov, mstrelan, smustgrave: Convert ViewsRelationship plugin discovery to attributes

merge-requests/6650/merge
Alex Pott 2024-03-16 17:26:24 +00:00
parent 8aa3632c61
commit 27b07de8bb
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
7 changed files with 31 additions and 11 deletions

View File

@ -5,6 +5,7 @@ namespace Drupal\taxonomy\Plugin\views\relationship;
use Drupal\Core\Database\Database;
use Drupal\Core\Form\FormStateInterface;
use Drupal\taxonomy\VocabularyStorageInterface;
use Drupal\views\Attribute\ViewsRelationship;
use Drupal\views\Plugin\views\relationship\RelationshipPluginBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -12,9 +13,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* Relationship handler to return the taxonomy terms of nodes.
*
* @ingroup views_relationship_handlers
*
* @ViewsRelationship("node_term_data")
*/
#[ViewsRelationship("node_term_data")]
class NodeTermData extends RelationshipPluginBase {
/**

View File

@ -0,0 +1,19 @@
<?php
declare(strict_types=1);
namespace Drupal\views\Attribute;
use Drupal\Component\Plugin\Attribute\PluginID;
/**
* Defines a Plugin attribute class for views relationship handlers.
*
* @see \Drupal\views\Plugin\views\relationship\RelationshipPluginBase
*
* @ingroup views_relationship_handlers
*/
#[\Attribute(\Attribute::TARGET_CLASS)]
class ViewsRelationship extends PluginID {
}

View File

@ -2,15 +2,15 @@
namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\Attribute\ViewsRelationship;
use Drupal\views\Plugin\views\BrokenHandlerTrait;
/**
* A special handler to take the place of missing or broken handlers.
*
* @ingroup views_relationship_handlers
*
* @ViewsRelationship("broken")
*/
#[ViewsRelationship("broken")]
class Broken extends RelationshipPluginBase {
use BrokenHandlerTrait;

View File

@ -2,6 +2,7 @@
namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\Attribute\ViewsRelationship;
use Drupal\views\Plugin\ViewsHandlerManager;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface;
@ -10,9 +11,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* A relationship handlers which reverse entity references.
*
* @ingroup views_relationship_handlers
*
* @ViewsRelationship("entity_reverse")
*/
#[ViewsRelationship("entity_reverse")]
class EntityReverse extends RelationshipPluginBase {
/**

View File

@ -4,6 +4,7 @@ namespace Drupal\views\Plugin\views\relationship;
use Drupal\Core\Database\Query\AlterableInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Attribute\ViewsRelationship;
use Drupal\views\Views;
use Drupal\views\Entity\View;
@ -56,9 +57,8 @@ use Drupal\views\Entity\View;
* in the same way as node_comment_statistics.
*
* @ingroup views_relationship_handlers
*
* @ViewsRelationship("groupwise_max")
*/
#[ViewsRelationship("groupwise_max")]
class GroupwiseMax extends RelationshipPluginBase {
/**

View File

@ -15,7 +15,7 @@ use Drupal\views\Views;
*
* Relationship handlers extend
* \Drupal\views\Plugin\views\relationship\RelationshipPluginBase. They must
* be annotated with \Drupal\views\Annotation\ViewsRelationship annotation,
* be attributed with \Drupal\views\Attribute\ViewsRelationship attribute,
* and they must be in namespace directory Plugin\views\relationship.
*
* @ingroup views_plugins

View File

@ -2,13 +2,14 @@
namespace Drupal\views\Plugin\views\relationship;
use Drupal\views\Attribute\ViewsRelationship;
/**
* Default implementation of the base relationship plugin.
*
* @ingroup views_relationship_handlers
*
* @ViewsRelationship("standard")
*/
#[ViewsRelationship("standard")]
class Standard extends RelationshipPluginBase {
}