FulfillmentMethodController.php in Ubercart 8.4
File
shipping/uc_fulfillment/src/Controller/FulfillmentMethodController.php
View source
<?php
namespace Drupal\uc_fulfillment\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\uc_fulfillment\FulfillmentMethodInterface;
class FulfillmentMethodController extends ControllerBase {
public function addForm($plugin_id) {
$entity = $this
->entityTypeManager()
->getStorage('uc_fulfillment_method')
->create([
'plugin' => $plugin_id,
]);
return $this
->entityFormBuilder()
->getForm($entity);
}
public function performOperation(FulfillmentMethodInterface $uc_fulfillment_method, $op) {
$uc_fulfillment_method
->{$op}()
->save();
if ($op == 'enable') {
$this
->messenger()
->addMessage($this
->t('The %label fulfillment method has been enabled.', [
'%label' => $uc_fulfillment_method
->label(),
]));
}
elseif ($op == 'disable') {
$this
->messenger()
->addMessage($this
->t('The %label fulfillment method has been disabled.', [
'%label' => $uc_fulfillment_method
->label(),
]));
}
$url = $uc_fulfillment_method
->toUrl('collection');
return $this
->redirect($url
->getRouteName(), $url
->getRouteParameters(), $url
->getOptions());
}
}