| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Util\Translation; |
| 4 |
|
| 5 |
/** |
| 6 |
* The single rule for turning a context key into a store-facing string name. |
| 7 |
* |
| 8 |
* Separate-table contexts (msg/mail/redirect) are already globally unique; |
| 9 |
* form_content contexts are unique only within their form, so they carry a |
| 10 |
* "-form-{id}" suffix. Every registering provider must agree on this, otherwise |
| 11 |
* one form's strings land under two different names in the same store. |
| 12 |
*/ |
| 13 |
final class TranslationStringName |
| 14 |
{ |
| 15 |
/** |
| 16 |
* @param mixed $context |
| 17 |
* @param mixed $formId |
| 18 |
* |
| 19 |
* @return string |
| 20 |
*/ |
| 21 |
public static function forForm($context, $formId) |
| 22 |
{ |
| 23 |
$context = (string) $context; |
| 24 |
if (preg_match('/^(msg|mail|redirect)-/', $context)) { |
| 25 |
return $context; |
| 26 |
} |
| 27 |
return $context . '-form-' . (int) $formId; |
| 28 |
} |
| 29 |
} |
| 30 |
|