You are here

public function AkamaiClientV3::buildConfigurationForm in Akamai 8.3

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 PluginFormInterface::buildConfigurationForm

File

src/Plugin/Client/AkamaiClientV3.php, line 142

Class

AkamaiClientV3
Defines the CCUv3 client version for Akamai.

Namespace

Drupal\akamai\Plugin\Client

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $config = $this->configFactory
    ->get('akamai.settings');
  $default_action = key(array_filter($config
    ->get('action_v3')));
  $form['action'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Clearing Action Type Default'),
    '#default_value' => in_array($default_action, $this
      ->validActions()) ? $default_action : 'delete',
    '#options' => [
      'delete' => $this
        ->t('Delete'),
      'invalidate' => $this
        ->t('Invalidate'),
    ],
    '#description' => $this
      ->t('The default clearing action. The options are <em>delete</em> (which deletes the item from the Akamai cache) and <em>invalidate</em> (which leaves the item in the cache, but invalidates it so that the origin will be hit on the next request).'),
    '#required' => TRUE,
  ];
  $form['purge_urls_with_hostname'] = [
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Purge URLs With Common Hostname'),
    '#default_value' => $config
      ->get('purge_urls_with_hostname'),
    '#description' => $this
      ->t('Sends Base Path as "hostname" Fast Purge API request data member when purging URLs'),
  ];
  return $form;
}