Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

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 {
    
    /**
     * 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));
    }

}

Traits

Title Deprecated Summary
PluginWithFormsTrait Provides a trait with typical behavior for plugins which have forms.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal