You are here

class FillPdfFormForm in FillPDF 8.4

Same name and namespace in other branches
  1. 5.0.x src/Form/FillPdfFormForm.php \Drupal\fillpdf\Form\FillPdfFormForm

Form controller for the FillPDFForm edit form.

Hierarchy

Expanded class hierarchy of FillPdfFormForm

File

src/Form/FillPdfFormForm.php, line 24

Namespace

Drupal\fillpdf\Form
View source
class FillPdfFormForm extends ContentEntityForm {

  /**
   * Maximum number of entities to be listed in a select.
   */
  const SELECT_MAX = 25;

  /**
   * The FillPdf admin form helper.
   *
   * @var \Drupal\fillpdf\FillPdfAdminFormHelperInterface
   */
  protected $adminFormHelper;

  /**
   * The FillPdf link manipulator.
   *
   * @var \Drupal\fillpdf\FillPdfLinkManipulatorInterface
   */
  protected $linkManipulator;

  /**
   * The FillPdf link manipulator.
   *
   * @var \Drupal\fillpdf\InputHelperInterface
   */
  protected $inputHelper;

  /**
   * The FillPdf serializer.
   *
   * @var \Drupal\fillpdf\SerializerInterface
   */
  protected $serializer;

  /**
   * The file system service.
   *
   * @var \Drupal\Core\File\FileSystemInterface
   */
  protected $fileSystem;

  /**
   * The FillPDF token resolver.
   *
   * @var \Drupal\fillpdf\TokenResolverInterface
   */
  protected $tokenResolver;

  /**
   * Constructs a FillPdfFormForm object.
   *
   * @param \Drupal\Core\Entity\EntityRepositoryInterface $entity_repository
   *   The entity repository service.
   * @param \Drupal\fillpdf\FillPdfAdminFormHelperInterface $admin_form_helper
   *   FillPdf admin form helper.
   * @param \Drupal\fillpdf\FillPdfLinkManipulatorInterface $link_manipulator
   *   FillPdf link manipulator.
   * @param \Drupal\fillpdf\InputHelperInterface $input_helper
   *   FillPdf link manipulator.
   * @param \Drupal\fillpdf\SerializerInterface $fillpdf_serializer
   *   FillPdf serializer.
   * @param \Drupal\Core\File\FileSystemInterface $file_system
   *   Helpers to operate on files and stream wrappers.
   * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
   *   The entity repository service.
   * @param \Drupal\fillpdf\TokenResolverInterface $token_resolver
   *   The FillPDF token resolver.
   */
  public function __construct(EntityRepositoryInterface $entity_repository, FillPdfAdminFormHelperInterface $admin_form_helper, FillPdfLinkManipulatorInterface $link_manipulator, InputHelperInterface $input_helper, SerializerInterface $fillpdf_serializer, FileSystemInterface $file_system, EntityTypeManager $entity_type_manager, TokenResolverInterface $token_resolver) {
    parent::__construct($entity_repository);
    $this->adminFormHelper = $admin_form_helper;
    $this->linkManipulator = $link_manipulator;
    $this->inputHelper = $input_helper;
    $this->serializer = $fillpdf_serializer;
    $this->fileSystem = $file_system;
    $this->entityTypeManager = $entity_type_manager;
    $this->tokenResolver = $token_resolver;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('entity.repository'), $container
      ->get('fillpdf.admin_form_helper'), $container
      ->get('fillpdf.link_manipulator'), $container
      ->get('fillpdf.input_helper'), $container
      ->get('fillpdf.serializer'), $container
      ->get('file_system'), $container
      ->get('entity_type.manager'), $container
      ->get('fillpdf.token_resolver'));
  }

  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    /** @var \Drupal\fillpdf\FillPdfFormInterface $fillpdf_form */
    $fillpdf_form = $this->entity;
    $form['title']['token_tree'] = $this->adminFormHelper
      ->getAdminTokenForm();

    // @todo: Encapsulate this logic into a ::getDefaultEntityType() method on FillPdfForm
    $stored_default_entity_type = $fillpdf_form
      ->get('default_entity_type');
    $default_entity_type = count($stored_default_entity_type) ? $stored_default_entity_type
      ->first()->value : NULL;
    $form['default_entity_type'] = [
      '#type' => 'select',
      '#title' => $this
        ->t('Default entity type'),
      '#options' => $this
        ->getEntityTypeOptions(),
      '#empty_option' => $this
        ->t('- None -'),
      '#weight' => 12.5,
      '#default_value' => $default_entity_type,
      '#ajax' => [
        'callback' => '::ajaxUpdateEntityId',
        'event' => 'change',
        'wrapper' => 'test-entity-wrapper',
        'progress' => [
          'type' => 'none',
        ],
      ],
    ];

    // On AJAX-triggered rebuild, work with the user input instead of previously
    // stored values.
    if ($form_state
      ->isRebuilding()) {
      $default_entity_type = $form_state
        ->getValue('default_entity_type');
      $default_entity_id = $form_state
        ->getValue('default_entity_id');
    }
    else {
      $stored_default_entity_id = $fillpdf_form
        ->get('default_entity_id');
      $default_entity_id = count($stored_default_entity_id) ? $stored_default_entity_id
        ->first()->value : NULL;
    }
    $form['default_entity_id'] = [
      '#title' => $this
        ->t('Default entity'),
      '#target_type' => $default_entity_type,
      '#weight' => 13,
      '#prefix' => '<div id="test-entity-wrapper">',
      '#suffix' => '</div>',
      '#ajax' => [
        'callback' => '::ajaxUpdateEntityId',
        'event' => 'autocompleteclose autocompletechange',
        'wrapper' => 'test-entity-wrapper',
        'progress' => [
          'type' => 'none',
        ],
      ],
    ];

    // If a default entity type is set, allow selecting a default entity, too.
    if ($default_entity_type) {
      $storage = $this->entityTypeManager
        ->getStorage($default_entity_type);
      $default_entity = $default_entity_id ? $storage
        ->load($default_entity_id) : NULL;
      if (!empty($default_entity)) {
        $description = Link::fromTextAndUrl($this
          ->t('Download this PDF template populated with data from the @type %label (@id).', [
          '@type' => $default_entity_type,
          '%label' => $default_entity
            ->label(),
          '@id' => $default_entity_id,
        ]), $this->linkManipulator
          ->generateLink([
          'fid' => $this->entity
            ->id(),
          'entity_ids' => [
            $default_entity_type => [
              $default_entity_id,
            ],
          ],
        ]))
          ->toString();
      }
      $entity_ids = $storage
        ->getQuery()
        ->range(0, self::SELECT_MAX + 1)
        ->execute();
      if (count($entity_ids) > self::SELECT_MAX) {
        if (!isset($description)) {
          $description = $this
            ->t('Enter the title of a %type to test populating the PDF template.', [
            '%type' => $default_entity_type,
          ]);
        }
        $form['default_entity_id'] += [
          '#type' => 'entity_autocomplete',
          '#default_value' => $default_entity,
          '#description' => $description,
        ];
      }
      else {
        $options = [];
        foreach ($storage
          ->loadMultiple($entity_ids) as $id => $entity) {
          $options[$id] = $entity
            ->label();
        }
        if (!isset($description)) {
          $description = $this
            ->t('Choose a %type to test populating the PDF template.', [
            '%type' => $default_entity_type,
          ]);
        }
        $form['default_entity_id'] += [
          '#type' => 'select',
          '#options' => $options,
          '#empty_option' => $this
            ->t('- None -'),
          '#default_value' => $default_entity_id,
          '#description' => $description,
        ];
      }
    }
    else {
      $form['default_entity_id'] += [
        '#type' => 'hidden',
      ];
    }
    $fid = $fillpdf_form
      ->id();

    /** @var \Drupal\file\FileInterface $file_entity */
    $file_entity = File::load($fillpdf_form
      ->get('file')
      ->first()->target_id);
    $pdf_info_weight = 0;
    $form['pdf_info'] = [
      '#type' => 'fieldset',
      '#title' => $this
        ->t('PDF form information'),
      '#weight' => $form['default_entity_type']['#weight'] + 1,
      'submitted_pdf' => [
        '#type' => 'item',
        '#title' => $this
          ->t('Uploaded PDF'),
        '#description' => $file_entity
          ->getFileUri(),
        '#weight' => $pdf_info_weight++,
      ],
    ];
    $upload_location = FillPdf::buildFileUri($this
      ->config('fillpdf.settings')
      ->get('template_scheme'), 'fillpdf');
    if (!$this->fileSystem
      ->prepareDirectory($upload_location, FileSystemInterface::CREATE_DIRECTORY + FileSystemInterface::MODIFY_PERMISSIONS)) {
      $this
        ->messenger()
        ->addError($this
        ->t('The directory %directory does not exist or is not writable. Please check permissions.', [
        '%directory' => $this->fileSystem
          ->realpath($upload_location),
      ]));
    }
    else {
      $form['pdf_info']['upload_pdf'] = [
        '#type' => 'managed_file',
        '#title' => $this
          ->t('Update PDF template'),
        '#accept' => 'application/pdf',
        '#upload_validators' => [
          'file_validate_extensions' => [
            'pdf',
          ],
        ],
        '#upload_location' => $upload_location,
        '#description' => $this
          ->t('Update the PDF file used as template by this form.'),
        '#weight' => $pdf_info_weight++,
      ];
    }
    $form['pdf_info']['sample_populate'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Sample PDF'),
      '#description' => $this
        ->t('@link<br />If you have set a custom path on this PDF, the sample will be saved there silently.', [
        '@link' => Link::fromTextAndUrl($this
          ->t('See which fields are which in this PDF.'), $this->linkManipulator
          ->generateLink([
          'fid' => $fid,
          'sample' => TRUE,
        ]))
          ->toString(),
      ]),
      '#weight' => $pdf_info_weight++,
    ];
    $form['pdf_info']['form_id'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Form info'),
      '#description' => $this
        ->t('Form ID: [@fid].  Populate this form with entity IDs, such as %path . For more usage examples, see <a href="@documentation">the documentation</a>.', [
        '@fid' => $fid,
        '%path' => "/fillpdf?fid={$fid}&entity_ids[]=node:10&entity_ids[]=user:7",
        '@documentation' => 'https://www.drupal.org/docs/8/modules/fillpdf/usage#makelink',
      ]),
      '#weight' => $pdf_info_weight,
    ];
    $available_schemes = $form['scheme']['widget']['#options'];

    // If only one option is available, this is 'none', so there's nothing to
    // chose.
    if (count($available_schemes) == 1) {
      $form['scheme']['#type'] = 'hidden';
      $form['destination_path']['#type'] = 'hidden';
      $form['destination_redirect']['#type'] = 'hidden';
    }
    else {
      $form['storage_download'] = [
        '#type' => 'fieldset',
        '#title' => $this
          ->t('Storage and download'),
        '#weight' => $form['pdf_info']['#weight'] + 1,
        '#open' => TRUE,
        '#attached' => [
          'library' => [
            'fillpdf/form',
          ],
        ],
      ];
      $form['storage_download']['storage'] = [
        '#type' => 'container',
      ];

      // @todo: Check for empty value after Core issue is fixed.
      // See: https://www.drupal.org/project/drupal/issues/1585930
      $states_no_scheme = [
        ':input[name="scheme"]' => [
          'value' => '_none',
        ],
      ];
      $form['scheme']['#group'] = 'storage';
      $form['destination_path']['#group'] = 'storage';
      $form['destination_path']['widget']['0']['value']['#field_prefix'] = 'fillpdf/';
      $form['destination_path']['#states'] = [
        'invisible' => $states_no_scheme,
      ];
      $form['destination_path']['token_tree'] = $this->adminFormHelper
        ->getAdminTokenForm();
      $description = $this
        ->t('If filled PDFs should be automatically saved to disk, chose a file storage');
      $description .= isset($available_schemes['public']) ? '; ' . $this
        ->t('note that %public storage does not provide any access control.', [
        '%public' => 'public://',
      ]) : '.';
      $description .= ' ' . $this
        ->t('Otherwise, filled PDFs are sent to the browser for download.');
      $form['storage_download']['storage']['description_scheme_none'] = [
        '#type' => 'item',
        '#description' => $description,
        '#weight' => 22,
        '#states' => [
          'visible' => $states_no_scheme,
        ],
      ];
      $form['storage_download']['storage']['description_scheme_set'] = [
        '#type' => 'item',
        '#description' => $this
          ->t('As PDFs are saved to disk, make sure you include the <em>&download=1</em> flag to send them to the browser as well.'),
        '#weight' => 23,
        '#states' => [
          'invisible' => $states_no_scheme,
        ],
      ];
      $form['destination_redirect']['#group'] = 'storage_download';
      $form['destination_redirect']['#states'] = [
        'invisible' => $states_no_scheme,
      ];
    }
    $form['additional_settings'] = [
      '#type' => 'details',
      '#title' => $this
        ->t('Additional settings'),
      '#weight' => $form['pdf_info']['#weight'] + 1,
      '#open' => $fillpdf_form && (!empty($fillpdf_form->replacements->value) || !empty($fillpdf_form->pdftk_encryption->value) || !empty($fillpdf_form->permissions->value) || !empty($fillpdf_form->owner_password->value) || !empty($fillpdf_form->user_password->value)),
    ];
    $form['replacements']['#group'] = 'additional_settings';
    $form['additional_settings']['security'] = [
      '#name' => 'security',
      '#type' => 'details',
      '#title' => t('PDF Security (currently only works with pdftk)'),
      '#weight' => 100,
      '#open' => $fillpdf_form && (!empty($fillpdf_form->pdftk_encryption->value) || !empty($fillpdf_form->permissions->value) || !empty($fillpdf_form->owner_password->value) || !empty($fillpdf_form->user_password->value)),
    ];
    $form['pdftk_encryption']['#group'] = 'security';
    $form['permissions']['#group'] = 'security';
    $form['owner_password']['#group'] = 'security';
    $form['user_password']['#group'] = 'security';

    // @todo: Add a button to let them attempt re-parsing if it failed.
    $form['fillpdf_fields']['fields'] = FillPdf::embedView('fillpdf_form_fields', 'block_1', $fillpdf_form
      ->id());
    $form['fillpdf_fields']['#weight'] = 100;
    $form['export_fields'] = [
      '#prefix' => '<div>',
      '#markup' => Link::fromTextAndUrl($this
        ->t('Export these field mappings'), Url::fromRoute('entity.fillpdf_form.export_form', [
        'fillpdf_form' => $fillpdf_form
          ->id(),
      ]))
        ->toString(),
      '#suffix' => '</div>',
      '#weight' => 100,
    ];
    $form['import_fields'] = [
      '#prefix' => '<div>',
      '#markup' => Link::fromTextAndUrl($this
        ->t('Import a previous export into this PDF'), Url::fromRoute('entity.fillpdf_form.import_form', [
        'fillpdf_form' => $fillpdf_form
          ->id(),
      ]))
        ->toString(),
      '#suffix' => '</div>',
      '#weight' => 100,
    ];
    return $form;
  }

  /**
   * Helper function providing available entity type select options.
   *
   * After translating entity types to token types, we're filtering out those
   * entity types that don't have any tokens supplied, because without tokens
   * available there is no point populating a FillPDF form with an entity.
   *
   * @return string[][]
   *   Multidimensional array of entity type options, keyed by entity type and
   *   grouped by the group label (i.e. 'Content' or 'Config').
   */
  protected function getEntityTypeOptions() {
    $token_info = $this->tokenResolver
      ->getTokenService()
      ->getInfo();
    $entity_mapper = $this->tokenResolver
      ->getEntityMapper();
    $all_tokens = $token_info['types'];
    $options = [];
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type => $definition) {

      // Exclude entity types with no tokens being provided.
      $token_type = $entity_mapper
        ->getTokenTypeForEntityType($entity_type, FALSE);
      if (!$token_type || empty($all_tokens[$token_type])) {
        continue;
      }
      $label = $definition
        ->getLabel();
      $group_label = (string) $definition
        ->getGroupLabel();
      $options[$group_label][$entity_type] = "{$entity_type} ({$label})";
    }
    foreach ($options as &$group_options) {

      // Sort each group's list alphabetically.
      array_multisort($group_options, SORT_ASC, SORT_NATURAL);
    }

    // Make sure that 'Content' entities are listed on top.
    $content = (string) $this
      ->t('Content', [], [
      'context' => 'Entity type group',
    ]);
    return [
      $content => $options[$content],
    ] + $options;
  }

  /**
   * AJAX callback updating the 'default_entity_id' element.
   *
   * This is triggered whenever either the default entity type is changed or
   * another default entity ID is chosen. It replaces the 'default_entity_id'
   * form element. If triggered by the 'default_entity_type' element, both the
   * description and the autocomplete are reset, the latter being fed with
   * referenceable entities of the chosen entity type. Otherwise, only the
   * description is rebuilt reflecting the chosen default entity ID.
   *
   * @param array $form
   *   An associative array containing the structure of the form.
   * @param \Drupal\Core\Form\FormStateInterface $form_state
   *   The current state of the form.
   *
   * @return array
   *   A render array containing the replacement form element.
   */
  public function ajaxUpdateEntityId(array &$form, FormStateInterface $form_state) {
    $element = $form['default_entity_id'];
    $triggering_element = reset($form_state
      ->getTriggeringElement()['#array_parents']);
    if ($triggering_element == 'default_entity_type') {
      unset($element['#value']);
    }
    return $element;
  }

  /**
   * {@inheritdoc}
   *
   * @todo Remove this (imperfect) workaround once the Core issue is fixed.
   *   See https://www.drupal.org/project/fillpdf/issues/3046178.
   */
  protected function actions(array $form, FormStateInterface $form_state) {
    $actions = parent::actions($form, $form_state);

    // Replace inherited '?destination' query parameter with current URL.

    /** @var \Drupal\Core\Url $route_info */
    $route_info = $actions['delete']['#url'];
    $route_info
      ->setOption('query', []);
    $actions['delete']['#url'] = $route_info;
    return $actions;
  }

  /**
   * {@inheritdoc}
   *
   * @throws \Drupal\Core\Entity\EntityStorageException
   * @throws \Drupal\Core\Entity\EntityMalformedException
   */
  public function save(array $form, FormStateInterface $form_state) {

    /** @var \Drupal\fillpdf\FillPdfFormInterface $entity */
    $entity = $this
      ->getEntity();
    $this
      ->messenger()
      ->addStatus($this
      ->t('FillPDF Form %link has been updated.', [
      '%link' => $entity
        ->toLink()
        ->toString(),
    ]));
    if ($form_state
      ->getValue('upload_pdf')) {
      $existing_fields = $entity
        ->getFormFields();

      /** @var \Drupal\file\FileInterface $new_file */
      $new_file = File::load($form_state
        ->getValue('upload_pdf')['0']);
      $new_file
        ->setPermanent();
      $new_file
        ->save();

      // Set the new file to our unsaved FillPdf form and parse its fields.
      $entity->file = $new_file;
      $new_fields = $this->inputHelper
        ->parseFields($entity);

      // Enrich the new field objects with existing values. Note that we pass
      // them in seemingly-reverse order since we want to import the EXISTING
      // fields into the NEW fields.
      $non_matching_fields = $this->serializer
        ->importFormFields($existing_fields, $new_fields, FALSE);

      // Save new fields.

      /** @var \Drupal\fillpdf\FillPdfFormFieldInterface $field */
      foreach ($new_fields as $field) {
        $field
          ->save();
      }

      // Delete existing fields. Importing the new fields saved them.

      /** @var \Drupal\fillpdf\FillPdfFormFieldInterface $field */
      foreach ($existing_fields as $field) {
        $field
          ->delete();
      }
      if (count($existing_fields)) {
        $this
          ->messenger()
          ->addStatus($this
          ->t('Your previous field mappings have been transferred to the new PDF template you uploaded.'));
      }
      if (count($non_matching_fields)) {
        $message = [
          '#prefix' => $this
            ->t("These keys couldn't be found in the new PDF:"),
          [
            '#theme' => 'item_list',
            '#items' => array_keys($non_matching_fields),
          ],
        ];
        $this
          ->messenger()
          ->addWarning(\Drupal::service('renderer')
          ->render($message));
      }
      $this
        ->messenger()
        ->addStatus($this
        ->t('You might also want to update the <em>Filename pattern</em> field; this has not been changed.'));
    }

    // Save custom form elements' values, resetting default_entity_id to NULL,
    // if not matching the default entity type.
    $default_entity_type = $form_state
      ->getValue('default_entity_type');
    $default_entity_id = $default_entity_type == $form['default_entity_id']['#target_type'] ? $form_state
      ->getValue('default_entity_id') : NULL;
    $entity
      ->set('default_entity_type', $default_entity_type)
      ->set('default_entity_id', $default_entity_id)
      ->save();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentEntityForm::$entity protected property The entity being used by this form. Overrides EntityForm::$entity 9
ContentEntityForm::$entityRepository protected property The entity repository service.
ContentEntityForm::$entityTypeBundleInfo protected property The entity type bundle info service.
ContentEntityForm::$time protected property The time service.
ContentEntityForm::addRevisionableFormFields protected function Add revision form fields if the entity enabled the UI.
ContentEntityForm::buildEntity public function Builds an updated entity object based upon the submitted form values. Overrides EntityForm::buildEntity 3
ContentEntityForm::copyFormValuesToEntity protected function Copies top-level form values to entity properties Overrides EntityForm::copyFormValuesToEntity
ContentEntityForm::flagViolations protected function Flags violations for the current form. 4
ContentEntityForm::getBundleEntity protected function Returns the bundle entity of the entity, or NULL if there is none.
ContentEntityForm::getEditedFieldNames protected function Gets the names of all fields edited in the form. 4
ContentEntityForm::getFormDisplay public function Gets the form display. Overrides ContentEntityFormInterface::getFormDisplay
ContentEntityForm::getFormLangcode public function Gets the code identifying the active form language. Overrides ContentEntityFormInterface::getFormLangcode
ContentEntityForm::getNewRevisionDefault protected function Should new revisions created on default.
ContentEntityForm::init protected function Initializes the form state and the entity before the first form build. Overrides EntityForm::init 1
ContentEntityForm::initFormLangcodes protected function Initializes form language code values.
ContentEntityForm::isDefaultFormLangcode public function Checks whether the current form language matches the entity one. Overrides ContentEntityFormInterface::isDefaultFormLangcode
ContentEntityForm::prepareEntity protected function Prepares the entity object before the form is built first. Overrides EntityForm::prepareEntity 1
ContentEntityForm::setFormDisplay public function Sets the form display. Overrides ContentEntityFormInterface::setFormDisplay
ContentEntityForm::showRevisionUi protected function Checks whether the revision form fields should be added to the form.
ContentEntityForm::submitForm public function This is the default entity object builder function. It is called before any other submit handler to build the new entity object to be used by the following submit handlers. At this point of the form workflow the entity is validated and the form state… Overrides EntityForm::submitForm 3
ContentEntityForm::updateChangedTime public function Updates the changed time of the entity.
ContentEntityForm::updateFormLangcode public function Updates the form language to reflect any change to the entity language.
ContentEntityForm::validateForm public function Button-level validation handlers are highly discouraged for entity forms, as they will prevent entity validation from running. If the entity is going to be saved during the form submission, this method should be manually invoked from the button-level… Overrides FormBase::validateForm 3
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
EntityForm::$entityTypeManager protected property The entity type manager. 3
EntityForm::$moduleHandler protected property The module handler service.
EntityForm::$operation protected property The name of the current operation.
EntityForm::$privateEntityManager private property The entity manager.
EntityForm::actionsElement protected function Returns the action form element for the current entity form.
EntityForm::afterBuild public function Form element #after_build callback: Updates the entity with submitted data.
EntityForm::buildForm public function Form constructor. Overrides FormInterface::buildForm 10
EntityForm::getBaseFormId public function Returns a string identifying the base form. Overrides BaseFormIdInterface::getBaseFormId 5
EntityForm::getEntity public function Gets the form entity. Overrides EntityFormInterface::getEntity
EntityForm::getEntityFromRouteMatch public function Determines which entity will be used by this form from a RouteMatch object. Overrides EntityFormInterface::getEntityFromRouteMatch 1
EntityForm::getFormId public function Returns a unique string identifying the form. Overrides FormInterface::getFormId 10
EntityForm::getOperation public function Gets the operation identifying the form. Overrides EntityFormInterface::getOperation
EntityForm::prepareInvokeAll protected function Invokes the specified prepare hook variant.
EntityForm::processForm public function Process callback: assigns weights and hides extra fields.
EntityForm::setEntity public function Sets the form entity. Overrides EntityFormInterface::setEntity
EntityForm::setEntityManager public function Sets the entity manager for this form. Overrides EntityFormInterface::setEntityManager
EntityForm::setEntityTypeManager public function Sets the entity type manager for this form. Overrides EntityFormInterface::setEntityTypeManager
EntityForm::setModuleHandler public function Sets the module handler for this form. Overrides EntityFormInterface::setModuleHandler
EntityForm::setOperation public function Sets the operation for this form. Overrides EntityFormInterface::setOperation
EntityForm::__get public function
EntityForm::__set public function
FillPdfFormForm::$adminFormHelper protected property The FillPdf admin form helper.
FillPdfFormForm::$fileSystem protected property The file system service.
FillPdfFormForm::$inputHelper protected property The FillPdf link manipulator.
FillPdfFormForm::$linkManipulator protected property The FillPdf link manipulator.
FillPdfFormForm::$serializer protected property The FillPdf serializer.
FillPdfFormForm::$tokenResolver protected property The FillPDF token resolver.
FillPdfFormForm::actions protected function @todo Remove this (imperfect) workaround once the Core issue is fixed. See https://www.drupal.org/project/fillpdf/issues/3046178. Overrides EntityForm::actions
FillPdfFormForm::ajaxUpdateEntityId public function AJAX callback updating the 'default_entity_id' element.
FillPdfFormForm::create public static function Instantiates a new instance of this class. Overrides ContentEntityForm::create
FillPdfFormForm::form public function Gets the actual form array to be built. Overrides ContentEntityForm::form
FillPdfFormForm::getEntityTypeOptions protected function Helper function providing available entity type select options.
FillPdfFormForm::save public function Overrides EntityForm::save
FillPdfFormForm::SELECT_MAX constant Maximum number of entities to be listed in a select.
FillPdfFormForm::__construct public function Constructs a FillPdfFormForm object. Overrides ContentEntityForm::__construct
FormBase::$configFactory protected property The config factory. 1
FormBase::$requestStack protected property The request stack. 1
FormBase::$routeMatch protected property The route match.
FormBase::config protected function Retrieves a configuration object.
FormBase::configFactory protected function Gets the config factory for this form. 1
FormBase::container private function Returns the service container.
FormBase::currentUser protected function Gets the current user.
FormBase::getRequest protected function Gets the request object.
FormBase::getRouteMatch protected function Gets the route match.
FormBase::logger protected function Gets the logger for a specific channel.
FormBase::redirect protected function Returns a redirect response object for the specified route. Overrides UrlGeneratorTrait::redirect
FormBase::resetConfigFactory public function Resets the configuration factory.
FormBase::setConfigFactory public function Sets the config factory for this form.
FormBase::setRequestStack public function Sets the request stack object to use.
LinkGeneratorTrait::$linkGenerator protected property The link generator. 1
LinkGeneratorTrait::getLinkGenerator Deprecated protected function Returns the link generator.
LinkGeneratorTrait::l Deprecated protected function Renders a link to a route given a route name and its parameters.
LinkGeneratorTrait::setLinkGenerator Deprecated public function Sets the link generator service.
LoggerChannelTrait::$loggerFactory protected property The logger channel factory service.
LoggerChannelTrait::getLogger protected function Gets the logger for a specific channel.
LoggerChannelTrait::setLoggerFactory public function Injects the logger channel factory.
MessengerTrait::$messenger protected property The messenger. 29
MessengerTrait::messenger public function Gets the messenger. 29
MessengerTrait::setMessenger public function Sets the messenger.
RedirectDestinationTrait::$redirectDestination protected property The redirect destination service. 1
RedirectDestinationTrait::getDestinationArray protected function Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.
RedirectDestinationTrait::getRedirectDestination protected function Returns the redirect destination service.
RedirectDestinationTrait::setRedirectDestination public function Sets the redirect destination service.
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
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.
UrlGeneratorTrait::$urlGenerator protected property The url generator.
UrlGeneratorTrait::getUrlGenerator Deprecated protected function Returns the URL generator service.
UrlGeneratorTrait::setUrlGenerator Deprecated public function Sets the URL generator service.
UrlGeneratorTrait::url Deprecated protected function Generates a URL or path for a specific route based on the given parameters.