You are here

public function CacheControlBlockForm::buildForm in Akamai 8.2

Same name and namespace in other branches
  1. 8 lib/Drupal/akamai/Form/CacheControlBlockForm.php \Drupal\akamai\Form\CacheControlBlockForm::buildForm()

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 FormInterface::buildForm

File

src/Form/CacheControlBlockForm.php, line 28
Contains \Drupal\akamai\Form\CacheControlBlockForm.

Class

CacheControlBlockForm
Defines a form that configures Akamai settings.

Namespace

Drupal\akamai\Form

Code

public function buildForm(array $form, array &$form_state) {
  $akamai_config = \Drupal::config('akamai.settings');
  $path = check_plain(current_path());
  $nid = arg(1);
  if (arg(0) == 'node' && is_numeric($nid) && arg(2) == NULL) {
    $path = arg(0) . '/' . $nid;
    $form['#node'] = node_load($nid);
  }
  else {
    $form['#node'] = NULL;
  }
  $path_label = $path;
  if ($path == \Drupal::config('system.site')
    ->get('page.front')) {
    $path_label = t("[frontpage]");
  }
  $form['path'] = array(
    '#type' => 'hidden',
    '#value' => $path,
  );
  $form['message'] = array(
    '#type' => 'item',
    '#title' => t('Refresh URL'),
    '#markup' => $path_label,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Refresh Akamai Cache'),
  );
  return $form;
}