You are here

class ReadOnlyFormEvent in Configuration Read-only mode 8

Readonly form event.

Hierarchy

  • class \Drupal\config_readonly\ReadOnlyFormEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of ReadOnlyFormEvent

2 files declare their use of ReadOnlyFormEvent
config_readonly.module in ./config_readonly.module
Contains config_readonly.module.
ReadOnlyFormSubscriber.php in src/EventSubscriber/ReadOnlyFormSubscriber.php

File

src/ReadOnlyFormEvent.php, line 11

Namespace

Drupal\config_readonly
View source
class ReadOnlyFormEvent extends Event {
  const NAME = 'config_readonly_form_event';

  /**
   * The form state.
   *
   * @var \Drupal\Core\Form\FormStateInterface
   */
  protected $formState;

  /**
   * Flag as to whether the form is read only.
   *
   * @var bool
   */
  protected $readOnlyForm;

  /**
   * Constructs a new ReadOnlyFormEvent object.
   *
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The form state.
   */
  public function __construct(FormStateInterface $form_state) {
    $this->readOnlyForm = FALSE;
    $this->formState = $form_state;
  }

  /**
   * Get the form state.
   *
   * @return \Drupal\Core\Form\FormStateInterface
   *   The form state.
   */
  public function getFormState() {
    return $this->formState;
  }

  /**
   * Mark the form as read-only.
   */
  public function markFormReadOnly() {
    $this->readOnlyForm = TRUE;
  }

  /**
   * Check whether the form is read-only.
   *
   * @return bool
   *   Whether the form is read-only.
   */
  public function isFormReadOnly() {
    return $this->readOnlyForm;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ReadOnlyFormEvent::$formState protected property The form state.
ReadOnlyFormEvent::$readOnlyForm protected property Flag as to whether the form is read only.
ReadOnlyFormEvent::getFormState public function Get the form state.
ReadOnlyFormEvent::isFormReadOnly public function Check whether the form is read-only.
ReadOnlyFormEvent::markFormReadOnly public function Mark the form as read-only.
ReadOnlyFormEvent::NAME constant
ReadOnlyFormEvent::__construct public function Constructs a new ReadOnlyFormEvent object.