You are here

public function PurgePurgerBundleAPI::merge in Purge 7.2

Merges another bundle into this one.

Parameters

object $merge_bundle: A bundle, instance of PurgeBundleBasic.

bool $overwrite: Overwrites with the merge bundle value should a duplicate be found.

File

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

Class

PurgePurgerBundleAPI
Provides a full bundle.

Code

public function merge($merge_bundle, $overwrite = 1) {

  // First check if this is actually another bundle.
  if (!$merge_bundle instanceof PurgePurgerBundle) {
    return;
  }

  // Loop through all types.
  foreach ($this->type as $type_name => $type) {

    // Walk the merge bundle item.
    foreach ($merge_bundle->{$type_name} as $item_name => $item) {

      // Check if the item exists in this bundle.
      if ($overwrite == 1 || !isset($this->{$type_name}[$item_name])) {

        // Set the merged item.
        $this->{$type_name}[$item_name] = clone $merge_bundle->{$type_name}[$item_name];
      }
    }
  }
}