Core is in the process of converting from Annotation to PHP Attributes for plugins. We need to document the usage of this feature.
If we adopted this change, the Drupal Project would benefit by ...
Provide all proposed changes to the Drupal Coding standards β . Give a link to each section that will be changed, and show the current text and proposed text as in the following layout:
Add current text in blockquotes
Plugin
Plugin type class
{Some text here}
// Attribute class #[\Attribute(\Attribute::TARGET_CLASS)] class Action extends Plugin { β¦ } // Plugin manager public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler) { parent::__construct('Plugin/Action', $namespaces, $module_handler, 'Drupal\Core\Action\ActionInterface', 'Drupal\Core\Annotation\Action', [], Action::class); }
Plugin class
{Some text here}
namespace Drupal\Core\Action\Plugin\Action; use Drupal\Core\Action\Plugin\Action\Derivative\EntityPublishedActionDeriver; use Drupal\Core\Action\Attribute\Action; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslatableMarkup; /** * Publishes an entity. */ #[Action( id: 'entity:publish_action', action_label: new TranslatableMarkup('Publish'), deriver: EntityPublishedActionDeriver::class )] class PublishAction extends EntityActionBase {], Action::class); }
For a fuller explanation of these steps see the Coding Standards project page β
Active
Coding Standards