/** * Performs an operation on the payment method entity. * * @param \Drupal\uc_payment\PaymentMethodInterface $uc_payment_method * The payment method entity. * @param string $op * The operation to perform, usually 'enable' or 'disable'. * * @return \Symfony\Component\HttpFoundation\RedirectResponse * A redirect back to the payment method listing page. */ public function performOperation(PaymentMethodInterface $uc_payment_method, $op) { $uc_payment_method->{$op}()->save(); if ($op == 'enable') { drupal_set_message($this->t('The %label payment method has been enabled.', ['%label' => $uc_payment_method->label()])); } elseif ($op == 'disable') { drupal_set_message($this->t('The %label payment method has been disabled.', ['%label' => $uc_payment_method->label()])); } $url = $uc_payment_method->toUrl('collection'); return $this->redirect($url->getRouteName(), $url->getRouteParameters(), $url->getOptions()); }
/** * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { $this->entity->save(); drupal_set_message($this->t('Saved the %label payment method.', ['%label' => $this->entity->label()])); $form_state->setRedirectUrl($this->entity->toUrl('collection')); }