You are here

function backup_migrate_item::all_items in Backup and Migrate 7.2

Same name and namespace in other branches
  1. 8.2 includes/crud.inc \backup_migrate_item::all_items()
  2. 8.3 includes/crud.inc \backup_migrate_item::all_items()
  3. 6.3 includes/crud.inc \backup_migrate_item::all_items()
  4. 6.2 includes/crud.inc \backup_migrate_item::all_items()
  5. 7.3 includes/crud.inc \backup_migrate_item::all_items()

Get all of the given items.

2 calls to backup_migrate_item::all_items()
backup_migrate_item::get_list in includes/crud.inc
Get a table of all items of this type.
backup_migrate_item::item in includes/crud.inc
A particular item.

File

includes/crud.inc, line 617
CRUD functions for backup and migrate types (schedules, profiles etc.).

Class

backup_migrate_item
A base class for items which can be stored in the database, listed, edited, deleted etc.

Code

function all_items() {
  static $cache = array();

  // Allow other modules to declare destinations programatically.
  $items = array();
  foreach (module_implements($this->db_table) as $module) {
    $fn = $module . '_' . $this->db_table;
    $items += $fn();
  }

  // Get any items stored as a variable. This allows destinations to be defined in settings.php
  $defaults = (array) variable_get($this->db_table . '_defaults', array());
  foreach ($defaults as $info) {
    if (is_array($info) && ($item = $this
      ->create($info))) {
      $items[$item
        ->get_id()] = $item;
    }
  }

  // Get the items from the db.
  $result = db_query("SELECT * FROM {{$this->db_table}}", array(), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  foreach ($result as $info) {
    $info = $this
      ->decode_db_row($info);
    if ($item = $this
      ->create($info)) {
      $item->storage = empty($items[$item
        ->get_id()]) ? BACKUP_MIGRATE_STORAGE_DB : BACKUP_MIGRATE_STORAGE_OVERRIDEN;
      $items[$item
        ->get_id()] = $item;
    }
  }

  // Allow other modules to alter the items. This should maybe be before the db override code above
  // but then the filters are not able to set defaults for missing values. Other modules should just
  // be careful not to overwrite the user's UI changes in an unexpected way.
  drupal_alter($this->db_table, $items);
  return $items;
}