You are here

abstract class Purge in Purge 7.2

Class for purge configuration management.

Defines a basic configuration item.

Hierarchy

Expanded class hierarchy of Purge

1 string reference to 'Purge'
purge_menu in ./purge_ui.module
Implements hook_menu().

File

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

View source
abstract class Purge {
  public $name = '';
  public $description = '';
  public $available = 1;
  public $enabled = 1;
  public $access = array(
    PURGE_ACCESS_FULL,
  );
  public $item = array();
  public $depend = array();
  public $option = array();

  /**
   * Only serialize the static values.
   */
  public function __sleep() {
    $return_properties = array();
    $basic_properties = array(
      'name',
      'description',
      'enabled',
      'access',
    );
    $return_properties = $basic_properties;

    // Build the static item array so we don't have to serialize all objects.
    if (count($this->item)) {

      // Make sure the item array is serialized once finished.
      $return_properties[] = 'item';

      //
      foreach ($this->item as $type_name => $items) {

        // Check we're parsing an option and this is a Purger.
        if ($this instanceof PurgePurger && ($type_name = 'option')) {

          // Store the option values in this purges item array.
          $this->item['option'] = array();
          foreach ($this->option as $option_name => $option) {
            $this->item['option'][$option_name] = array();

            // Set the current value of the option in the item array.
            $this->item['option'][$option_name] = $option->value;
          }
        }
        else {
          $this->item[$type_name] = array();

          // .
          foreach ($items as $item_name => $item) {
            $this->item[$type_name][] = $item_name;
          }
        }
      }
    }
    return $return_properties;
  }

  /**
   * Does basic dependency checks for builtin dependencies.
   *
   */
  public function validate() {
    $errors = array();

    // Check if we're a Dependable item or if we have dependencies in the items.
    if ($this instanceof PurgeDependable || count($this->item['depend']) > 0) {

      // Check if we have depend objects on board.
      if (count($this->depend) > 0) {
        foreach ($this->depend as $depend_name => $depend) {
          $depend_errors = array();
          $depend_errors = $depend
            ->validate();
          foreach ($depend_errors as $depend_error) {
            $errors[] = $depend_error;
          }
        }
      }
    }
    return $errors;
  }

}

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