本文整理汇总了PHP中Symfony\Component\Translation\TranslatorInterface::has方法的典型用法代码示例。如果您正苦于以下问题:PHP TranslatorInterface::has方法的具体用法?PHP TranslatorInterface::has怎么用?PHP TranslatorInterface::has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Translation\TranslatorInterface
的用法示例。
在下文中一共展示了TranslatorInterface::has方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolveMessage
/**
* Resolve an error message from the translator.
*
* @return string|null
*/
protected function resolveMessage()
{
if (!$this->translator->has($code = "errors.{$this->errorCode}")) {
return null;
}
return $this->translator->trans($code, $this->parameters);
}
示例2: __construct
/**
* @param \LaravelPlus\Extension\Repository\NamespacedRepository $specs
* @param \Symfony\Component\Translation\TranslatorInterface $translator
* @param string $path
*/
public function __construct(NamespacedRepository $specs, TranslatorInterface $translator, $path)
{
$rules = $specs->get($path);
if (is_null($rules)) {
throw new InvalidArgumentException("spec '{$path}' is not found");
}
if (!is_array($rules)) {
throw new InvalidArgumentException('$rules must array in path ' . $path);
}
if (!$translator->has($path)) {
throw new InvalidArgumentException("translate '{$path}' is not found");
}
if (strpos($path, '::') !== false) {
list($namespace, $path) = explode('::', $path, 2);
} else {
$namespace = '';
}
$this->path = $path;
$this->namespace = $namespace;
$this->rules = $rules;
$this->translator = new Translator($translator, $namespace);
$this->resolveSpecReferences();
}
示例3: has
/**
* Determine if a translation exists.
*
* @param string $key
* @param string $locale
* @return bool
*/
public function has($key, $locale = null)
{
return $this->translator->has($this->fullkey($key));
}