You are here

class PurgePurgerBundleProcess in Purge 7.2

Class definition for the runtime bundle. This class is used for processing the purge requests during runtine.

Hierarchy

Expanded class hierarchy of PurgePurgerBundleProcess

File

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

View source
class PurgePurgerBundleProcess extends PurgePurgerBundle {
  public $purgeables;

  /**
   * Constructor for the Configuration bundle.
   */
  public function __construct() {
    $runtime_data = array();

    // First check if the data is in cache.
    // If not, get from parent.
    $all_data = $this
      ->get_data();

    // Create the types and keep the data for caching.
    $this
      ->set_types($all_data);
    $runtime_data['type'] = $all_data['type'];

    // For loop through the set_data and collect active items.
    $data['purger'] = array();
    foreach ($all_data['purger'] as $purger_name => $purger_data) {

      // check if the purger is enabled.
      if (strpos($purger_data, "s:7:\"enabled\";i:1")) {
        $data['purger'][$purger_name] = $purger_data;

        // Create the purger object.
        $this->purger[$purger_name] = unserialize($purger_data);

        // Now loop through the pointers
        foreach ($this->purger[$purger_name]->pointers as $pointer_type => $item_names) {
          foreach ($item_names as $item_name) {
            $item_data = $all_data[$pointer_type][$item_name];

            // Check in the data if the item is enabled.
            if (strpos($item_data, "s:7:\"enabled\";i:1")) {

              // Check if the item object isn't allready there.
              if (isset($this->{$pointer_type}[$item_name])) {

                // If so just link the pointer to it.
                $this->purger[$purger_name]->{$pointer_type}[$item_name] = $this->{$pointer_type}[$item_name];
              }
              else {

                // Create the object from data
                $this->{$pointer_type}[$item_name] = unserialize($item_data);

                // Check if it item has cacheable data
                if ($this->{$pointer_type}[$item_name] instanceof PurgeCacheable) {
                  $this->{$pointer_type}[$item_name]
                    ->cache();
                }

                // And link the pointer
                $this->purger[$purger_name]->{$pointer_type}[$item_name] = $this->{$pointer_type}[$item_name];

                // And keep the item data
                $data[$pointer_type][$item_name] = $item_data;
              }
            }
          }
        }
      }
    }
  }

  /**
   * Process all requests.
   */
  public function process() {

    // Walk the purgeables.
    foreach ($this->purgeables as $purgeable_type_name => $purgeables) {
      foreach ($purgeables as $purgeable) {

        // Pass all purgers.
        foreach ($this->purger as $purger_name => $purger) {

          // Handle purgeable URLs.
          if ($purgeable_type_name == 'urls') {
            if ($this->purger[$purger_name] instanceof PurgeProcessableUrl) {

              // Process the Purgeable URL.
              $this->purger[$purger_name]
                ->process_url($purgeable);
            }
          }
        }
      }
    }

    // Now process the queues.
    foreach ($this->queue as $queue) {

      //if (count($queue->queue) > 0) {
      $queue
        ->process();

      // }
    }
  }

}

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
PurgePurger::$domain public property
PurgePurger::$handler public property
PurgePurger::$header public property
PurgePurger::$queue public property
PurgePurger::$target public property
PurgePurgerBundle::$type public property
PurgePurgerBundle::get_data public function Function to select data from the dataset.
PurgePurgerBundle::set_types public function Function to set the type objects.
PurgePurgerBundle::__sleep public function Override for parents sleep to make sure we include the bundled objects. Overrides Purge::__sleep
PurgePurgerBundle::__wakeup public function Set the item objects linked in this bundle when waking up.
PurgePurgerBundleProcess::$purgeables public property
PurgePurgerBundleProcess::process public function Process all requests.
PurgePurgerBundleProcess::__construct public function Constructor for the Configuration bundle.