You are here

public function PurgePurgerBundleProcess::__construct in Purge 7.2

Constructor for the Configuration bundle.

File

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

Class

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

Code

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;
            }
          }
        }
      }
    }
  }
}