Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / PluginWithFormsTrait.php
1 <?php
2
3 namespace Drupal\Core\Plugin;
4
5 /**
6  * Provides a trait with typical behavior for plugins which have forms.
7  */
8 trait PluginWithFormsTrait {
9
10   /**
11    * {@inheritdoc}
12    */
13   public function getFormClass($operation) {
14     if (isset($this->getPluginDefinition()['forms'][$operation])) {
15       return $this->getPluginDefinition()['forms'][$operation];
16     }
17     elseif ($operation === 'configure' && $this instanceof PluginFormInterface) {
18       return static::class;
19     }
20   }
21
22   /**
23    * {@inheritdoc}
24    */
25   public function hasFormClass($operation) {
26     return !empty($this->getFormClass($operation));
27   }
28
29 }