You are here

class FormBuilderWrapper in Devel 8

Same name and namespace in other branches
  1. 8.3 webprofiler/src/Form/FormBuilderWrapper.php \Drupal\webprofiler\Form\FormBuilderWrapper
  2. 8.2 webprofiler/src/Form/FormBuilderWrapper.php \Drupal\webprofiler\Form\FormBuilderWrapper
  3. 4.x webprofiler/src/Form/FormBuilderWrapper.php \Drupal\webprofiler\Form\FormBuilderWrapper

Class FormBuilderWrapper

Hierarchy

Expanded class hierarchy of FormBuilderWrapper

1 file declares its use of FormBuilderWrapper
FormsDataCollector.php in webprofiler/src/DataCollector/FormsDataCollector.php

File

webprofiler/src/Form/FormBuilderWrapper.php, line 11

Namespace

Drupal\webprofiler\Form
View source
class FormBuilderWrapper extends FormBuilder {

  /**
   * @var array
   */
  private $buildForms;

  /**
   * @return array
   */
  public function getBuildForm() {
    return $this->buildForms;
  }

  /**
   * {@inheritdoc}
   */
  public function prepareForm($form_id, &$form, FormStateInterface &$form_state) {
    parent::prepareForm($form_id, $form, $form_state);
    if (!$this->buildForms) {
      $this->buildForms = [];
    }
    $elements = [];
    foreach ($form as $key => $value) {
      if (strpos($key, '#') !== 0) {
        $elements[$key]['#title'] = isset($value['#title']) ? $value['#title'] : NULL;
        $elements[$key]['#access'] = isset($value['#access']) ? $value['#access'] : NULL;
        $elements[$key]['#type'] = isset($value['#type']) ? $value['#type'] : NULL;
      }
    }
    $buildInfo = $form_state
      ->getBuildInfo();
    $class = get_class($buildInfo['callback_object']);
    $method = new \ReflectionMethod($class, 'buildForm');
    $this->buildForms[$buildInfo['form_id']] = [
      'class' => [
        'class' => $class,
        'method' => 'buildForm',
        'file' => $method
          ->getFilename(),
        'line' => $method
          ->getStartLine(),
      ],
      'form' => $elements,
    ];
    return $form;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormBuilder::$classResolver protected property The class resolver.
FormBuilder::$csrfToken protected property The CSRF token generator to validate the form token.
FormBuilder::$currentUser protected property The current user.
FormBuilder::$elementInfo protected property The element info manager.
FormBuilder::$eventDispatcher protected property The event dispatcher.
FormBuilder::$formCache protected property The form cache.
FormBuilder::$formSubmitter protected property The form submitter.
FormBuilder::$formValidator protected property The form validator.
FormBuilder::$moduleHandler protected property The module handler.
FormBuilder::$requestStack protected property The request stack.
FormBuilder::$safeCoreValueCallables protected property Defines element value callables which are safe to run even when the form state has an invalid CSRF token.
FormBuilder::$themeManager protected property The theme manager.
FormBuilder::buildForm public function Builds and processes a form for a given form ID. Overrides FormBuilderInterface::buildForm
FormBuilder::buildFormAction protected function Builds the $form['#action'].
FormBuilder::buttonWasClicked protected function Determines if a given button triggered the form submission.
FormBuilder::currentUser protected function Gets the current active user.
FormBuilder::deleteCache public function Deletes a form in the cache. Overrides FormCacheInterface::deleteCache
FormBuilder::doBuildForm public function Builds and processes all elements in the structured form array. Overrides FormBuilderInterface::doBuildForm
FormBuilder::doSubmitForm public function Handles the submitted form, executing callbacks and processing responses. Overrides FormSubmitterInterface::doSubmitForm
FormBuilder::elementTriggeredScriptedSubmission protected function Detects if an element triggered the form submission via Ajax.
FormBuilder::executeSubmitHandlers public function Executes custom submission handlers for a given form. Overrides FormSubmitterInterface::executeSubmitHandlers
FormBuilder::executeValidateHandlers public function Executes custom validation handlers for a given form. Overrides FormValidatorInterface::executeValidateHandlers
FormBuilder::getCache public function Fetches a form from the cache. Overrides FormCacheInterface::getCache
FormBuilder::getFileUploadMaxSize protected function Wraps file_upload_max_size().
FormBuilder::getForm public function Gets a renderable form array. Overrides FormBuilderInterface::getForm
FormBuilder::getFormId public function Determines the ID of a form. Overrides FormBuilderInterface::getFormId
FormBuilder::handleInputElement protected function Adds the #name and #value properties of an input element before rendering.
FormBuilder::processForm public function Processes a form submission. Overrides FormBuilderInterface::processForm
FormBuilder::rebuildForm public function Constructs a new $form from the information in $form_state. Overrides FormBuilderInterface::rebuildForm
FormBuilder::redirectForm public function Redirects the user to a URL after a form has been processed. Overrides FormSubmitterInterface::redirectForm
FormBuilder::renderFormTokenPlaceholder public function Renders the form CSRF token. It's a #lazy_builder callback.
FormBuilder::renderPlaceholderFormAction public function Renders a form action URL. It's a #lazy_builder callback.
FormBuilder::retrieveForm public function Retrieves the structured array that defines a given form. Overrides FormBuilderInterface::retrieveForm
FormBuilder::setCache public function Stores a form in the cache. Overrides FormCacheInterface::setCache
FormBuilder::setInvalidTokenError public function Sets a form_token error on the given form state. Overrides FormValidatorInterface::setInvalidTokenError
FormBuilder::submitForm public function Retrieves, populates, and processes a form. Overrides FormBuilderInterface::submitForm
FormBuilder::trustedCallbacks public static function Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface::trustedCallbacks
FormBuilder::validateForm public function Validates user-submitted form data in the $form_state. Overrides FormValidatorInterface::validateForm
FormBuilder::valueCallableIsSafe protected function Helper function to normalize the different callable formats.
FormBuilder::__construct public function Constructs a new FormBuilder.
FormBuilderInterface::AJAX_FORM_REQUEST constant Request key for AJAX forms that submit to the form's original route.
FormBuilderWrapper::$buildForms private property
FormBuilderWrapper::getBuildForm public function
FormBuilderWrapper::prepareForm public function Prepares a structured form array. Overrides FormBuilder::prepareForm
TrustedCallbackInterface::THROW_EXCEPTION constant Untrusted callbacks throw exceptions.
TrustedCallbackInterface::TRIGGER_SILENCED_DEPRECATION constant Untrusted callbacks trigger silenced E_USER_DEPRECATION errors.
TrustedCallbackInterface::TRIGGER_WARNING constant Untrusted callbacks trigger E_USER_WARNING errors.