Ojs\JournalBundle\Entity\Journal::translate PHP Метод

translate() публичный Метод

Translation helper method
public translate ( null $locale = null ) : mixed | null | JournalTranslation
$locale null
Результат mixed | null | JournalTranslation
    public function translate($locale = null)
    {
        if (null === $locale) {
            $locale = $this->currentLocale;
        }
        if (!$locale) {
            throw new \RuntimeException('No locale has been set and currentLocale is empty');
        }
        if ($this->currentTranslation && $this->currentTranslation->getLocale() === $locale) {
            return $this->currentTranslation;
        }
        $defaultTranslation = $this->translations->get($this->getDefaultLocale());
        if (!($translation = $this->translations->get($locale))) {
            $translation = new JournalTranslation();
            if (!is_null($defaultTranslation)) {
                $translation->setTitle($defaultTranslation->getTitle());
                $translation->setSubtitle($defaultTranslation->getSubtitle());
                $translation->setDescription($defaultTranslation->getDescription());
                $translation->setTitleAbbr($defaultTranslation->getTitleAbbr());
                $translation->setFooterText($defaultTranslation->getFooterText());
            }
            $translation->setLocale($locale);
            $this->addTranslation($translation);
        }
        $this->currentTranslation = $translation;
        return $translation;
    }
Journal