You are here

public function DomPdf::buildConfigurationForm in Entity Print 8.2

Form constructor.

Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.

Parameters

array $form: An associative array containing the initial structure of the plugin form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().

Return value

array The form structure.

Overrides PdfEngineBase::buildConfigurationForm

File

src/Plugin/EntityPrint/PrintEngine/DomPdf.php, line 124

Class

DomPdf
A Entity Print plugin for the DomPdf library.

Namespace

Drupal\entity_print\Plugin\EntityPrint\PrintEngine

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $form['enable_html5_parser'] = [
    '#title' => $this
      ->t('Enable HTML5 Parser'),
    '#type' => 'checkbox',
    '#default_value' => $this->configuration['enable_html5_parser'],
    '#description' => $this
      ->t("Note, this library doesn't work without this option enabled."),
  ];
  $form['disable_log'] = [
    '#title' => $this
      ->t('Disable Log'),
    '#type' => 'checkbox',
    '#default_value' => $this->configuration['disable_log'],
    '#description' => $this
      ->t("Check to disable DomPdf logging to <code>@log_file_name</code> in Drupal's temporary directory.", [
      '@log_file_name' => self::LOG_FILE_NAME,
    ]),
  ];
  $form['enable_remote'] = [
    '#title' => $this
      ->t('Enable Remote URLs'),
    '#type' => 'checkbox',
    '#default_value' => $this->configuration['enable_remote'],
    '#description' => $this
      ->t('This settings must be enabled for CSS and Images to work unless you manipulate the source manually.'),
  ];
  $form['ssl_configuration'] = [
    '#type' => 'details',
    '#title' => $this
      ->t('SSL Configuration'),
    '#open' => !empty($this->configuration['cafile']) || empty($this->configuration['verify_peer']) || empty($this->configuration['verify_peer_name']),
  ];
  $form['ssl_configuration']['cafile'] = [
    '#title' => $this
      ->t('CA File'),
    '#type' => 'textfield',
    '#default_value' => $this->configuration['cafile'],
    '#description' => $this
      ->t('Path to the CA file. This may be needed for development boxes that use SSL. You can leave this empty in production.'),
  ];
  $form['ssl_configuration']['verify_peer'] = [
    '#title' => $this
      ->t('Verify Peer'),
    '#type' => 'checkbox',
    '#default_value' => $this->configuration['verify_peer'],
    '#description' => $this
      ->t("Verify an SSL Peer's certificate. For development only, do not disable this in production. See https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html"),
  ];
  $form['ssl_configuration']['verify_peer_name'] = [
    '#title' => $this
      ->t('Verify Peer Name'),
    '#type' => 'checkbox',
    '#default_value' => $this->configuration['verify_peer_name'],
    '#description' => $this
      ->t("Verify an SSL Peer's certificate. For development only, do not disable this in production. See https://curl.haxx.se/libcurl/c/CURLOPT_SSL_VERIFYPEER.html"),
  ];
  return $form;
}