function uc_order_actions in Ubercart 8.4
Same name and namespace in other branches
- 5 uc_order/uc_order.module \uc_order_actions()
- 6.2 uc_order/uc_order.module \uc_order_actions()
- 7.3 uc_order/uc_order.module \uc_order_actions()
Returns the actions a user may perform on an order.
Parameters
\Drupal\uc_order\OrderInterface $order: The order to return the actions for.
Return value
array A renderable set of operation links.
1 call to uc_order_actions()
- Actions::render in uc_order/
src/ Plugin/ views/ field/ Actions.php - Renders the field.
1 string reference to 'uc_order_actions'
- OrderViewsData::getViewsData in uc_order/
src/ OrderViewsData.php - Returns views data for the entity type.
File
- uc_order/
uc_order.module, line 515 - Handles all things concerning Ubercart orders.
Code
function uc_order_actions(OrderInterface $order, $icon_html = FALSE) {
$user = \Drupal::currentUser();
$actions = [];
if ($user
->hasPermission('view all orders')) {
$actions['view'] = [
'title' => t('View'),
'url' => $order
->toUrl(),
'weight' => 0,
];
$actions['print'] = [
'title' => t('Print'),
'url' => Url::fromRoute('uc_order.admin_invoice_print', [
'uc_order' => $order
->id(),
]),
'weight' => 5,
];
}
else {
if ($order
->access('view')) {
$actions['view'] = [
'title' => t('View'),
'url' => Url::fromRoute('uc_order.user_view', [
'user' => $user
->id(),
'uc_order' => $order
->id(),
]),
'weight' => 0,
];
}
if ($order
->access('invoice')) {
$actions['print'] = [
'title' => t('Print'),
'url' => Url::fromRoute('uc_order.user_invoice_print', [
'user' => $user
->id(),
'uc_order' => $order
->id(),
]),
'weight' => 5,
];
}
}
if ($order
->access('update')) {
$actions['edit'] = [
'title' => t('Edit'),
'url' => $order
->toUrl('edit-form'),
'weight' => 10,
];
}
if ($order
->access('delete')) {
$actions['delete'] = [
'title' => t('Delete'),
'url' => $order
->toUrl('delete-form'),
'weight' => 20,
];
}
$extra = \Drupal::moduleHandler()
->invokeAll('uc_order_actions', [
$order,
]);
if (count($extra)) {
$actions = array_merge($actions, $extra);
}
\Drupal::moduleHandler()
->alter('uc_order_actions', $actions, $order);
return [
'#type' => 'operations',
'#links' => $actions,
];
}