You are here

PluginWithFormsTrait.php in Drupal 8

Same filename and directory in other branches
  1. 9 core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php

Namespace

Drupal\Core\Plugin

File

core/lib/Drupal/Core/Plugin/PluginWithFormsTrait.php
View source
<?php

namespace Drupal\Core\Plugin;


/**
 * Provides a trait with typical behavior for plugins which have forms.
 */
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));
  }

}

Traits

Namesort descending Description
PluginWithFormsTrait Provides a trait with typical behavior for plugins which have forms.