You are here

class PurgePurgerUrl in Purge 7.2

Class definition for the Basic Url Purger.

Hierarchy

Expanded class hierarchy of PurgePurgerUrl

File

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

View source
class PurgePurgerUrl extends PurgePurger implements PurgeProcessableUrl {
  public $purger = array();

  /**
   * Process purgeables.
   *
   * @param array $purgeablea_url
   *
   * @return array $queue_item
   */
  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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Purge::$access public property
Purge::$available public property
Purge::$depend public property
Purge::$description public property
Purge::$enabled public property
Purge::$item public property
Purge::$name public property
Purge::$option public property
Purge::validate public function Does basic dependency checks for builtin dependencies. 5
Purge::__sleep public function Only serialize the static values. 1
PurgePurger::$domain public property
PurgePurger::$handler public property
PurgePurger::$header public property
PurgePurger::$queue public property
PurgePurger::$target public property
PurgePurgerUrl::$purger public property
PurgePurgerUrl::process_url public function Process purgeables. Overrides PurgeProcessableUrl::process_url