public function getTranslation($lang)
    {
        // Check if locale given
        if (strpos($lang, '_')) {
            $parts = explode('_', $lang);
            $lang = array_shift($parts);
        }

        foreach ($this->getTranslations() as $translation) {
            if ($translation->getLang() === $lang) {
                return $translation;
            }
        }

        $translation = new LayoutTranslation($lang);
        $translation->setLayout($this);

        return $translation;
    }
public function getTranslation($lang)
    {
        // Check if locale given
        if (strpos($lang, '_')) {
            $parts = explode('_', $lang);
            $lang = array_shift($parts);
        }

        foreach ($this->getTranslations() as $translation) {
            if ($translation->getLang() === $lang) {
                return $translation;
            }
        }

        $translation = new LayoutTranslation($lang);
        $translation->setLayout($this);

        return $translation;
    }
public function getTranslation ( $ lang ) { // Check if locale given if ( strpos ( $ lang , '_' ) ) { $ parts = explode ( '_' , $ lang ) ; $ lang = array_shift ( $ parts ) ; } foreach ( $ this -> getTranslations ( ) as $ translation ) { if ( $ translation -> getLang ( ) === $ lang ) { return $ translation ; } } $ translation = new LayoutTranslation ( $ lang ) ; $ translation -> setLayout ( $ this ) ; return $ translation ; }
Get LayoutTranslation for a given lang, if not exist it will be created

@param string $lang

@return \Lexik\Bundle\MailerBundle\Entity\LayoutTranslation
Get LayoutTranslation for a given lang if not exist it will be created