public function handleAction(ActionEvent $event) { $environment = $event->getEnvironment(); if ($environment->getDataDefinition()->getName() != 'orm_avisota_queue') { return; } $action = $event->getAction(); if ($action->getName() == 'clear') { $input = $environment->getInputProvider(); $id = IdSerializer::fromSerialized($input->getParameter('id')); $repository = EntityHelper::getRepository('Avisota\\Contao:Queue'); /** @var \Avisota\Contao\Entity\Queue $queueData */ $queueData = $repository->find($id->getId()); /** @var QueueInterface $queue */ $queue = $GLOBALS['container'][sprintf('avisota.queue.%s', $queueData->getAlias())]; $queue->execute(new NullTransport()); $message = new AddMessageEvent(sprintf($GLOBALS['TL_LANG']['orm_avisota_queue']['queueCleared'], $queueData->getTitle()), AddMessageEvent::TYPE_CONFIRM); $event->getDispatcher()->dispatch(ContaoEvents::MESSAGE_ADD, $message); $redirect = new RedirectEvent('contao/main.php?do=avisota_queue&ref=' . TL_REFERER_ID); $event->getDispatcher()->dispatch(ContaoEvents::CONTROLLER_REDIRECT, $redirect); } }