Code Duplication    Length = 26-26 lines in 2 locations

application/modules/xbanners/models/Base/BannerImage.php 1 location

@@ 1975-2000 (lines=26) @@
1972
     * @param     ConnectionInterface $con an optional connection object
1973
     *
1974
     * @return ChildBannerImageI18n */
1975
    public function getTranslation($locale = 'ru', ConnectionInterface $con = null)
1976
    {
1977
        if (!isset($this->currentTranslations[$locale])) {
1978
            if (null !== $this->collBannerImageI18ns) {
1979
                foreach ($this->collBannerImageI18ns as $translation) {
1980
                    if ($translation->getLocale() == $locale) {
1981
                        $this->currentTranslations[$locale] = $translation;
1982
1983
                        return $translation;
1984
                    }
1985
                }
1986
            }
1987
            if ($this->isNew()) {
1988
                $translation = new ChildBannerImageI18n();
1989
                $translation->setLocale($locale);
1990
            } else {
1991
                $translation = ChildBannerImageI18nQuery::create()
1992
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
1993
                    ->findOneOrCreate($con);
1994
                $this->currentTranslations[$locale] = $translation;
1995
            }
1996
            $this->addBannerImageI18n($translation);
1997
        }
1998
1999
        return $this->currentTranslations[$locale];
2000
    }
2001
2002
    /**
2003
     * Remove the translation for a given locale

application/modules/xbanners/models/Base/Banners.php 1 location

@@ 1923-1948 (lines=26) @@
1920
     * @param     ConnectionInterface $con an optional connection object
1921
     *
1922
     * @return ChildBannersI18n */
1923
    public function getTranslation($locale = 'ru', ConnectionInterface $con = null)
1924
    {
1925
        if (!isset($this->currentTranslations[$locale])) {
1926
            if (null !== $this->collBannersI18ns) {
1927
                foreach ($this->collBannersI18ns as $translation) {
1928
                    if ($translation->getLocale() == $locale) {
1929
                        $this->currentTranslations[$locale] = $translation;
1930
1931
                        return $translation;
1932
                    }
1933
                }
1934
            }
1935
            if ($this->isNew()) {
1936
                $translation = new ChildBannersI18n();
1937
                $translation->setLocale($locale);
1938
            } else {
1939
                $translation = ChildBannersI18nQuery::create()
1940
                    ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale))
1941
                    ->findOneOrCreate($con);
1942
                $this->currentTranslations[$locale] = $translation;
1943
            }
1944
            $this->addBannersI18n($translation);
1945
        }
1946
1947
        return $this->currentTranslations[$locale];
1948
    }
1949
1950
    /**
1951
     * Remove the translation for a given locale