You are here

function CartForm::submitEmptyCart in Translation Management Tool 8

Form submit callback to remove the selected items.

File

src/Form/CartForm.php, line 127

Class

CartForm
Source overview form.

Namespace

Drupal\tmgmt\Form

Code

function submitEmptyCart(array $form, FormStateInterface $form_state) {
  \Drupal::entityTypeManager()
    ->getStorage('tmgmt_job_item')
    ->delete(tmgmt_cart_get()
    ->getJobItemsFromCart());
  tmgmt_cart_get()
    ->emptyCart();
  $this
    ->messenger()
    ->addStatus(t('All job items were removed from the cart.'));
}