Exemplo n.º 1
0
 /**
  * {@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;
 }