Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Latest commit

 

History

History
38 lines (27 loc) · 689 Bytes

README.md

File metadata and controls

38 lines (27 loc) · 689 Bytes

Translatable Exception

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());
}