You are here

public function TaxRateController::performOperation in Ubercart 8.4

Performs an operation on the tax rate entity.

Parameters

\Drupal\uc_tax\TaxRateInterface $uc_tax_rate: The tax rate entity.

string $op: The operation to perform, usually 'enable' or 'disable'.

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect back to the tax rate listing page.

1 string reference to 'TaxRateController::performOperation'
uc_tax.routing.yml in uc_tax/uc_tax.routing.yml
uc_tax/uc_tax.routing.yml

File

uc_tax/src/Controller/TaxRateController.php, line 74

Class

TaxRateController
Route controller for tax rates.

Namespace

Drupal\uc_tax\Controller

Code

public function performOperation(TaxRateInterface $uc_tax_rate, $op) {
  $uc_tax_rate
    ->{$op}()
    ->save();
  if ($op == 'enable') {
    $this
      ->messenger()
      ->addMessage($this
      ->t('The %label tax rate has been enabled.', [
      '%label' => $uc_tax_rate
        ->label(),
    ]));
  }
  elseif ($op == 'disable') {
    $this
      ->messenger()
      ->addMessage($this
      ->t('The %label tax rate has been disabled.', [
      '%label' => $uc_tax_rate
        ->label(),
    ]));
  }
  $url = $uc_tax_rate
    ->toUrl('collection');
  return $this
    ->redirect($url
    ->getRouteName(), $url
    ->getRouteParameters(), $url
    ->getOptions());
}