Commit 5e0d3422 authored by Giles McCormick Smith's avatar Giles McCormick Smith Committed by Stephen Mulvihill
Browse files

Issue #3301320: Does this work with Azure Frontdoor

parent dde4a7c5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -14,6 +14,6 @@
    }
  ],
  "require": {
    "drupal/purge": "^3.0@beta"
    "drupal/purge": "^3.2"
  }
}
+16 −0
Original line number Diff line number Diff line
@@ -38,6 +38,20 @@ class AzureCdnSettingsForm extends ConfigFormBase {
      '#title' => $this->t('Purge settings'),
    ];

    $form['purge_settings']['endpoint_type'] = [
      '#type' => 'select',
      '#title' => $this->t('Endpoint type'),
      '#options' => [
        'endpoints' => $this
          ->t('Azure CDN'),
        'afdEndpoints' => $this
          ->t('Azure FrontDoor'),
        ],
      '#required' => TRUE,
      '#default_value' => $config->get('endpoint_type'),
    ];


    $form['purge_settings']['devel'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Enable debug mode'),
@@ -156,6 +170,7 @@ class AzureCdnSettingsForm extends ConfigFormBase {
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    // General config.
    $endpoint_type = $form_state->getValue('endpoint_type');
    $devel = $form_state->getValue('devel');
    $chunk_size = $form_state->getValue('chunk_size');

@@ -173,6 +188,7 @@ class AzureCdnSettingsForm extends ConfigFormBase {
    $api_version = $form_state->getValue('api_version');

    $this->config('azure_cdn_purge.settings')
      ->set('endpoint_type', $endpoint_type)
      ->set('devel', $devel)
      ->set('chunk_size', $chunk_size)
      ->set('tenant_id', $tenant_id)
+2 −1
Original line number Diff line number Diff line
@@ -124,6 +124,7 @@ class AzurePurger extends PurgerBase implements PurgerInterface {

      if ($invalidation_type == 'path') {
        // Get Azure URI parameters.
        $endpoint_type = $this->config->get('endpoint_type');
        $devel = $this->config->get('devel');
        $endpoint_name = $this->config->get('endpoint_name');
        $profile_name = $this->config->get('profile_name');
@@ -155,7 +156,7 @@ class AzurePurger extends PurgerBase implements PurgerInterface {

        $access_token = $response_auth['access_token'];

        $url = "https://management.azure.com/subscriptions/" . $subscription_id . "/resourceGroups/" . $resource_group_name . "/providers/Microsoft.Cdn/profiles/" . $profile_name . "/endpoints/" . $endpoint_name . "/purge?api-version=" . $api_version;
        $url = "https://management.azure.com/subscriptions/" . $subscription_id . "/resourceGroups/" . $resource_group_name . "/providers/Microsoft.Cdn/profiles/" . $profile_name . "/$endpoint_type/" . $endpoint_name . "/purge?api-version=" . $api_version;

        $body_contents = [
          'contentPaths' => $targets_to_purge,