You are here

public function Gardener::load in Backup and migrate prune 7

Same name and namespace in other branches
  1. 7.2 class/Gardener.php \Gardener::load()

Load the settings of a gardener and return an instance of it.

Throws

ErrorException

1 call to Gardener::load()
Gardener::__construct in class/Gardener.php

File

class/Gardener.php, line 76
Gardener class implementation file

Class

Gardener
Gardener class implementation

Code

public function load($gardener_id) {
  backup_migrate_include('destinations');
  if (!is_numeric($gardener_id)) {
    throw new ErrorException(t('Cannot load a gardener with an invalid ID.'), \GARDENER::INVALID_ID, WATCHDOG_ERROR);
  }

  // Initialize settings & data
  $this->id = $gardener_id;
  $fields = db_select('backup_migrate_gardener', 'bmg')
    ->fields('bmg')
    ->condition('bmg.gardener_id', $gardener_id)
    ->execute()
    ->fetch();
  if (!$fields) {
    throw new ErrorException(t('ID not foud to load gardener.'), \GARDENER::INVALID_ID, WATCHDOG_ERROR);
  }
  $this
    ->setSettings(unserialize($fields->settings));
  $this
    ->setDestination(backup_migrate_get_destination($fields->destination_id));
  $this
    ->setName($fields->name);
  $this
    ->setCreated($fields->created);
}