Usage
Initialization
To automatically display toasts and alerts in your templates,
add the following Twig function in your base.html.twig (or the layout file):
{{ ux_sweet_alert_scripts() }}Toasts
To use UX SweetAlert, inject the AlertManagerInterface service and
use the toast() method to create toasts in PHP:
use Pentiminax\UX\SweetAlert\AlertManagerInterface;use Pentiminax\UX\SweetAlert\Enum\Position;
class HomeController extends AbstractController{ #[Route('/', name: 'app_homepage')] public function index(AlertManagerInterface $alertManager): Response { $alertManager->toast( title: 'title', text: 'text', position: Position::TOP_END, timer: 3000, timerProgressBar: true );
return $this->render('home/index.html.twig'); }}