You are here

trait PluginWithFormsTrait in Drupal 8

Same name and namespace in other branches
  1. 9 core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php \Drupal\Core\Plugin\PluginWithFormsTrait
  2. 10 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 {

  /**
   * {@inheritdoc}
   */
  public function getFormClass($operation) {
    if (isset($this
      ->getPluginDefinition()['forms'][$operation])) {
      return $this
        ->getPluginDefinition()['forms'][$operation];
    }
    elseif ($operation === 'configure' && $this instanceof PluginFormInterface) {
      return static::class;
    }
  }

  /**
   * {@inheritdoc}
   */
  public function hasFormClass($operation) {
    return !empty($this
      ->getFormClass($operation));
  }

}

Members