PluginFormBase.php 909 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace Drupal\Core\Plugin;
  3. use Drupal\Component\Plugin\PluginAwareInterface;
  4. use Drupal\Component\Plugin\PluginInspectionInterface;
  5. use Drupal\Core\Form\FormStateInterface;
  6. /**
  7. * Provides a base class for plugin forms.
  8. *
  9. * Classes extending this can be in any namespace, but are commonly placed in
  10. * the 'PluginForm' namespace, such as \Drupal\module_name\PluginForm\ClassName.
  11. */
  12. abstract class PluginFormBase implements PluginFormInterface, PluginAwareInterface {
  13. /**
  14. * The plugin this form is for.
  15. *
  16. * @var \Drupal\Component\Plugin\PluginInspectionInterface
  17. */
  18. protected $plugin;
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function setPlugin(PluginInspectionInterface $plugin) {
  23. $this->plugin = $plugin;
  24. }
  25. /**
  26. * {@inheritdoc}
  27. */
  28. public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
  29. // Validation is optional.
  30. }
  31. }