/**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $form['help'] = array('#markup' => t('By default, only the "Free order" payment method is listed here. To see additional payment methods you must <a href="@install">install additional modules</a>. The "Payment Method Pack" module that comes with Ubercart provides "Check" and "COD" payment methods. The "Credit Card" module that comes with Ubercart provides a credit card payment method, although you will need an additional module to provide a payment gateway for your credit card. For more information about payment methods and settings please read the <a href="@doc">Ubercart Documentation</a>.', ['@install' => Url::fromRoute('system.modules_list')->toString(), '@doc' => Url::fromUri('http://www.drupal.org/documentation/modules/ubercart')->toString()]));
     $form['methods'] = array('#type' => 'table', '#header' => array(t('Payment method'), t('List position'), t('Operations')), '#tabledrag' => array(array('action' => 'order', 'relationship' => 'sibling', 'group' => 'uc-payment-method-weight')));
     foreach ($this->paymentMethodManager->getDefinitions() as $id => $method) {
         $form['methods'][$id]['#attributes']['class'][] = 'draggable';
         $form['methods'][$id]['status'] = array('#type' => 'checkbox', '#title' => SafeMarkup::checkPlain($method['name']), '#default_value' => $method['checkout']);
         $form['methods'][$id]['weight'] = array('#type' => 'weight', '#title' => t('Weight for @title', array('@title' => $method['name'])), '#title_display' => 'invisible', '#default_value' => $method['weight'], '#attributes' => array('class' => array('uc-payment-method-weight')));
         if (empty($method['no_gateway'])) {
             $gateways = _uc_payment_gateway_list($id, TRUE);
             $options = array();
             foreach ($gateways as $gateway_id => $gateway) {
                 $options[$gateway_id] = $gateway['title'];
             }
             if ($options) {
                 $form['methods'][$id]['status']['#title'] .= ' (' . t('includes %gateways', array('%gateways' => implode(', ', $options))) . ')';
             }
         }
         $links = array();
         if (!empty($method['settings_form'])) {
             $links['settings'] = array('title' => t('Settings'), 'url' => Url::fromRoute('uc_payment.method_settings', ['method' => $id]));
         }
         // $links['conditions'] = array(
         //   'title' => t('Conditions'),
         //   'url' => Url::fromRoute('admin/store/config/payment/manage/uc_payment_method_', ['method' => $id]),
         // );
         $form['methods'][$id]['settings'] = array('#type' => 'operations', '#links' => $links);
     }
     return parent::buildForm($form, $form_state);
 }
 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state)
 {
     $options = array_map(function ($definition) {
         return $definition['name'];
     }, array_filter($this->paymentMethodManager->getDefinitions(), function ($definition) {
         return !$definition['no_ui'];
     }));
     if ($options) {
         uasort($options, 'strnatcasecmp');
         $form['add'] = array('#type' => 'details', '#title' => $this->t('Add payment method'), '#open' => TRUE, '#attributes' => array('class' => array('container-inline')));
         $form['add']['payment_method_type'] = array('#type' => 'select', '#title' => $this->t('Type'), '#empty_option' => $this->t('- Choose -'), '#options' => $options);
         $form['add']['submit'] = array('#type' => 'submit', '#value' => $this->t('Add payment method'), '#validate' => array('::validateAddPaymentMethod'), '#submit' => array('::submitAddPaymentMethod'), '#limit_validation_errors' => array(array('payment_method_type')));
     }
     $form = parent::buildForm($form, $form_state);
     $form[$this->entitiesKey]['#empty'] = $this->t('No payment methods have been configured.');
     $form['actions']['#type'] = 'actions';
     $form['actions']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save configuration'), '#button_type' => 'primary');
     return $form;
 }