You are here

public function ShippingQuoteMethodController::performOperation in Ubercart 8.4

Performs an operation on the shipping quote method entity.

Parameters

\Drupal\uc_quote\ShippingQuoteMethodInterface $uc_quote_method: The shipping quote method entity.

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

Return value

\Symfony\Component\HttpFoundation\RedirectResponse A redirect back to the shipping quote method listing page.

1 string reference to 'ShippingQuoteMethodController::performOperation'
uc_quote.routing.yml in shipping/uc_quote/uc_quote.routing.yml
shipping/uc_quote/uc_quote.routing.yml

File

shipping/uc_quote/src/Controller/ShippingQuoteMethodController.php, line 40

Class

ShippingQuoteMethodController
Route controller for shipping quote methods.

Namespace

Drupal\uc_quote\Controller

Code

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