farmaprom / translatable-exception
Exception that can be translated
v1.1.0
2021-06-14 13:05 UTC
Requires
- php: ~5.4|~7.0|~8.0
This package is auto-updated.
Last update: 2025-05-10 16:02:34 UTC
README
Example usage
<?php use FarmaProm\TranslatableException\TranslatableException; require_once __DIR__ . '/vendor/autoload.php'; class MyException extends TranslatableException { public function getTranslationKey() { return 'my_key'; } public function getTranslationDomain() { return 'my_domain'; } } try { throw (new MyException())->setTranslationParams(['param' => 'test']); } catch (TranslatableException $e) { var_export($e); // Example usage with translator // $translator->trans($e->getTranslationKey(), $e->getTranslationParams(), $e->getTranslationDomain()); }