trait PluginWithFormsTrait

Same name in other branches
  1. 9 core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php \Drupal\Core\Plugin\PluginWithFormsTrait
  2. 8.9.x core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php \Drupal\Core\Plugin\PluginWithFormsTrait
  3. 11.x core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php \Drupal\Core\Plugin\PluginWithFormsTrait

Provides a trait with typical behavior for plugins which have forms.

Hierarchy

3 files declare their use of PluginWithFormsTrait
BlockPluginTrait.php in core/lib/Drupal/Core/Block/BlockPluginTrait.php
PluginWithFormsTraitTest.php in core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php
WorkflowTypeBase.php in core/modules/workflows/src/Plugin/WorkflowTypeBase.php

File

core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php, line 8

Namespace

Drupal\Core\Plugin
View source
trait PluginWithFormsTrait {
    
    /**
     * Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass().
     */
    public function getFormClass($operation) {
        if (isset($this->getPluginDefinition()['forms'][$operation])) {
            return $this->getPluginDefinition()['forms'][$operation];
        }
        elseif ($operation === 'configure' && $this instanceof PluginFormInterface) {
            return static::class;
        }
    }
    
    /**
     * Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass().
     */
    public function hasFormClass($operation) {
        return !empty($this->getFormClass($operation));
    }

}

Members

Title Sort descending Modifiers Object type Summary
PluginWithFormsTrait::getFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::getFormClass().
PluginWithFormsTrait::hasFormClass public function Implements \Drupal\Core\Plugin\PluginWithFormsInterface::hasFormClass().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.