You are here

public function PurgePurgerUrl::process_url in Purge 7.2

Process purgeables.

Parameters

array $purgeablea_url:

Return value

array $queue_item

Overrides PurgeProcessableUrl::process_url

File

includes/purge.class.inc, line 681
Contains all class and interface definitions for Purge.

Class

PurgePurgerUrl
Class definition for the Basic Url Purger.

Code

public function process_url($purgeable_url) {
  $purges = array();

  // First set all processable items with the purgeable data.
  foreach ($this->pointers as $pointer_type => $pointers) {
    foreach ($pointers as $pointer_name) {
      if ($pointer_type != 'handler') {
        if ($this->{$pointer_type}[$pointer_name] instanceof PurgeProcessableUrl) {
          $this->{$pointer_type}[$pointer_name]
            ->process_url($purgeable_url);
        }
      }
    }

    // gather targets.
    $target_urls = array();
    foreach ($this->target as $target_name => $target) {
      foreach ($target->urls as $url) {
        $target_urls[] = $url;
      }
    }

    // Gather domains.
    $domains = array();
    foreach ($this->domain as $domain_name => $domain) {
      foreach ($domain->domains as $domain_domain) {
        $domains[] = $domain_domain;
      }
    }
    if ($this->options['domain']['purgeable_url_domain']) {
      $domains[] = parse_url($purgeable, PHP_URL_HOST);
    }

    // Gather headers.
    $headers = array();
    foreach ($this->header as $header_name => $header) {
      foreach ($header->headers as $header_key => $header_value) {
        $headers[$header_key] = $header_value;
      }
    }

    // Now lets fill the purges array
    $parsed_purgeable = parse_url($purgeable_url);
    foreach ($target_urls as $target_url) {
      foreach ($domains as $domain) {
        $purge_headers = $headers;

        // Add the host header.
        $purge_headers['Host'] = $domain;
        $purges[] = array(
          'purge_url' => $target_url . $parsed_purgeable['path'],
          'headers' => $purge_headers,
        );
      }
    }
  }

  // Get the hanlder and its options.
  $handler = $this->pointers['handler'][0];
  $handler_options = array();
  $handler_options = $this->options['handler'];
  $queue_item = array(
    'handler' => $handler,
    'handler_options' => $handler_options,
    'purges' => $purges,
  );
  $queue_name = $this->pointers['queue'][0];
  $this->queue[$queue_name]->queue[] = $queue_item;
}