Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $backup_migrate_schedule = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Schedule Name'), '#maxlength' => 255, '#default_value' => $backup_migrate_schedule->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $backup_migrate_schedule->id(), '#machine_name' => array('exists' => '\\Drupal\\backup_migrate\\Entity\\Schedule::load'), '#disabled' => !$backup_migrate_schedule->isNew());
     $form['enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Schedule enabled'), '#default_value' => $backup_migrate_schedule->get('enabled'));
     $bam = backup_migrate_get_service_object([], ['nobrowser' => TRUE]);
     $form['source_id'] = DrupalConfigHelper::getSourceSelector($bam, t('Backup Source'));
     $form['destination_id'] = DrupalConfigHelper::getDestinationSelector($bam, t('Backup Destination'));
     $form['settings_profile_id'] = DrupalConfigHelper::getSettingsProfileSelector(t('Settings Profile'));
     $period = Schedule::secondsToPeriod($backup_migrate_schedule->get('period'));
     $form['period_container'] = array('#parents' => array(), '#type' => 'fieldset', '#title' => $this->t('Frequency'), '#field_prefix' => $this->t('Run every'), '#attributes' => array('class' => array('container-inline', 'fieldgroup', 'form-composite')));
     $form['period_container']['period_number'] = array('#type' => 'number', '#default_value' => $period['number'], '#min' => 1, '#title' => $this->t('Period number'), '#title_display' => 'invisible', '#size' => 2);
     $form['period_container']['period_type'] = ['#type' => 'select', '#title' => $this->t('Period type'), '#title_display' => 'invisible', '#options' => [], '#default_value' => $period['type']];
     foreach (Schedule::getPeriodTypes() as $key => $type) {
         $form['period_container']['period_type']['#options'][$key] = $type['title'];
     }
     //    $form['keep'] = array(
     //      '#type' => 'textfield',
     //      '#title' => $this->t('Number to keep'),
     //      '#default_value' => $backup_migrate_schedule->get('keep'),
     //      '#description' => $this->t('The number of backups to retain. Once this number is reached, the oldest backup will be deleted to make room for the most recent backup. Leave blank to keep all backups.'),
     //      '#size' => 10,
     //    );
     return $form;
 }
 /**
  * @param array $form
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  * @param null $backup_migrate_destination
  * @param null $backup_id
  * @return array
  */
 public function buildForm(array $form, FormStateInterface $form_state, $backup_migrate_destination = NULL, $backup_id = NULL)
 {
     $this->destination = $backup_migrate_destination;
     $this->backup_id = $backup_id;
     $bam = backup_migrate_get_service_object();
     $form['source_id'] = DrupalConfigHelper::getPluginSelector($bam->sources(), $this->t('Restore To'));
     $conf_schema = $bam->plugins()->map('configSchema', array('operation' => 'restore'));
     $form += DrupalConfigHelper::buildFormFromSchema($conf_schema, $bam->plugins()->config());
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $backup_migrate_settings = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $backup_migrate_settings->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $backup_migrate_settings->id(), '#machine_name' => array('exists' => '\\Drupal\\backup_migrate\\Entity\\SettingsProfile::load'), '#disabled' => !$backup_migrate_settings->isNew());
     $bam = backup_migrate_get_service_object($backup_migrate_settings->get('config'));
     $form['config'] = DrupalConfigHelper::buildAllPluginsForm($bam->plugins(), 'backup', ['config']);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = array();
     $bam = backup_migrate_get_service_object();
     $form['backup_migrate_restore_upload'] = array('#title' => t('Upload a Backup File'), '#type' => 'file', '#description' => t("Upload a backup file created by Backup and Migrate. For other database or file backups please use another tool for import. Max file size: %size", array("%size" => format_size(file_upload_max_size()))));
     $form['source_id'] = DrupalConfigHelper::getPluginSelector($bam->sources(), $this->t('Restore To'));
     $conf_schema = $bam->plugins()->map('configSchema', array('operation' => 'restore'));
     $form += DrupalConfigHelper::buildFormFromSchema($conf_schema, $bam->plugins()->config());
     $form['quickbackup']['submit'] = array('#type' => 'submit', '#value' => t('Restore now'), '#weight' => 1);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = array();
     // Theme the form if we want it inline.
     // @FIXME
     // $form['#theme'] = 'backup_migrate_ui_manual_quick_backup_form_inline';
     $bam = backup_migrate_get_service_object();
     $form['source'] = array('#type' => 'fieldset', "#title" => t("Source"), "#collapsible" => TRUE, "#collapsed" => FALSE, "#tree" => FALSE);
     $form['source']['source_id'] = DrupalConfigHelper::getSourceSelector($bam, t('Backup Source'));
     $form['source']['source_id']['#default_value'] = \Drupal::config('backup_migrate.settings')->get('backup_migrate_source_id');
     $form += DrupalConfigHelper::buildAllPluginsForm($bam->plugins(), 'backup');
     $form['destination'] = array('#type' => 'fieldset', "#title" => t("Destination"), "#collapsible" => TRUE, "#collapsed" => FALSE, "#tree" => FALSE);
     $form['destination']['destination_id'] = DrupalConfigHelper::getDestinationSelector($bam, t('Backup Destination'));
     $form['destination']['destination_id']['#default_value'] = \Drupal::config('backup_migrate.settings')->get('backup_migrate_destination_id');
     $form['quickbackup']['submit'] = array('#type' => 'submit', '#value' => t('Backup now'), '#weight' => 1);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form = array();
     // Theme the form if we want it inline.
     // @FIXME
     // $form['#theme'] = 'backup_migrate_ui_manual_quick_backup_form_inline';
     $bam = backup_migrate_get_service_object();
     $form['quickbackup'] = array('#type' => 'fieldset', "#title" => t("Quick Backup"), "#collapsible" => FALSE, "#collapsed" => FALSE, "#tree" => FALSE);
     $form['quickbackup']['source_id'] = DrupalConfigHelper::getPluginSelector($bam->plugins()->getAllByOp('exportToFile'), t('Backup Source'));
     $form['quickbackup']['destination_id'] = DrupalConfigHelper::getPluginSelector($bam->plugins()->getAllByOp('saveFile'), t('Backup Destination'));
     // Create the service
     //    $bam = backup_migrate_get_service_object($config);
     //    $bam->plugins()->get('namer')->confGet('filename');
     // $form['quickbackup']['source_id'] = _backup_migrate_get_source_pulldown(\Drupal::config('backup_migrate.settings')->get('backup_migrate_source_id'));
     // $form['quickbackup']['destination'] = _backup_migrate_get_destination_pulldown('manual backup', \Drupal::config('backup_migrate.settings')->get('backup_migrate_destination_id'), \Drupal::config('backup_migrate.settings')->get('backup_migrate_copy_destination_id'));
     $form['quickbackup']['submit'] = array('#type' => 'submit', '#value' => t('Backup now'), '#weight' => 1);
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, '#default_value' => $this->entity->label(), '#description' => $this->t("Label for the Backup Source."), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $this->entity->id(), '#machine_name' => array('exists' => '\\Drupal\\backup_migrate\\Entity\\Source::load'), '#disabled' => !$this->entity->isNew());
     if (!$this->entity->get('type')) {
         $form['type'] = array('#type' => 'radios', '#title' => $this->t('Type'));
         foreach ($this->entity->getPluginManager()->getDefinitions() as $type) {
             if (empty($type['locked'])) {
                 $form['type']['#options'][$type['id']] = $type['title'];
                 $form['type'][$type['id']]['#description'] = $type['description'];
             }
         }
     } else {
         $type = $this->entity->getPlugin()->getPluginDefinition();
         $form['type'] = array('#type' => 'value', '#value' => $type['id'], '#markup' => $this->t("Type: @type", ['@type' => $type['title']]));
         if ($bam_plugin = $this->entity->getObject()) {
             $form['config'] = DrupalConfigHelper::buildPluginForm($bam_plugin, 'initialize', ['config']);
         }
     }
     return $form;
 }
 /**
  * {@inheritdoc}
  */
 public function form(array $form, FormStateInterface $form_state)
 {
     $form = parent::form($form, $form_state);
     $backup_migrate_schedule = $this->entity;
     $form['label'] = array('#type' => 'textfield', '#title' => $this->t('Schedule Name'), '#maxlength' => 255, '#default_value' => $backup_migrate_schedule->label(), '#required' => TRUE);
     $form['id'] = array('#type' => 'machine_name', '#default_value' => $backup_migrate_schedule->id(), '#machine_name' => array('exists' => '\\Drupal\\backup_migrate\\Entity\\Schedule::load'), '#disabled' => !$backup_migrate_schedule->isNew());
     $form['enabled'] = array('#type' => 'checkbox', '#title' => $this->t('Schedule enabled'), '#default_value' => $backup_migrate_schedule->get('enabled'));
     $bam = backup_migrate_get_service_object([], ['nobrowser' => TRUE]);
     $form['source_id'] = DrupalConfigHelper::getPluginSelector($bam->plugins()->getAllByOp('exportToFile'), t('Backup Source'));
     $form['source_id']['source_id']['#default_value'] = $backup_migrate_schedule->get('source_id');
     $form['destination_id'] = DrupalConfigHelper::getPluginSelector($bam->plugins()->getAllByOp('saveFile'), t('Backup Destination'));
     $form['source_id']['destination_id']['#default_value'] = $backup_migrate_schedule->get('destination_id');
     $form['period'] = array('#type' => 'textfield', '#title' => $this->t('Frequency'), '#default_value' => $backup_migrate_schedule->get('period'), '#field_suffix' => $this->t('Seconds'), '#size' => 10);
     //    $form['keep'] = array(
     //      '#type' => 'textfield',
     //      '#title' => $this->t('Number to keep'),
     //      '#default_value' => $backup_migrate_schedule->get('keep'),
     //      '#description' => $this->t('The number of backups to retain. Once this number is reached, the oldest backup will be deleted to make room for the most recent backup. Leave blank to keep all backups.'),
     //      '#size' => 10,
     //    );
     return $form;
 }
 /**
  * Get a select form item for the given list of sources
  *
  * @param \BackupMigrate\Core\Main\BackupMigrateInterface $bam
  * @param $title
  * @return array
  */
 public static function getDestinationSelector(BackupMigrateInterface $bam, $title)
 {
     return DrupalConfigHelper::getPluginSelector($bam->destinations(), $title);
 }