コード例 #1
0
ファイル: ScheduleForm.php プロジェクト: r-daneelolivaw/chalk
 /**
  * {@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;
 }
コード例 #2
0
 /**
  * {@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;
 }
コード例 #3
0
 /**
  * {@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::getSourceSelector($bam, t('Backup Source'));
     $form['quickbackup']['destination_id'] = DrupalConfigHelper::getDestinationSelector($bam, t('Backup Destination'));
     $form['quickbackup']['settings_profile_id'] = DrupalConfigHelper::getSettingsProfileSelector(t('Settings Profile'));
     // Create the service
     //    $bam = backup_migrate_get_service_object();
     //    $bam->setConfig($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;
 }