ShippingQuoteMethodController.php in Ubercart 8.4
File
shipping/uc_quote/src/Controller/ShippingQuoteMethodController.php
View source
<?php
namespace Drupal\uc_quote\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\uc_quote\ShippingQuoteMethodInterface;
class ShippingQuoteMethodController extends ControllerBase {
public function addForm($plugin_id) {
$entity = $this
->entityTypeManager()
->getStorage('uc_quote_method')
->create([
'plugin' => $plugin_id,
]);
return $this
->entityFormBuilder()
->getForm($entity);
}
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());
}
}