You are here

public function HtaccessDisplayForm::buildForm in Htaccess 8.2

Form constructor.

Parameters

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

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/HtaccessDisplayForm.php, line 41
Administration pages.

Class

HtaccessDisplayForm
Defines a form to configure RSVP List module settings

Namespace

Drupal\htaccess\Form

Code

public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
  $config = $this
    ->config('htaccess.settings');
  $path = $request
    ->getPathInfo();
  $parts = explode('/', $path);
  $action = $parts[6];
  $id = $parts[7];
  $select = Database::getConnection()
    ->select('htaccess', 'h');
  $select
    ->fields('h');
  $select
    ->condition('id', $id);
  $results = $select
    ->execute();
  $result = $results
    ->fetch();
  $deploymentlink = Link::createFromRoute('Deployment Page', 'htaccess.admin_deployment');
  $htaccess = "<p>" . t('Back to %deployment_page', array(
    '%deployment_page' => $deploymentlink
      ->toString(),
  )) . "</p>";
  $htaccess .= "<code>" . str_replace(PHP_EOL, "<br />", \Drupal\Component\Utility\SafeMarkup::checkPlain($result->htaccess)) . "</code>";
  $form['htaccess_settings_display'] = array(
    '#type' => 'fieldset',
    '#title' => $id . '. ' . $result->name,
    '#description' => $htaccess,
  );
  return parent::buildForm($form, $form_state);
}