You are here

class QuickFormBase in farmOS 2.x

Base class for quick forms.

Hierarchy

Expanded class hierarchy of QuickFormBase

1 file declares its use of QuickFormBase
Test.php in modules/core/quick/tests/modules/farm_quick_test/src/Plugin/QuickForm/Test.php

File

modules/core/quick/src/Plugin/QuickForm/QuickFormBase.php, line 18

Namespace

Drupal\farm_quick\Plugin\QuickForm
View source
class QuickFormBase extends PluginBase implements QuickFormInterface, ContainerFactoryPluginInterface {
  use MessengerTrait;
  use StringTranslationTrait;

  /**
   * Constructs a QuickFormBase object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin_id for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   * @param \Drupal\Core\Messenger\MessengerInterface $messenger
   *   The messenger service.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition, MessengerInterface $messenger) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->messenger = $messenger;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    return new static($configuration, $plugin_id, $plugin_definition, $container
      ->get('messenger'));
  }

  /**
   * {@inheritdoc}
   */
  public function getId() {
    return $this
      ->getPluginId();
  }

  /**
   * {@inheritdoc}
   */
  public function getlabel() {
    return $this->pluginDefinition['label'] ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getDescription() {
    return $this->pluginDefinition['description'] ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getHelpText() {
    return $this->pluginDefinition['helpText'] ?? '';
  }

  /**
   * {@inheritdoc}
   */
  public function getPermissions() {
    return $this->pluginDefinition['permissions'] ?? [];
  }

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account) {
    $permissions = $this
      ->getPermissions();
    return AccessResult::allowedIfHasPermissions($account, $permissions);
  }

  /**
   * {@inheritdoc}
   */
  public function buildForm(array $form, FormStateInterface $form_state) {
    return [];
  }

  /**
   * {@inheritdoc}
   */
  public function validateForm(array &$form, FormStateInterface $form_state) {

    // Validation is optional.
  }

  /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {

    // Submit is optional, but presumably this will be overridden.
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 2
DependencySerializationTrait::__wakeup public function 2
MessengerTrait::$messenger protected property The messenger. 27
MessengerTrait::messenger public function Gets the messenger. 27
MessengerTrait::setMessenger public function Sets the messenger.
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition. 1
PluginBase::$pluginId protected property The plugin_id.
PluginBase::DERIVATIVE_SEPARATOR constant A string which is used to separate base plugin IDs from the derivative ID.
PluginBase::getBaseId public function Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface::getBaseId
PluginBase::getDerivativeId public function Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface::getDerivativeId
PluginBase::getPluginDefinition public function Gets the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition 2
PluginBase::getPluginId public function Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginBase::isConfigurable public function Determines if the plugin is configurable.
QuickFormBase::access public function Checks access for the quick form. Overrides QuickFormInterface::access
QuickFormBase::buildForm public function Form constructor. Overrides QuickFormInterface::buildForm 1
QuickFormBase::create public static function Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface::create
QuickFormBase::getDescription public function Returns the quick form description. Overrides QuickFormInterface::getDescription
QuickFormBase::getHelpText public function Returns the quick form help text. Overrides QuickFormInterface::getHelpText
QuickFormBase::getId public function Returns the quick form ID. Overrides QuickFormInterface::getId
QuickFormBase::getlabel public function
QuickFormBase::getPermissions public function Returns the list of access permissions for the quick form. Overrides QuickFormInterface::getPermissions
QuickFormBase::submitForm public function Form submission handler. Overrides QuickFormInterface::submitForm 1
QuickFormBase::validateForm public function Form validation handler. Overrides QuickFormInterface::validateForm
QuickFormBase::__construct public function Constructs a QuickFormBase object. Overrides PluginBase::__construct
QuickFormInterface::getLabel public function Returns the quick form label.
StringTranslationTrait::$stringTranslation protected property The string translation service. 4
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.